linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] perf/cxlpmu: Fix allocation argument order and minor formatting
@ 2025-06-24 19:43 Alok Tiwari
  2025-06-24 19:43 ` [PATCH v2 1/3] perf/cxlpmu: Fix devm_kcalloc() argument order in cxl_pmu_probe() Alok Tiwari
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Alok Tiwari @ 2025-06-24 19:43 UTC (permalink / raw)
  To: jonathan.cameron, will, mark.rutland, linux-cxl
  Cc: alok.a.tiwari, linux-perf-users, linux-kernel

This patch series includes a few minor cleanups and correctness
improvements in drivers/perf/cxl_pmu.c

Correct the argument order in devm_kcalloc() to follow the
conventional count, size form to avoid any confusion or bugs.

Remove an unintended newline in the IRQ name string passed to
devm_kasprintf() and  fix a formatting issue in the devm_kasprintf()

Fix several typos in comments and documentation strings, improving code
readability and alignment with the CXL specification.

v1 -> v2
created individual patches into a series as suggested Jonathan.

Alok Tiwari (3):
  perf/cxlpmu: Fix devm_kcalloc() argument order in cxl_pmu_probe()
  perf/cxlpmu: Remove unintended newline from IRQ name format string
  perf/cxlpmu: Fix typos in cxl_pmu.c comments and documentation

 drivers/perf/cxl_pmu.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

-- 
2.46.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/3] perf/cxlpmu: Fix devm_kcalloc() argument order in cxl_pmu_probe()
  2025-06-24 19:43 [PATCH v2 0/3] perf/cxlpmu: Fix allocation argument order and minor formatting Alok Tiwari
@ 2025-06-24 19:43 ` Alok Tiwari
  2025-06-25  8:59   ` Jonathan Cameron
  2025-06-24 19:43 ` [PATCH v2 2/3] perf/cxlpmu: Remove unintended newline from IRQ name format string Alok Tiwari
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Alok Tiwari @ 2025-06-24 19:43 UTC (permalink / raw)
  To: jonathan.cameron, will, mark.rutland, linux-cxl
  Cc: alok.a.tiwari, linux-perf-users, linux-kernel

The previous code mistakenly swapped the count and size parameters.
This fix corrects the argument order in devm_kcalloc() to follow the
conventional count, size form, avoiding potential confusion or bugs.

Previous usage:
  devm_kcalloc(dev, sizeof(*info->hw_events), info->num_counters,
   GFP_KERNEL);

New usage:
  devm_kcalloc(dev, info->num_counters, sizeof(*info->hw_events),
   GFP_KERNEL);

Previous incorrect order could lead to unexpected memory allocation
behavior. This fix ensures correct allocation of hw_event structure.

Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
 drivers/perf/cxl_pmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/perf/cxl_pmu.c b/drivers/perf/cxl_pmu.c
index d6693519eaee2..8998c0a2f3a2d 100644
--- a/drivers/perf/cxl_pmu.c
+++ b/drivers/perf/cxl_pmu.c
@@ -834,8 +834,8 @@ static int cxl_pmu_probe(struct device *dev)
 	if (rc)
 		return rc;
 
-	info->hw_events = devm_kcalloc(dev, sizeof(*info->hw_events),
-				       info->num_counters, GFP_KERNEL);
+	info->hw_events = devm_kcalloc(dev, info->num_counters,
+				       sizeof(*info->hw_events), GFP_KERNEL);
 	if (!info->hw_events)
 		return -ENOMEM;
 
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/3] perf/cxlpmu: Remove unintended newline from IRQ name format string
  2025-06-24 19:43 [PATCH v2 0/3] perf/cxlpmu: Fix allocation argument order and minor formatting Alok Tiwari
  2025-06-24 19:43 ` [PATCH v2 1/3] perf/cxlpmu: Fix devm_kcalloc() argument order in cxl_pmu_probe() Alok Tiwari
@ 2025-06-24 19:43 ` Alok Tiwari
  2025-06-25  9:04   ` Jonathan Cameron
  2025-06-24 19:43 ` [PATCH v2 3/3] perf/cxlpmu: Fix typos in cxl_pmu.c comments and documentation Alok Tiwari
  2025-07-14 15:10 ` [PATCH v2 0/3] perf/cxlpmu: Fix allocation argument order and minor formatting Will Deacon
  3 siblings, 1 reply; 8+ messages in thread
From: Alok Tiwari @ 2025-06-24 19:43 UTC (permalink / raw)
  To: jonathan.cameron, will, mark.rutland, linux-cxl
  Cc: alok.a.tiwari, linux-perf-users, linux-kernel

The IRQ name format string used in devm_kasprintf() mistakenly included
a newline character "\n".
This could lead to confusing log output or misformatted names in sysfs
or debug messages.

This fix removes the newline to ensure proper IRQ naming.

Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
 drivers/perf/cxl_pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/perf/cxl_pmu.c b/drivers/perf/cxl_pmu.c
index 8998c0a2f3a2d..5a475a5a1f095 100644
--- a/drivers/perf/cxl_pmu.c
+++ b/drivers/perf/cxl_pmu.c
@@ -873,7 +873,7 @@ static int cxl_pmu_probe(struct device *dev)
 		return rc;
 	irq = rc;
 
-	irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_overflow\n", dev_name);
+	irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_overflow", dev_name);
 	if (!irq_name)
 		return -ENOMEM;
 
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] perf/cxlpmu: Fix typos in cxl_pmu.c comments and documentation
  2025-06-24 19:43 [PATCH v2 0/3] perf/cxlpmu: Fix allocation argument order and minor formatting Alok Tiwari
  2025-06-24 19:43 ` [PATCH v2 1/3] perf/cxlpmu: Fix devm_kcalloc() argument order in cxl_pmu_probe() Alok Tiwari
  2025-06-24 19:43 ` [PATCH v2 2/3] perf/cxlpmu: Remove unintended newline from IRQ name format string Alok Tiwari
@ 2025-06-24 19:43 ` Alok Tiwari
  2025-06-25  9:05   ` Jonathan Cameron
  2025-07-14 15:10 ` [PATCH v2 0/3] perf/cxlpmu: Fix allocation argument order and minor formatting Will Deacon
  3 siblings, 1 reply; 8+ messages in thread
