powerpc/pseries: Macros and wrapper functions for H_HTM call
Subsystems (2)
Madhavan Srinivasan
maintainerPATCH 1/3 powerpc/pseries: Macros and wrapper functions for H_HTM call
Define macros and wrapper functions to handle H_HTM (Hardware Trace Macro) hypervisor call. H_HTM is new HCALL added to export data from Hardware Trace Macro (HTM) function.
--- arch/powerpc/include/asm/hvcall.h | 34 +++++++++++++++++++++++ arch/powerpc/include/asm/plpar_wrappers.h | 21 ++++++++++++++ 2 files changed, 55 insertions(+)
arch/powerpc/include/asm/hvcall.h +34 -0
@@ -348,6 +348,7 @@#define H_SCM_FLUSH 0x44C#define H_GET_ENERGY_SCALE_INFO 0x450#define H_PKS_SIGNED_UPDATE 0x454 +#define H_HTM 0x458#define H_WATCHDOG 0x45C#define H_GUEST_GET_CAPABILITIES 0x460#define H_GUEST_SET_CAPABILITIES 0x464
@@ -497,6 +498,39 @@#define H_GUEST_CAP_POWER10 (1UL<<(63-2))#define H_GUEST_CAP_BITMAP2 (1UL<<(63-63)) +/* +* Defines for H_HTM - Macros for hardware trace macro (HTM) function. +*/ +#define H_HTM_FLAGS_HARDWARE_TARGET (1ul << 63) +#define H_HTM_FLAGS_LOGICAL_TARGET (1ul << 62) +#define H_HTM_FLAGS_PROCID_TARGET (1ul << 61) +#define H_HTM_FLAGS_NOWRAP (1ul << 60) + +#define H_HTM_OP_SHIFT (63-15) +#define H_HTM_OP (x) ((unsigned long)(x)<<H_HTM_OP_SHIFT) +#define H_HTM_OP_CAPABILITIES 0x01 +#define H_HTM_OP_STATUS 0x02 +#define H_HTM_OP_SETUP 0x03 +#define H_HTM_OP_CONFIGURE 0x04 +#define H_HTM_OP_START 0x05 +#define H_HTM_OP_STOP 0x06 +#define H_HTM_OP_DECONFIGURE 0x07 +#define H_HTM_OP_DUMP_DETAILS 0x08 +#define H_HTM_OP_DUMP_DATA 0x09 +#define H_HTM_OP_DUMP_SYSMEM_CONF 0x0a +#define H_HTM_OP_DUMP_SYSPROC_CONF 0x0b + +#define H_HTM_TYPE_SHIFT (63-31) +#define H_HTM_TYPE (x) ((unsigned long)(x)<<H_HTM_TYPE_SHIFT) +#define H_HTM_TYPE_NEST 0x01 +#define H_HTM_TYPE_CORE 0x02 +#define H_HTM_TYPE_LLAT 0x03 +#define H_HTM_TYPE_GLOBAL 0xff + +#define H_HTM_TARGET_NODE_INDEX (x) ((unsigned long)(x)<<(63-15)) +#define H_HTM_TARGET_NODAL_CHIP_INDEX (x) ((unsigned long)(x)<<(63-31)) +#define H_HTM_TARGET_CORE_INDEX_ON_CHIP (x) ((unsigned long)(x)<<(63-47)) +#ifndef __ASSEMBLY__#include <linux/types.h>
arch/powerpc/include/asm/plpar_wrappers.h +21 -0
@@ -93,6 +93,27 @@ static inline long register_dtl(unsigned long cpu, unsigned long vpa)return vpa_call (H_VPA_REG_DTL , cpu, vpa); } +static inline long htm_call (unsigned long flags,unsigned long target, +unsigned long operation,unsigned long param1, +unsigned long param2,unsigned long param3) +{ +return plpar_hcall_norets (H_HTM , flags, target, operation, + param1, param2, param3); +} + +static inline long htm_get_dump_hardware (unsigned long nodeindex, +unsigned long nodalchipindex,unsigned long coreindexonchip, +unsigned long type,unsigned long addr,unsigned long size, +unsigned long offset) +{ +return htm_call (H_HTM_FLAGS_HARDWARE_TARGET , +H_HTM_TARGET_NODE_INDEX (nodeindex) | +H_HTM_TARGET_NODAL_CHIP_INDEX (nodalchipindex) | +H_HTM_TARGET_CORE_INDEX_ON_CHIP (coreindexonchip), +H_HTM_OP (H_HTM_OP_DUMP_DATA ) |H_HTM_TYPE (type), + addr, size, offset); +} +extern void vpa_init (int cpu); static inline long plpar_pte_enter(unsigned long flags,
Signature · 1 line
2.45.2
Madhavan Srinivasan
maintainerPATCH 2/3 powerpc/pseries: Export hardware trace macro dump via debugfs
This patch adds debugfs interface to export Hardware Trace Macro (HTM) function data in a LPAR. New hypervisor call "H_HTM" has been defined to setup, configure, control and dump the HTM data. This patch supports only dumping of HTM data in a LPAR.
New debugfs folder called "htmdump" has been added under /sys/kernel/debug/arch path which contains files need to
pass required parameters for the H_HTM dump function. New Kconfig option called "CONFIG_HTMDUMP" has been in platform/pseries for the same.
With patch series applied and booted, list of files in debugfs path
# pwd /sys/kernel/debug/powerpc/htmdump # ls coreindexonchip htmtype nodalchipindex nodeindex trace
--- arch/powerpc/platforms/pseries/Kconfig | 8 ++ arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/htmdump.c | 130 +++++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 arch/powerpc/platforms/pseries/htmdump.c
arch/powerpc/platforms/pseries/Kconfig +8 -0
@@ -128,6 +128,14 @@ config CMM will be reused for other LPARs. The interface allows firmware to balance memory across many LPARs. +config HTMDUMP + tristate "PHYP HTM data dumper" + default y + help + Select this option, if you want to enable the kernel debugfs + interface to dump the Hardware Trace Macro (HTM) function data + in the LPAR. + config HV_PERF_CTRS bool "Hypervisor supplied PMU events (24x7 & GPCI)" default y
arch/powerpc/platforms/pseries/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o obj-$(CONFIG_HVCS) += hvcserver.o obj-$(CONFIG_HCALL_STATS) += hvCall_inst.o obj-$(CONFIG_CMM) += cmm.o +obj-$(CONFIG_HTMDUMP) += htmdump.o obj-$(CONFIG_IO_EVENT_IRQ) += io_event_irq.o obj-$(CONFIG_LPARCFG) += lparcfg.o obj-$(CONFIG_IBMVIO) += vio.o
arch/powerpc/platforms/pseries/htmdump.c new file +130 -0
130 lines not on this page · raw message
Signature · 1 line
2.45.2
Madhavan Srinivasan
maintainerPATCH 3/3 powerpc: Document details on H_HTM hcall
In reply to Madhavan SrinivasanAdd documentation to 'papr_hcalls.rst' describing the input, output and return values of the H_HTM hcall as per the internal specification.
--- Documentation/arch/powerpc/papr_hcalls.rst | 11 +++++++++++ 1 file changed, 11 insertions(+)
Documentation/arch/powerpc/papr_hcalls.rst +11 -0
@@ -289,6 +289,17 @@ to be issued multiple times in order to be completely serviced. The subsequent hcalls to the hypervisor until the hcall is completely serviced at which point H_SUCCESS or other error is returned by the hypervisor. +**H_HTM** + +| Input: flags, target, operation (op), op-param1, op-param2, op-param3 +| Out: *dumphtmbufferdata* +| Return Value: *H_Success,H_Busy,H_LongBusyOrder,H_Partial,H_Parameter, + H_P2,H_P3,H_P4,H_P5,H_P6,H_State,H_Not_Available,H_Authority* + +H_HTM supports setup, configuration, control and dumping of Hardware Trace +Macro (HTM) function and its data. HTM buffer stores tracing data for functions +like core instruction, core LLAT and nest. + References ========== .. [1] "Power Architecture Platform Reference"
Signature · 1 line
2.45.2
Ritesh Harjani (IBM)
reviewerRe: [PATCH 2/3] powerpc/pseries: Export hardware trace macro dump via debugfs
In reply to Madhavan SrinivasanThis is a generic review and I haven't looked into the PAPR spec for htmdump hcall and it's interface.
Quoted 29 lines · Madhavan Srinivasan
This patch adds debugfs interface to export Hardware Trace Macro (HTM) function data in a LPAR. New hypervisor call "
H_HTM" has been defined to setup, configure, control and dump the HTM data. This patch supports only dumping of HTM data in a LPAR.
New debugfs folder called "htmdump" has been added under/sys/kernel/debug/archpath which contains files need to
pass required parameters for theH_HTMdump function. NewKconfigoption called "CONFIG_HTMDUMP" has been in platform/pseries for the same.With patch series applied and booted, list of files in debugfs path
# pwd /sys/kernel/debug/powerpc/htmdump # ls coreindexonchip htmtype nodalchipindex nodeindex traceSigned-off-by Madhavan Srinivasan <[email protected]>--- arch/powerpc/platforms/pseries/Kconfig | 8 ++ arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/htmdump.c | 130 +++++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 arch/powerpc/platforms/pseries/htmdump.carch/powerpc/platforms/pseries/Kconfig +0
-0
arch/powerpc/platforms/pseries/Kconfig config CMM · line 132
Quoted 5 lines
arch/powerpc/platforms/pseries/Kconfig +2
-0@@ -128,6 +128,14 @@ config CMM will be reused for other LPARs. The interface allows firmware to balance memory across many LPARs. +config HTMDUMP + tristate "PHYP HTM data dumper"
Not sure if we can make machine_device_initcall() as a tristate? Did we try compiling it as a module?
It we would like to keep this as a module - then why not use module_init call and then make it depend upon...
depends on PPC_PSERIES && DEBUG_FS (??)
arch/powerpc/platforms/pseries/Kconfig config CMM · line 133
Quoted 1 line
arch/powerpc/platforms/pseries/Kconfig +1
-0+ default y
and then since this is mostly a debug trace facility, then we need not enable it by default right?
Quoted 36 lines
arch/powerpc/platforms/pseries/Kconfig +5
-0+ help + Select this option, if you want to enable the kernel debugfs + interface to dump the Hardware Trace Macro (HTM) function data + in the LPAR. + config HV_PERF_CTRS bool "Hypervisor supplied PMU events (24x7 & GPCI)" default yarch/powerpc/platforms/pseries/Makefile +1
-0@@ -19,6 +19,7 @@ obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o obj-$(CONFIG_HVCS) += hvcserver.o obj-$(CONFIG_HCALL_STATS) += hvCall_inst.o obj-$(CONFIG_CMM) += cmm.o +obj-$(CONFIG_HTMDUMP) += htmdump.o obj-$(CONFIG_IO_EVENT_IRQ) += io_event_irq.o obj-$(CONFIG_LPARCFG) += lparcfg.o obj-$(CONFIG_IBMVIO) += vio.oarch/powerpc/platforms/pseries/htmdump.c new file +10
-0@@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) IBM Corporation, 2024 +*/ + +#define pr_fmt (fmt) "htmdump: " fmt + +#include <linux/bitops.h> +#include <linux/string.h> +#include <linux/init.h>
arch/powerpc/platforms/pseries/htmdump.c line 20
Quoted 10 lines
arch/powerpc/platforms/pseries/htmdump.c new file +10
-0+#include <linux/moduleparam.h> +#include <linux/fs.h> +#include <linux/debugfs.h> +#include <linux/slab.h> +#include <linux/memory.h> +#include <linux/memory_hotplug.h> +#include <linux/numa.h> +#include <linux/memblock.h> +#include <asm/machdep.h> +#include <asm/plpar_wrappers.h>
Do we need all of the above?
e.g. slab, memory_hotplug etc are not needed IMO.
Maybe only?
#include <asm/hvcall.h>
#include <asm/io.h>
#include <asm/machdep.h>
#include <asm/plpar_wrappers.h>
#include <linux/debugfs.h>
#include <linux/module.h>
(module.h depending upon if we make it module_init())
Quoted 87 lines
arch/powerpc/platforms/pseries/htmdump.c new file +87
-0+ +/* This enables us to keep track of the memory removed from each node. */ +struct htmdump_entry { +void *buf; +struct dentry *dir; +char name[16 ]; +}; + +static u32 nodeindex =0 ; +static u32 nodalchipindex =0 ; +static u32 coreindexonchip =0 ; +static u32 htmtype =0 ; + +#define BUFFER_SIZE PAGE_SIZE + +static ssize_t htmdump_read (struct file *filp,char __user *ubuf, +size_t count,loff_t *ppos) +{ +struct htmdump_entry *ent = filp->private_data; +unsigned long page, read_size, available; +loff_t offset; +long rc; + + page =ALIGN_DOWN (*ppos,BUFFER_SIZE ); + offset = (*ppos) %BUFFER_SIZE ; + + rc =htm_get_dump_hardware (nodeindex, nodalchipindex, coreindexonchip, + htmtype,virt_to_phys (ent->buf),BUFFER_SIZE , page); + +switch (rc) { +case H_SUCCESS : +case H_PARTIAL : +break ; +case H_NOT_AVAILABLE : +return 0 ; +case H_BUSY : +case H_LONG_BUSY_ORDER_1_MSEC : +case H_LONG_BUSY_ORDER_10_MSEC : +case H_LONG_BUSY_ORDER_100_MSEC : +case H_LONG_BUSY_ORDER_1_SEC : +case H_LONG_BUSY_ORDER_10_SEC : +case H_LONG_BUSY_ORDER_100_SEC : +case H_PARAMETER : +case H_P2 : +case H_P3 : +case H_P4 : +case H_P5 : +case H_P6 : +case H_STATE : +case H_AUTHORITY : +return -EINVAL ; + } + + available =BUFFER_SIZE - offset; + read_size =min (count, available); + *ppos += read_size; +return simple_read_from_buffer (ubuf, count, &offset, ent->buf, available); +} + +static const struct file_operations htmdump_fops = { + .llseek = default_llseek, + .read = htmdump_read, + .open = simple_open, +}; + +static struct dentry *htmdump_debugfs_dir; + +static int htmdump_init_debugfs (void ) +{ +struct htmdump_entry *ent; + + ent =kcalloc (1 ,sizeof (struct htmdump_entry ),GFP_KERNEL ); +if (!ent) { +pr_err ("Failed to allocate ent\n" ); +return -EINVAL ; + } + + ent->buf =kmalloc (BUFFER_SIZE ,GFP_KERNEL ); +if (!ent->buf) { +pr_err ("Failed to allocate htmdump buf\n" ); +return -ENOMEM ; + } + +pr_debug ("%s: ent:%lx buf:%lx\n" , + __func__, (long unsigned int )ent, (long unsigned int )ent->buf); + + htmdump_debugfs_dir = debugfs_create_dir("htmdump",
arch/powerpc/platforms/pseries/htmdump.c line 117
Quoted 10 lines
arch/powerpc/platforms/pseries/htmdump.c new file +10
-0+ arch_debugfs_dir); + +debugfs_create_u32 ("nodeindex" ,0600 , + htmdump_debugfs_dir, &nodeindex); +debugfs_create_u32 ("nodalchipindex" ,0600 , + htmdump_debugfs_dir, &nodalchipindex); +debugfs_create_u32 ("coreindexonchip" ,0600 , + htmdump_debugfs_dir, &coreindexonchip); +debugfs_create_u32 ("htmtype" ,0600 , + htmdump_debugfs_dir, &htmtype);
minor nit: For all of the above. S_IRUSR | S_IWUSR instead of 0600.
arch/powerpc/platforms/pseries/htmdump.c line 118
Quoted 1 line
arch/powerpc/platforms/pseries/htmdump.c new file +1
-0+debugfs_create_file ("trace" ,0400 , htmdump_debugfs_dir, ent, &htmdump_fops);
maybe S_IRUSR instead of 0400.
(makes it more readable).
arch/powerpc/platforms/pseries/htmdump.c line 123
Quoted 5 lines
arch/powerpc/platforms/pseries/htmdump.c new file +5
-0+ +return 0 ; +} + +static int htmdump_init (void )
maybe put it into __init section?
Quoted 9 lines
arch/powerpc/platforms/pseries/htmdump.c new file +7
-1+{ +if (htmdump_init_debugfs ()) +return -EINVAL ; + +return 0 ; +} +machine_device_initcall (pseries, htmdump_init); --2.45.2
Ritesh Harjani (IBM)
reviewerRe: [PATCH 3/3] powerpc: Document details on H_HTM hcall
In reply to Madhavan SrinivasanQuoted 18 lines · Madhavan Srinivasan
Add documentation to '
papr_hcalls.rst' describing the input, output and return values of theH_HTMhcall as per the internal specification.Signed-off-by Madhavan Srinivasan <[email protected]>--- Documentation/arch/powerpc/papr_hcalls.rst | 11 +++++++++++ 1 file changed, 11 insertions(+)Documentation/arch/powerpc/papr_hcalls.rst +1
-0@@ -289,6 +289,17 @@ to be issued multiple times in order to be completely serviced. The subsequent hcalls to the hypervisor until the hcall is completely serviced at which point H_SUCCESS or other error is returned by the hypervisor. +**H_HTM**
Documentation/arch/powerpc/papr_hcalls.rst to be issued multiple times in order to be completely serviced. The · line 302
Quoted 10 lines
Documentation/arch/powerpc/papr_hcalls.rst +10
-0+ +| Input: flags, target, operation (op), op-param1, op-param2, op-param3 +| Out: *dumphtmbufferdata* +| Return Value: *H_Success,H_Busy,H_LongBusyOrder,H_Partial,H_Parameter, + H_P2,H_P3,H_P4,H_P5,H_P6,H_State,H_Not_Available,H_Authority* + +H_HTM supports setup, configuration, control and dumping of Hardware Trace +Macro (HTM) function and its data. HTM buffer stores tracing data for functions +like core instruction, core LLAT and nest. +
Minor nit: Maybe the set of debugfs cmds to collect the trace and some example trace log? If it is not confidential?
Quoted 5 lines
Documentation/arch/powerpc/papr_hcalls.rst +0
-0References ========== .. [1] "Power Architecture Platform Reference"Signature · 1 line
2.45.2
kernel test robot
build botRe: [PATCH 2/3] powerpc/pseries: Export hardware trace macro dump via debugfs
In reply to Madhavan Srinivasankernel test robot noticed the following build errors:
Hi Madhavan,
kernel test robot noticed the following build errors:
[auto build test ERROR on powerpc/next]
[also build test ERROR on powerpc/fixes linus/master v6.10-rc5 next-20240625] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Madhavan-Srinivasan/powerpc-pseries-Export-hardware-trace-macro-dump-via-debugfs/20240625-144003 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next patch link: https://lore.kernel.org/r/20240620174614.53751-2-maddy%40linux.ibm.com patch subject: [PATCH 2/3] powerpc/pseries: Export hardware trace macro dump via debugfs config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20240626/[email protected]/config) compiler: powerpc64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240626/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
In file included from arch/powerpc/platforms/pseries/htmdump.c:19:
>> arch/powerpc/include/asm/machdep.h:262:85: error: expected ')' before numeric constant
262 | #define machine_device_initcall(mach, fn) __define_machine_initcall(mach, fn, 6)
| ^
arch/powerpc/include/asm/machdep.h:248:61: note: in definition of macro '__define_machine_initcall'
248 | __define_initcall(__machine_initcall_##mach##_##fn, id);
| ^~
arch/powerpc/platforms/pseries/htmdump.c:130:1: note: in expansion of macro 'machine_device_initcall'
130 | machine_device_initcall(pseries, htmdump_init);
| ^~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/machdep.h:244:27: warning: '__machine_initcall_pseries_htmdump_init' defined but not used [-Wunused-function]
244 | static int __init __machine_initcall_##mach##_##fn(void) { \
| ^~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/machdep.h:262:49: note: in expansion of macro '__define_machine_initcall'
262 | #define machine_device_initcall(mach, fn) __define_machine_initcall(mach, fn, 6)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/platforms/pseries/htmdump.c:130:1: note: in expansion of macro 'machine_device_initcall'
130 | machine_device_initcall(pseries, htmdump_init);
| ^~~~~~~~~~~~~~~~~~~~~~~vim +262 arch/powerpc/include/asm/machdep.h
^1da177e4c3f41 include/asm-ppc64/machdep.h Linus Torvalds 2005-04-16 242
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 243 #define __define_machine_initcall(mach, fn, id) \
800d68c3aa0dc3 include/asm-powerpc/machdep.h Grant Likely 2007-12-02 @244 static int __init __machine_initcall_##mach##_##fn(void) { \
800d68c3aa0dc3 include/asm-powerpc/machdep.h Grant Likely 2007-12-02 245 if (machine_is(mach)) return fn(); \
800d68c3aa0dc3 include/asm-powerpc/machdep.h Grant Likely 2007-12-02 246 return 0; \
800d68c3aa0dc3 include/asm-powerpc/machdep.h Grant Likely 2007-12-02 247 } \
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 248 __define_initcall(__machine_initcall_##mach##_##fn, id);
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 249
8d3c941e240ba2 arch/powerpc/include/asm/machdep.h Michael Ellerman 2014-07-15 250 #define machine_early_initcall(mach, fn) __define_machine_initcall(mach, fn, early)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 251 #define machine_core_initcall(mach, fn) __define_machine_initcall(mach, fn, 1)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 252 #define machine_core_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 1s)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 253 #define machine_postcore_initcall(mach, fn) __define_machine_initcall(mach, fn, 2)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 254 #define machine_postcore_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 2s)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 255 #define machine_arch_initcall(mach, fn) __define_machine_initcall(mach, fn, 3)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 256 #define machine_arch_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 3s)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 257 #define machine_subsys_initcall(mach, fn) __define_machine_initcall(mach, fn, 4)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 258 #define machine_subsys_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 4s)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 259 #define machine_fs_initcall(mach, fn) __define_machine_initcall(mach, fn, 5)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 260 #define machine_fs_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 5s)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 261 #define machine_rootfs_initcall(mach, fn) __define_machine_initcall(mach, fn, rootfs)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 @262 #define machine_device_initcall(mach, fn) __define_machine_initcall(mach, fn, 6)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 263 #define machine_device_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 6s)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 264 #define machine_late_initcall(mach, fn) __define_machine_initcall(mach, fn, 7)
7929d407e47fbf arch/powerpc/include/asm/machdep.h Matthew Leach 2012-12-17 265 #define machine_late_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 7s)800d68c3aa0dc3 include/asm-powerpc/machdep.h Grant Likely 2007-12-02 266
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Madhavan Srinivasan
maintainerRe: [PATCH 2/3] powerpc/pseries: Export hardware trace macro dump via debugfs
In reply to Ritesh Harjani (IBM)Quoted 2 lines · Ritesh Harjani (IBM)
This is a generic review and I haven't looked into the PAPR spec for htmdump hcall and it's interface.
Sure
Quoted 34 lines
Quoted 32 lines · Madhavan Srinivasan
This patch adds debugfs interface to export Hardware Trace Macro (HTM) function data in a LPAR. New hypervisor call "
H_HTM" has been defined to setup, configure, control and dump the HTM data. This patch supports only dumping of HTM data in a LPAR.
New debugfs folder called "htmdump" has been added under/sys/kernel/debug/archpath which contains files need to
pass required parameters for theH_HTMdump function. NewKconfigoption called "CONFIG_HTMDUMP" has been in platform/pseries for the same.With patch series applied and booted, list of files in debugfs path
# pwd /sys/kernel/debug/powerpc/htmdump # ls coreindexonchip htmtype nodalchipindex nodeindex traceSigned-off-by Madhavan Srinivasan <[email protected]>--- arch/powerpc/platforms/pseries/Kconfig | 8 ++ arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/htmdump.c | 130 +++++++++++++++++++++++ 3 files changed, 139 insertions(+)create mode 100644
arch/powerpc/platforms/pseries/htmdump.carch/powerpc/platforms/pseries/Kconfig +0
-0@@ -128,6 +128,14 @@ config CMM will be reused for other LPARs. The interface allows firmware to balance memory across many LPARs.
Quoted 7 lines
arch/powerpc/platforms/pseries/Kconfig config CMM · line 132
Quoted 2 lines
arch/powerpc/platforms/pseries/Kconfig +2
-0+config HTMDUMP + tristate "PHYP HTM data dumper"Not sure if we can make
machine_device_initcall()as a tristate? Did we try compiling it as a module?It we would like to keep this as a module - then why not use
module_initcall and then make it depend upon...
I will make it as bool and add depends as suggested.
Quoted 6 lines
depends on
PPC_PSERIES&&DEBUG_FS(??)arch/powerpc/platforms/pseries/Kconfig config CMM · line 133
Quoted 1 line
arch/powerpc/platforms/pseries/Kconfig +1
-0+ default yand then since this is mostly a debug trace facility, then we need not enable it by default right?
Yes, we want this to be there, it is up to hypervisor whether to permit the hcalls.
Quoted 57 lines
Quoted 37 lines
arch/powerpc/platforms/pseries/Kconfig +5
-0+ help + Select this option, if you want to enable the kernel debugfs + interface to dump the Hardware Trace Macro (HTM) function data + in the LPAR. + config HV_PERF_CTRS bool "Hypervisor supplied PMU events (24x7 & GPCI)" default yarch/powerpc/platforms/pseries/Makefile +1
-0@@ -19,6 +19,7 @@ obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o obj-$(CONFIG_HVCS) += hvcserver.o obj-$(CONFIG_HCALL_STATS) += hvCall_inst.o obj-$(CONFIG_CMM) += cmm.o +obj-$(CONFIG_HTMDUMP) += htmdump.o obj-$(CONFIG_IO_EVENT_IRQ) += io_event_irq.o obj-$(CONFIG_LPARCFG) += lparcfg.o obj-$(CONFIG_IBMVIO) += vio.oarch/powerpc/platforms/pseries/htmdump.c new file +10
-0@@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) IBM Corporation, 2024 +*/ + +#define pr_fmt (fmt) "htmdump: " fmt + +#include <linux/bitops.h> +#include <linux/string.h> +#include <linux/init.h> arch/powerpc/platforms/pseries/htmdump.c line 20
Quoted 10 lines
arch/powerpc/platforms/pseries/htmdump.c new file +10
-0+#include <linux/moduleparam.h> +#include <linux/fs.h> +#include <linux/debugfs.h> +#include <linux/slab.h> +#include <linux/memory.h> +#include <linux/memory_hotplug.h> +#include <linux/numa.h> +#include <linux/memblock.h> +#include <asm/machdep.h> +#include <asm/plpar_wrappers.h> Do we need all of the above?
e.g. slab,memory_hotplugetc are not needed IMO.Maybe only?
#include <
asm/hvcall.h>
#include <asm/io.h>
#include <asm/machdep.h>
#include <asm/plpar_wrappers.h>
Quoted 5 lines
#include <
linux/debugfs.h>
#include <linux/module.h>(
module.hdepending upon if we make itmodule_init())
Yeah, my bad, Should have handled this. will fix it in v2
Quoted 99 lines
Quoted 87 lines
arch/powerpc/platforms/pseries/htmdump.c new file +87
-0+ +/* This enables us to keep track of the memory removed from each node. */ +struct htmdump_entry { +void *buf; +struct dentry *dir; +char name[16 ]; +}; + +static u32 nodeindex =0 ; +static u32 nodalchipindex =0 ; +static u32 coreindexonchip =0 ; +static u32 htmtype =0 ; + +#define BUFFER_SIZE PAGE_SIZE + +static ssize_t htmdump_read (struct file *filp,char __user *ubuf, +size_t count,loff_t *ppos) +{ +struct htmdump_entry *ent = filp->private_data; +unsigned long page, read_size, available; +loff_t offset; +long rc; + + page =ALIGN_DOWN (*ppos,BUFFER_SIZE ); + offset = (*ppos) %BUFFER_SIZE ; + + rc =htm_get_dump_hardware (nodeindex, nodalchipindex, coreindexonchip, + htmtype,virt_to_phys (ent->buf),BUFFER_SIZE , page); + +switch (rc) { +case H_SUCCESS : +case H_PARTIAL : +break ; +case H_NOT_AVAILABLE : +return 0 ; +case H_BUSY : +case H_LONG_BUSY_ORDER_1_MSEC : +case H_LONG_BUSY_ORDER_10_MSEC : +case H_LONG_BUSY_ORDER_100_MSEC : +case H_LONG_BUSY_ORDER_1_SEC : +case H_LONG_BUSY_ORDER_10_SEC : +case H_LONG_BUSY_ORDER_100_SEC : +case H_PARAMETER : +case H_P2 : +case H_P3 : +case H_P4 : +case H_P5 : +case H_P6 : +case H_STATE : +case H_AUTHORITY : +return -EINVAL ; + } + + available =BUFFER_SIZE - offset; + read_size =min (count, available); + *ppos += read_size; +return simple_read_from_buffer (ubuf, count, &offset, ent->buf, available); +} + +static const struct file_operations htmdump_fops = { + .llseek = default_llseek, + .read = htmdump_read, + .open = simple_open, +}; + +static struct dentry *htmdump_debugfs_dir; + +static int htmdump_init_debugfs (void ) +{ +struct htmdump_entry *ent; + + ent =kcalloc (1 ,sizeof (struct htmdump_entry ),GFP_KERNEL ); +if (!ent) { +pr_err ("Failed to allocate ent\n" ); +return -EINVAL ; + } + + ent->buf =kmalloc (BUFFER_SIZE ,GFP_KERNEL ); +if (!ent->buf) { +pr_err ("Failed to allocate htmdump buf\n" ); +return -ENOMEM ; + } + +pr_debug ("%s: ent:%lx buf:%lx\n" , + __func__, (long unsigned int )ent, (long unsigned int )ent->buf); + + htmdump_debugfs_dir = debugfs_create_dir("htmdump",arch/powerpc/platforms/pseries/htmdump.c line 117
Quoted 10 lines
arch/powerpc/platforms/pseries/htmdump.c new file +10
-0+ arch_debugfs_dir); + +debugfs_create_u32 ("nodeindex" ,0600 , + htmdump_debugfs_dir, &nodeindex); +debugfs_create_u32 ("nodalchipindex" ,0600 , + htmdump_debugfs_dir, &nodalchipindex); +debugfs_create_u32 ("coreindexonchip" ,0600 , + htmdump_debugfs_dir, &coreindexonchip); +debugfs_create_u32 ("htmtype" ,0600 , + htmdump_debugfs_dir, &htmtype);minor nit: For all of the above.
S_IRUSR|S_IWUSRinstead of 0600.
Quoted 4 lines
arch/powerpc/platforms/pseries/htmdump.c line 118
Quoted 1 line
arch/powerpc/platforms/pseries/htmdump.c new file +1
-0+debugfs_create_file ("trace" ,0400 , htmdump_debugfs_dir, ent, &htmdump_fops);maybe
S_IRUSRinstead of 0400.(makes it more readable).
ok will check and changes.
Thanks for the review comments.
Maddy
Quoted 17 lines
arch/powerpc/platforms/pseries/htmdump.c line 123
Quoted 6 lines
arch/powerpc/platforms/pseries/htmdump.c new file +5
-0+ +return 0 ; +} + +static int htmdump_init (void )maybe put it into
__initsection?Quoted 9 lines
arch/powerpc/platforms/pseries/htmdump.c new file +7
-1+{ +if (htmdump_init_debugfs ()) +return -EINVAL ; + +return 0 ; +} +machine_device_initcall (pseries, htmdump_init); --2.45.2
Madhavan Srinivasan
maintainerRe: [PATCH 3/3] powerpc: Document details on H_HTM hcall
In reply to Ritesh Harjani (IBM)Quoted 19 lines · Ritesh Harjani (IBM)
Quoted 17 lines · Madhavan Srinivasan
Add documentation to '
papr_hcalls.rst' describing the input, output and return values of theH_HTMhcall as per the internal specification.Signed-off-by Madhavan Srinivasan <[email protected]>--- Documentation/arch/powerpc/papr_hcalls.rst | 11 +++++++++++ 1 file changed, 11 insertions(+)Documentation/arch/powerpc/papr_hcalls.rst +0
-0@@ -289,6 +289,17 @@ to be issued multiple times in order to be completely serviced. The subsequent hcalls to the hypervisor until the hcall is completely serviced at which point H_SUCCESS or other error is returned by the hypervisor.
Quoted 13 lines
Documentation/arch/powerpc/papr_hcalls.rst to be issued multiple times in order to be completely serviced. The · line 302
Quoted 11 lines
Documentation/arch/powerpc/papr_hcalls.rst +11
-0+**H_HTM** + +| Input: flags, target, operation (op), op-param1, op-param2, op-param3 +| Out: *dumphtmbufferdata* +| Return Value: *H_Success,H_Busy,H_LongBusyOrder,H_Partial,H_Parameter, + H_P2,H_P3,H_P4,H_P5,H_P6,H_State,H_Not_Available,H_Authority* + +H_HTM supports setup, configuration, control and dumping of Hardware Trace +Macro (HTM) function and its data. HTM buffer stores tracing data for functions +like core instruction, core LLAT and nest. +Minor nit: Maybe the set of debugfs cmds to collect the trace and some example trace log? If it is not confidential?
I could add the file structure in the commit message, but logs are just binary data.
Maddy
Quoted 6 lines
Quoted 6 lines
Documentation/arch/powerpc/papr_hcalls.rst +0
-0References ========== .. [1] "Power Architecture Platform Reference"Signature · 1 line
2.45.2
Michael Ellerman
reviewerRe: [PATCH 2/3] powerpc/pseries: Export hardware trace macro dump via debugfs
In reply to Ritesh Harjani (IBM)Quoted 4 lines · Ritesh Harjani (IBM)
This is a generic review and I haven't looked into the PAPR spec for htmdump hcall and it's interface.
Madhavan Srinivasan <[email protected]> writes:
...
Quoted 12 lines
arch/powerpc/platforms/pseries/htmdump.c line 117
Quoted 9 lines
arch/powerpc/platforms/pseries/htmdump.c new file +9
-0+ +debugfs_create_u32 ("nodeindex" ,0600 , + htmdump_debugfs_dir, &nodeindex); +debugfs_create_u32 ("nodalchipindex" ,0600 , + htmdump_debugfs_dir, &nodalchipindex); +debugfs_create_u32 ("coreindexonchip" ,0600 , + htmdump_debugfs_dir, &coreindexonchip); +debugfs_create_u32 ("htmtype" ,0600 , + htmdump_debugfs_dir, &htmtype);minor nit: For all of the above.
S_IRUSR|S_IWUSRinstead of 0600.
Quoted 3 lines
arch/powerpc/platforms/pseries/htmdump.c line 118
Quoted 1 line
arch/powerpc/platforms/pseries/htmdump.c new file +1
-0+debugfs_create_file ("trace" ,0400 , htmdump_debugfs_dir, ent, &htmdump_fops);maybe
S_IRUSRinstead of 0400.
Actually we prefer the octal values, see:
https://git.kernel.org/torvalds/c/57ad583f2086d55ada284c54bfc440123cf73964
cheers