Re: Where is the declaration of buffer used in kernel_param_ops .get functions?
On Sun, 2020-10-04 at 02:36 +0100, Matthew Wilcox wrote: > On Sat, Oct 03, 2020 at 06:19:18PM -0700, Joe Perches wrote: > > These patches came up because I was looking for > > the location of the declaration of the buffer used > > in kernel/params.c struct kernel_param_ops .get > > functions. > > > > I didn't find it. > > > > I want to see if it's appropriate to convert the > > sprintf family of functions used in these .get > > functions to sysfs_emit. > > > > Patches submitted here: > > https://lore.kernel.org/lkml/5d606519698ce4c8f1203a2b35797d8254c6050a.1600285923.git@perches.com/T/ > > > > Anyone know if it's appropriate to change the > > sprintf-like uses in these functions to sysfs_emit > > and/or sysfs_emit_at? > > There's a lot of preprocessor magic to wade through. > > I'm pretty sure this comes through include/linux/moduleparam.h > and kernel/module.c. Dunno, looked there, still can't find it. btw: The __module_param_call macro looks very dodgy as it uses both __used and __attribute__((unused)) and likely one of them should be removed (unused?) It looks like the comes from varying definitions of __attribute_used__ eventually converted to __used for old gcc versions 2, 3, and 4. 1da177e4c3f4:include/linux/compiler-gcc2.h:#define __attribute_used__ __attribute__((__unused__)) 1da177e4c3f4:include/linux/compiler-gcc3.h:# define __attribute_used__ __attribute__((__used__)) 1da177e4c3f4:include/linux/compiler-gcc3.h:# define __attribute_used__ __attribute__((__unused__)) 1da177e4c3f4:include/linux/compiler-gcc4.h:#define __attribute_used__ __attribute__((__used__)) Maybe: --- include/linux/moduleparam.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 47879fc7f75e..fc820b27fb00 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -288,10 +288,10 @@ struct kparam_array /* Default value instead of permissions? */ \ static const char __param_str_##name[] = prefix #name; \ static struct kernel_param __moduleparam_const __param_##name \ - __used \ -__attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void * \ - = { __param_str_##name, THIS_MODULE, ops, \ - VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } } + __used __section("__param") __aligned(sizeof(void *)) = { \ + __param_str_##name, THIS_MODULE, ops, \ + VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } \ + } /* Obsolete - use module_param_cb() */ #define module_param_call(name, _set, _get, arg, perm) \
Re: Where is the declaration of buffer used in kernel_param_ops .get functions?
On Sat, Oct 03, 2020 at 06:19:18PM -0700, Joe Perches wrote: > These patches came up because I was looking for > the location of the declaration of the buffer used > in kernel/params.c struct kernel_param_ops .get > functions. > > I didn't find it. > > I want to see if it's appropriate to convert the > sprintf family of functions used in these .get > functions to sysfs_emit. > > Patches submitted here: > https://lore.kernel.org/lkml/5d606519698ce4c8f1203a2b35797d8254c6050a.1600285923.git@perches.com/T/ > > Anyone know if it's appropriate to change the > sprintf-like uses in these functions to sysfs_emit > and/or sysfs_emit_at? There's a lot of preprocessor magic to wade through. I'm pretty sure this comes through include/linux/moduleparam.h and kernel/module.c.
Where is the declaration of buffer used in kernel_param_ops .get functions?
These patches came up because I was looking for the location of the declaration of the buffer used in kernel/params.c struct kernel_param_ops .get functions. I didn't find it. I want to see if it's appropriate to convert the sprintf family of functions used in these .get functions to sysfs_emit. Patches submitted here: https://lore.kernel.org/lkml/5d606519698ce4c8f1203a2b35797d8254c6050a.1600285923.git@perches.com/T/ Anyone know if it's appropriate to change the sprintf-like uses in these functions to sysfs_emit and/or sysfs_emit_at?
[PATCH 1/4] KVM: PPC: Book3S HV: Make struct kernel_param_ops definition const
This should be const, so make it so. Signed-off-by: Joe Perches --- arch/powerpc/kvm/book3s_hv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 4ba06a2a306c..2b215852cdc9 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -111,7 +111,7 @@ module_param(one_vm_per_core, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(one_vm_per_core, "Only run vCPUs from the same VM on a core (requires indep_threads_mode=N)"); #ifdef CONFIG_KVM_XICS -static struct kernel_param_ops module_param_ops = { +static const struct kernel_param_ops module_param_ops = { .set = param_set_int, .get = param_get_int, }; -- 2.26.0
[PATCH 0/4] treewide: Make definitions of struct kernel_param_ops const
Using const is good as it reduces data size. Joe Perches (4): KVM: PPC: Book3S HV: Make struct kernel_param_ops definition const kvm x86/mmu: Make struct kernel_param_ops definitions const rcu/tree: Make struct kernel_param_ops definitions const mm/zswap: Make struct kernel_param_ops definitions const arch/powerpc/kvm/book3s_hv.c | 2 +- arch/x86/kvm/mmu/mmu.c | 4 ++-- kernel/rcu/tree.c| 4 ++-- mm/zswap.c | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) -- 2.26.0
Re: [PATCH v4 net-next 0/2] Add Seville Ethernet switch to T1040RDB
From: Vladimir Oltean Date: Fri, 2 Oct 2020 16:41:04 +0300 > Seville is a DSA switch that is embedded inside the T1040 SoC, and > supported by the mscc_seville DSA driver inside drivers/net/dsa/ocelot. > > This series adds this switch to the SoC's dtsi files and to the T1040RDB > board file. > > I would like to send this series through net-next. There is no conflict > with other patches submitted to T1040 device tree. Maybe this could at > least get an ACK from devicetree maintainers. Series applied, thank you.
Re: [PATCH] crypto: talitos - Fix sparse warnings
Quoting Herbert Xu : On Fri, Oct 02, 2020 at 10:42:23PM +1000, Herbert Xu wrote: I don't think that's a valid optimisation unless it's backed up with real numbers. Also it only matters on little-endian as they're no-ops on big-endian. If I'm right then this driver never even worked on little-endian. The following changes fix the sparse warnings with less churn: --- diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 7c547352a862..992d58a4dbf1 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -460,7 +460,7 @@ DEF_TALITOS2_DONE(ch1_3, TALITOS2_ISR_CH_1_3_DONE) /* * locate current (offending) descriptor */ -static u32 current_desc_hdr(struct device *dev, int ch) +static __be32 current_desc_hdr(struct device *dev, int ch) { struct talitos_private *priv = dev_get_drvdata(dev); int tail, iter; @@ -478,7 +478,7 @@ static u32 current_desc_hdr(struct device *dev, int ch) iter = tail; while (priv->chan[ch].fifo[iter].dma_desc != cur_desc && - priv->chan[ch].fifo[iter].desc->next_desc != cur_desc) { + priv->chan[ch].fifo[iter].desc->next_desc != cpu_to_be32(cur_desc)) { iter = (iter + 1) & (priv->fifo_len - 1); if (iter == tail) { dev_err(dev, "couldn't locate current descriptor\n"); @@ -486,7 +486,7 @@ static u32 current_desc_hdr(struct device *dev, int ch) } } - if (priv->chan[ch].fifo[iter].desc->next_desc == cur_desc) { + if (priv->chan[ch].fifo[iter].desc->next_desc == cpu_to_be32(cur_desc)) { struct talitos_edesc *edesc; edesc = container_of(priv->chan[ch].fifo[iter].desc, @@ -501,13 +501,13 @@ static u32 current_desc_hdr(struct device *dev, int ch) /* * user diagnostics; report root cause of error based on execution unit status */ -static void report_eu_error(struct device *dev, int ch, u32 desc_hdr) +static void report_eu_error(struct device *dev, int ch, __be32 desc_hdr) { struct talitos_private *priv = dev_get_drvdata(dev); int i; if (!desc_hdr) - desc_hdr = in_be32(priv->chan[ch].reg + TALITOS_DESCBUF); + desc_hdr = cpu_to_be32(in_be32(priv->chan[ch].reg + TALITOS_DESCBUF)); switch (desc_hdr & DESC_HDR_SEL0_MASK) { case DESC_HDR_SEL0_AFEU: --- Christophe
[PATCH 5/5] powerpc/hv-gpci: Add sysfs files inside hv-gpci device to show cpumask
Patch here adds a cpumask attr to hv_gpci pmu along with ABI documentation. Primary use to expose the cpumask is for the perf tool which has the capability to parse the driver sysfs folder and understand the cpumask file. Having cpumask file will reduce the number of perf command line parameters (will avoid "-C" option in the perf tool command line). It can also notify the user which is the current cpu used to retrieve the counter data. command:# cat /sys/devices/hv_gpci/cpumask 0 Signed-off-by: Kajol Jain --- .../sysfs-bus-event_source-devices-hv_gpci | 7 +++ arch/powerpc/perf/hv-gpci.c| 18 ++ 2 files changed, 25 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_gpci b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_gpci index b68a28a712d5..7162c5d675fe 100644 --- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_gpci +++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_gpci @@ -72,3 +72,10 @@ Contact: Linux on PowerPC Developer List Description: A number indicating the latest version of the gpci interface that the kernel is aware of. + +What: /sys/devices/hv_gpci/cpumask +Date: October 2020 +Contact: Linux on PowerPC Developer List +Description: read only + This sysfs file exposes the cpumask which is designated to make + HCALLs to retrieve hv-gpci pmu event counter data. diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c index b9dc407c3159..159dca8d5d65 100644 --- a/arch/powerpc/perf/hv-gpci.c +++ b/arch/powerpc/perf/hv-gpci.c @@ -96,7 +96,15 @@ static ssize_t kernel_version_show(struct device *dev, return sprintf(page, "0x%x\n", COUNTER_INFO_VERSION_CURRENT); } +static ssize_t cpumask_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return cpumap_print_to_pagebuf(true, buf, _gpci_cpumask); +} + static DEVICE_ATTR_RO(kernel_version); +static DEVICE_ATTR_RO(cpumask); + HV_CAPS_ATTR(version, "0x%x\n"); HV_CAPS_ATTR(ga, "%d\n"); HV_CAPS_ATTR(expanded, "%d\n"); @@ -113,6 +121,15 @@ static struct attribute *interface_attrs[] = { NULL, }; +static struct attribute *cpumask_attrs[] = { + _attr_cpumask.attr, + NULL, +}; + +static struct attribute_group cpumask_attr_group = { + .attrs = cpumask_attrs, +}; + static struct attribute_group interface_group = { .name = "interface", .attrs = interface_attrs, @@ -122,6 +139,7 @@ static const struct attribute_group *attr_groups[] = { _group, _group, _group, + _attr_group, NULL, }; -- 2.26.2
[PATCH 4/5] powerpc/perf/hv-gpci: Add cpu hotplug support
Patch here adds cpu hotplug functions to hv_gpci pmu. A new cpuhp_state "CPUHP_AP_PERF_POWERPC_HV_GPCI_ONLINE" enum is added. The online callback function updates the cpumask only if its empty. As the primary intention of adding hotplug support is to designate a CPU to make HCALL to collect the counter data. The offline function test and clear corresponding cpu in a cpumask and update cpumask to any other active cpu. Signed-off-by: Kajol Jain --- arch/powerpc/perf/hv-gpci.c | 46 + include/linux/cpuhotplug.h | 1 + 2 files changed, 47 insertions(+) diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c index 6884d16ec19b..b9dc407c3159 100644 --- a/arch/powerpc/perf/hv-gpci.c +++ b/arch/powerpc/perf/hv-gpci.c @@ -48,6 +48,8 @@ EVENT_DEFINE_RANGE_FORMAT(length, config1, 24, 31); /* u32, byte offset */ EVENT_DEFINE_RANGE_FORMAT(offset, config1, 32, 63); +static cpumask_t hv_gpci_cpumask; + static struct attribute *format_attrs[] = { _attr_request.attr, _attr_starting_index.attr, @@ -275,6 +277,45 @@ static struct pmu h_gpci_pmu = { .capabilities = PERF_PMU_CAP_NO_EXCLUDE, }; +static int ppc_hv_gpci_cpu_online(unsigned int cpu) +{ + if (cpumask_empty(_gpci_cpumask)) + cpumask_set_cpu(cpu, _gpci_cpumask); + + return 0; +} + +static int ppc_hv_gpci_cpu_offline(unsigned int cpu) +{ + int target; + + /* Check if exiting cpu is used for collecting gpci events */ + if (!cpumask_test_and_clear_cpu(cpu, _gpci_cpumask)) + return 0; + + /* Find a new cpu to collect gpci events */ + target = cpumask_last(cpu_active_mask); + + if (target < 0 || target >= nr_cpu_ids) { + pr_err("hv_gpci: CPU hotplug init failed\n"); + return -1; + } + + /* Migrate gpci events to the new target */ + cpumask_set_cpu(target, _gpci_cpumask); + perf_pmu_migrate_context(_gpci_pmu, cpu, target); + + return 0; +} + +static int hv_gpci_cpu_hotplug_init(void) +{ + return cpuhp_setup_state(CPUHP_AP_PERF_POWERPC_HV_GPCI_ONLINE, + "perf/powerpc/hv_gcpi:online", + ppc_hv_gpci_cpu_online, + ppc_hv_gpci_cpu_offline); +} + static int hv_gpci_init(void) { int r; @@ -295,6 +336,11 @@ static int hv_gpci_init(void) return -ENODEV; } + /* init cpuhotplug */ + r = hv_gpci_cpu_hotplug_init(); + if (r) + return r; + /* sampling not supported */ h_gpci_pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index bf9181cef444..b79d3d4b06e8 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -182,6 +182,7 @@ enum cpuhp_state { CPUHP_AP_PERF_POWERPC_THREAD_IMC_ONLINE, CPUHP_AP_PERF_POWERPC_TRACE_IMC_ONLINE, CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE, + CPUHP_AP_PERF_POWERPC_HV_GPCI_ONLINE, CPUHP_AP_WATCHDOG_ONLINE, CPUHP_AP_WORKQUEUE_ONLINE, CPUHP_AP_RCUTREE_ONLINE, -- 2.26.2
[PATCH 3/5] Documentation/ABI: Add ABI documentation for hv-gpci format
This patch adds ABI documentation for hv-gpci event format. Signed-off-by: Kajol Jain --- .../sysfs-bus-event_source-devices-hv_gpci| 31 +++ 1 file changed, 31 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_gpci b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_gpci index 3ca4e554d2f9..b68a28a712d5 100644 --- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_gpci +++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_gpci @@ -1,3 +1,34 @@ +What: /sys/bus/event_source/devices/hv_gpci/format +Date: September 2020 +Contact:Linux on PowerPC Developer List +Description:Read-only. Attribute group to describe the magic bits +that go into perf_event_attr.config for a particular pmu. +(See ABI/testing/sysfs-bus-event_source-devices-format). + +Each attribute under this group defines a bit range of the +perf_event_attr.config. All supported attributes are listed +below. + + counter_info_version = "config:16-23" + length = "config:24-31" + partition_id = "config:32-63" + request = "config:0-31" + sibling_part_id = "config:32-63" + hw_chip_id = "config:32-63" + offset = "config:32-63" + phys_processor_idx = "config:32-63" + secondary_index = "config:0-15" + starting_index = "config:32-63" + + For example, + + processor_core_utilization_instructions_completed = "request=0x94, + phys_processor_idx=?,counter_info_version=0x8, + length=8,offset=0x18" + + In this event, '?' after phys_processor_idx specifies this value + this value will be provided by user while running this event. + What: /sys/bus/event_source/devices/hv_gpci/interface/collect_privileged Date: February 2014 Contact: Linux on PowerPC Developer List -- 2.26.2
[PATCH 2/5] Documentation/ABI: Add ABI documentation for hv-24x7 format
This patch adds ABI documentation for hv-24x7 format. Signed-off-by: Kajol Jain --- .../sysfs-bus-event_source-devices-hv_24x7| 25 +++ 1 file changed, 25 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 index e82fc37be802..6bec9a13a493 100644 --- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 +++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 @@ -1,3 +1,28 @@ +What: /sys/bus/event_source/devices/hv_24x7/format +Date: September 2020 +Contact:Linux on PowerPC Developer List +Description:Read-only. Attribute group to describe the magic bits +that go into perf_event_attr.config for a particular pmu. +(See ABI/testing/sysfs-bus-event_source-devices-format). + +Each attribute under this group defines a bit range of the +perf_event_attr.config. All supported attributes are listed +below. + + chip = "config:16-31" + core = "config:16-31" + domain = "config:0-3" + lpar = "config:0-15" + offset = "config:32-63" + vcpu = "config:16-31" + + For example, + + PM_PB_CYC = "domain=1,offset=0x80,chip=?,lpar=0x0" + + In this event, '?' after chip specifies that + this value will be provided by user while running this event. + What: /sys/bus/event_source/devices/hv_24x7/interface/catalog Date: February 2014 Contact: Linux on PowerPC Developer List -- 2.26.2
[PATCH 1/5] powerpc/hv-gpci: Fix starting index value
Commit 9e9f60108423f ("powerpc/perf/{hv-gpci, hv-common}: generate requests with counters annotated") adds a framework for defining gpci counters. In this patch, they adds starting_index value as '0x'. which is wrong as starting_index is of size 32 bits. Because of this, incase we try to run hv-gpci event we get error. In power9 machine: command#: perf stat -e hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/ -C 0 -I 1000 event syntax error: '..bie_count_and_time_tlbie_instructions_issued/' \___ value too big for format, maximum is 4294967295 This patch fix this issue and changes starting_index value to '0x' After this patch: command#: perf stat -e hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/ -C 0 -I 1000 1.85786 1,024 hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/ 2.000287818 1,024 hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/ ^C 2.439113909 17,408 hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/ Fixes: 9e9f60108423f ("powerpc/perf/{hv-gpci, hv-common}: generate requests with counters annotated") Signed-off-by: Kajol Jain --- arch/powerpc/perf/hv-gpci-requests.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/perf/hv-gpci-requests.h b/arch/powerpc/perf/hv-gpci-requests.h index e608f9db12dd..8965b4463d43 100644 --- a/arch/powerpc/perf/hv-gpci-requests.h +++ b/arch/powerpc/perf/hv-gpci-requests.h @@ -95,7 +95,7 @@ REQUEST(__field(0,8, partition_id) #define REQUEST_NAME system_performance_capabilities #define REQUEST_NUM 0x40 -#define REQUEST_IDX_KIND "starting_index=0x" +#define REQUEST_IDX_KIND "starting_index=0x" #include I(REQUEST_BEGIN) REQUEST(__field(0, 1, perf_collect_privileged) __field(0x1,1, capability_mask) @@ -223,7 +223,7 @@ REQUEST(__field(0, 2, partition_id) #define REQUEST_NAME system_hypervisor_times #define REQUEST_NUM 0xF0 -#define REQUEST_IDX_KIND "starting_index=0x" +#define REQUEST_IDX_KIND "starting_index=0x" #include I(REQUEST_BEGIN) REQUEST(__count(0, 8, time_spent_to_dispatch_virtual_processors) __count(0x8,8, time_spent_processing_virtual_processor_timers) @@ -234,7 +234,7 @@ REQUEST(__count(0, 8, time_spent_to_dispatch_virtual_processors) #define REQUEST_NAME system_tlbie_count_and_time #define REQUEST_NUM 0xF4 -#define REQUEST_IDX_KIND "starting_index=0x" +#define REQUEST_IDX_KIND "starting_index=0x" #include I(REQUEST_BEGIN) REQUEST(__count(0, 8, tlbie_instructions_issued) /* -- 2.26.2