From: Alok Tiwari @ 2025-06-24 19:43 UTC (permalink / raw)
  To: jonathan.cameron, will, mark.rutland, linux-cxl
  Cc: alok.a.tiwari, linux-perf-users, linux-kernel

Fix several minor typo errors in comments:
- Remove duplicated word "a" in "a a VID / GroupID".
- Correct "Opcopdes" to "Opcodes" in CXL spec reference.
- Fix spelling of "implemnted" to "implemented".

Improves code readability and documentation consistency.

Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
 drivers/perf/cxl_pmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/perf/cxl_pmu.c b/drivers/perf/cxl_pmu.c
index 5a475a5a1f095..d094030220bf2 100644
--- a/drivers/perf/cxl_pmu.c
+++ b/drivers/perf/cxl_pmu.c
@@ -113,7 +113,7 @@ struct cxl_pmu_info {
 
 /*
  * All CPMU counters are discoverable via the Event Capabilities Registers.
- * Each Event Capability register contains a a VID / GroupID.
+ * Each Event Capability register contains a VID / GroupID.
  * A counter may then count any combination (by summing) of events in
  * that group which are in the Supported Events Bitmask.
  * However, there are some complexities to the scheme.
@@ -406,7 +406,7 @@ static struct attribute *cxl_pmu_event_attrs[] = {
 	CXL_PMU_EVENT_CXL_ATTR(s2m_bisnp_curblk,		CXL_PMU_GID_S2M_BISNP, BIT(4)),
 	CXL_PMU_EVENT_CXL_ATTR(s2m_bisnp_datblk,		CXL_PMU_GID_S2M_BISNP, BIT(5)),
 	CXL_PMU_EVENT_CXL_ATTR(s2m_bisnp_invblk,		CXL_PMU_GID_S2M_BISNP, BIT(6)),
-	/* CXL rev 3.1 Table 3-50 S2M NDR Opcopdes */
+	/* CXL rev 3.1 Table 3-50 S2M NDR Opcodes */
 	CXL_PMU_EVENT_CXL_ATTR(s2m_ndr_cmp,			CXL_PMU_GID_S2M_NDR, BIT(0)),
 	CXL_PMU_EVENT_CXL_ATTR(s2m_ndr_cmps,			CXL_PMU_GID_S2M_NDR, BIT(1)),
 	CXL_PMU_EVENT_CXL_ATTR(s2m_ndr_cmpe,			CXL_PMU_GID_S2M_NDR, BIT(2)),
@@ -627,7 +627,7 @@ static void cxl_pmu_event_start(struct perf_event *event, int flags)
 	hwc->state = 0;
 
 	/*
-	 * Currently only hdm filter control is implemnted, this code will
+	 * Currently only hdm filter control is implemented, this code will
 	 * want generalizing when more filters are added.
 	 */
 	if (info->filter_hdm) {
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/3] perf/cxlpmu: Fix devm_kcalloc() argument order in cxl_pmu_probe()
  2025-06-24 19:43 ` [PATCH v2 1/3] perf/cxlpmu: Fix devm_kcalloc() argument order in cxl_pmu_probe() Alok Tiwari
@ 2025-06-25  8:59   ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2025-06-25  8:59 UTC (permalink / raw)
  To: Alok Tiwari; +Cc: will, mark.rutland, linux-cxl, linux-perf-users, linux-kernel

On Tue, 24 Jun 2025 12:43:38 -0700
Alok Tiwari <alok.a.tiwari@oracle.com> wrote:

> The previous code mistakenly swapped the count and size parameters.
> This fix corrects the argument order in devm_kcalloc() to follow the
> conventional count, size form, avoiding potential confusion or bugs.
> 
> Previous usage:
>   devm_kcalloc(dev, sizeof(*info->hw_events), info->num_counters,
>    GFP_KERNEL);
> 
> New usage:
>   devm_kcalloc(dev, info->num_counters, sizeof(*info->hw_events),
>    GFP_KERNEL);

Too much detail! The sentence above would have been enough given
we have the code change to see how it applied.
> 
> Previous incorrect order could lead to unexpected memory allocation
> behavior. This fix ensures correct allocation of hw_event structure.

It doesn't actually make any real difference.  Look at the implementation
of devm_kmalloc_array()  What it does is make it harder to reason about the
code and for that it is worth fixing up.

Anyhow none of that really matters.

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> 
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
> ---
>  drivers/perf/cxl_pmu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/perf/cxl_pmu.c b/drivers/perf/cxl_pmu.c
> index d6693519eaee2..8998c0a2f3a2d 100644
> --- a/drivers/perf/cxl_pmu.c
> +++ b/drivers/perf/cxl_pmu.c
> @@ -834,8 +834,8 @@ static int cxl_pmu_probe(struct device *dev)
>  	if (rc)
>  		return rc;
>  
> -	info->hw_events = devm_kcalloc(dev, sizeof(*info->hw_events),
> -				       info->num_counters, GFP_KERNEL);
> +	info->hw_events = devm_kcalloc(dev, info->num_counters,
> +				       sizeof(*info->hw_events), GFP_KERNEL);
>  	if (!info->hw_events)
>  		return -ENOMEM;
>  


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] perf/cxlpmu: Remove unintended newline from IRQ name format string
  2025-06-24 19:43 ` [PATCH v2 2/3] perf/cxlpmu: Remove unintended newline from IRQ name format string Alok Tiwari
@ 2025-06-25  9:04   ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2025-06-25  9:04 UTC (permalink / raw)
  To: Alok Tiwari; +Cc: will, mark.rutland, linux-cxl, linux-perf-users, linux-kernel

On Tue, 24 Jun 2025 12:43:39 -0700
Alok Tiwari <alok.a.tiwari@oracle.com> wrote:

> The IRQ name format string used in devm_kasprintf() mistakenly included
> a newline character "\n".
> This could lead to confusing log output or misformatted names in sysfs
> or debug messages.
> 
> This fix removes the newline to ensure proper IRQ naming.
> 
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>

> ---
>  drivers/perf/cxl_pmu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/perf/cxl_pmu.c b/drivers/perf/cxl_pmu.c
> index 8998c0a2f3a2d..5a475a5a1f095 100644
> --- a/drivers/perf/cxl_pmu.c
> +++ b/drivers/perf/cxl_pmu.c
> @@ -873,7 +873,7 @@ static int cxl_pmu_probe(struct device *dev)
>  		return rc;
>  	irq = rc;
>  
> -	irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_overflow\n", dev_name);
> +	irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_overflow", dev_name);
>  	if (!irq_name)
>  		return -ENOMEM;
>  


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] perf/cxlpmu: Fix typos in cxl_pmu.c comments and documentation
  2025-06-24 19:43 ` [PATCH v2 3/3] perf/cxlpmu: Fix typos in cxl_pmu.c comments and documentation Alok Tiwari
@ 2025-06-25  9:05   ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2025-06-25  9:05 UTC (permalink / raw)
  To: Alok Tiwari; +Cc: will, mark.rutland, linux-cxl, linux-perf-users, linux-kernel

On Tue, 24 Jun 2025 12:43:40 -0700
Alok Tiwari <alok.a.tiwari@oracle.com> wrote:

> Fix several minor typo errors in comments:
> - Remove duplicated word "a" in "a a VID / GroupID".
> - Correct "Opcopdes" to "Opcodes" in CXL spec reference.
> - Fix spelling of "implemnted" to "implemented".
> 
> Improves code readability and documentation consistency.
> 
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
One day I'll remember to run a spell checker :(

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>

> ---
>  drivers/perf/cxl_pmu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/perf/cxl_pmu.c b/drivers/perf/cxl_pmu.c
> index 5a475a5a1f095..d094030220bf2 100644
> --- a/drivers/perf/cxl_pmu.c
> +++ b/drivers/perf/cxl_pmu.c
> @@ -113,7 +113,7 @@ struct cxl_pmu_info {
>  
>  /*
>   * All CPMU counters are discoverable via the Event Capabilities Registers.
> - * Each Event Capability register contains a a VID / GroupID.
> + * Each Event Capability register contains a VID / GroupID.
>   * A counter may then count any combination (by summing) of events in
>   * that group which are in the Supported Events Bitmask.
>   * However, there are some complexities to the scheme.
> @@ -406,7 +406,7 @@ static struct attribute *cxl_pmu_event_attrs[] = {
>  	CXL_PMU_EVENT_CXL_ATTR(s2m_bisnp_curblk,		CXL_PMU_GID_S2M_BISNP, BIT(4)),
>  	CXL_PMU_EVENT_CXL_ATTR(s2m_bisnp_datblk,		CXL_PMU_GID_S2M_BISNP, BIT(5)),
>  	CXL_PMU_EVENT_CXL_ATTR(s2m_bisnp_invblk,		CXL_PMU_GID_S2M_BISNP, BIT(6)),
> -	/* CXL rev 3.1 Table 3-50 S2M NDR Opcopdes */
> +	/* CXL rev 3.1 Table 3-50 S2M NDR Opcodes */
>  	CXL_PMU_EVENT_CXL_ATTR(s2m_ndr_cmp,			CXL_PMU_GID_S2M_NDR, BIT(0)),
>  	CXL_PMU_EVENT_CXL_ATTR(s2m_ndr_cmps,			CXL_PMU_GID_S2M_NDR, BIT(1)),
>  	CXL_PMU_EVENT_CXL_ATTR(s2m_ndr_cmpe,			CXL_PMU_GID_S2M_NDR, BIT(2)),
> @@ -627,7 +627,7 @@ static void cxl_pmu_event_start(struct perf_event *event, int flags)
>  	hwc->state = 0;
>  
>  	/*
> -	 * Currently only hdm filter control is implemnted, this code will
> +	 * Currently only hdm filter control is implemented, this code will
>  	 * want generalizing when more filters are added.
>  	 */
>  	if (info->filter_hdm) {


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/3] perf/cxlpmu: Fix allocation argument order and minor formatting
  2025-06-24 19:43 [PATCH v2 0/3] perf/cxlpmu: Fix allocation argument order and minor formatting Alok Tiwari
                   ` (2 preceding siblings ...)
  2025-06-24 19:43 ` [PATCH v2 3/3] perf/cxlpmu: Fix typos in cxl_pmu.c comments and documentation Alok Tiwari
@ 2025-07-14 15:10 ` Will Deacon
  3 siblings, 0 replies; 8+ messages in thread
From: Will Deacon @ 2025-07-14 15:10 UTC (permalink / raw)
  To: jonathan.cameron, mark.rutland, linux-cxl, Alok Tiwari
  Cc: catalin.marinas, kernel-team, Will Deacon, linux-perf-users,
	linux-kernel

On Tue, 24 Jun 2025 12:43:37 -0700, Alok Tiwari wrote:
> This patch series includes a few minor cleanups and correctness
> improvements in drivers/perf/cxl_pmu.c
> 
> Correct the argument order in devm_kcalloc() to follow the
> conventional count, size form to avoid any confusion or bugs.
> 
> Remove an unintended newline in the IRQ name string passed to
> devm_kasprintf() and  fix a formatting issue in the devm_kasprintf()
> 
> [...]

Applied to will (for-next/perf), thanks!

[1/3] perf/cxlpmu: Fix devm_kcalloc() argument order in cxl_pmu_probe()
      https://git.kernel.org/will/c/6ae58c74e7aa
[2/3] perf/cxlpmu: Remove unintended newline from IRQ name format string
      https://git.kernel.org/will/c/3e870815ccf5
[3/3] perf/cxlpmu: Fix typos in cxl_pmu.c comments and documentation
      https://git.kernel.org/will/c/0259de6331df

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-07-14 15:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-24 19:43 [PATCH v2 0/3] perf/cxlpmu: Fix allocation argument order and minor formatting Alok Tiwari
2025-06-24 19:43 ` [PATCH v2 1/3] perf/cxlpmu: Fix devm_kcalloc() argument order in cxl_pmu_probe() Alok Tiwari
2025-06-25  8:59   ` Jonathan Cameron
2025-06-24 19:43 ` [PATCH v2 2/3] perf/cxlpmu: Remove unintended newline from IRQ name format string Alok Tiwari
2025-06-25  9:04   ` Jonathan Cameron
2025-06-24 19:43 ` [PATCH v2 3/3] perf/cxlpmu: Fix typos in cxl_pmu.c comments and documentation Alok Tiwari
2025-06-25  9:05   ` Jonathan Cameron
2025-07-14 15:10 ` [PATCH v2 0/3] perf/cxlpmu: Fix allocation argument order and minor formatting Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).