mbox series

[v4,00/10] Refactor the common parts to the HiSilicon Uncore PMU core and cleanups

Message ID 20241203125049.39458-1-yangyicong@huawei.com (mailing list archive)
Headers show
Series Refactor the common parts to the HiSilicon Uncore PMU core and cleanups | expand

Message

Yicong Yang Dec. 3, 2024, 12:50 p.m. UTC
From: Yicong Yang <yangyicong@hisilicon.com>

This series mainly contains the refactor of the HiSilicon Uncore PMU by
extracting the common parts from each drivers into the core:
- the retrieving of the PMU topology ID
- the common sysfs attributes like cpumask and identifier

In order to achieve this, we need to do below preparation:
- refactor the detection of associated CPUs for PMUs locates on a SICL
- maintain the topology information in a dedicated data structure
- provides a generic implementation of cpumask/identifier attributes

Besides also include below changes/cleanups in this patchset
- add one new sysfs attributes for better describing the topology information
  of the associated CPUs of the PMU.
- define a symbol namespace for HiSilicon Uncore PMUs to avoid pollute the
  common ones
- two minor nonfunctional cleanups of DDRC PMU

Change since v3:
- Split the associated_cpus refactor patches according to the functions, hope
  will be easier to review
- Drop the use of cpu_online_mask out of cpuhp
Link: https://lore.kernel.org/linux-arm-kernel/20241026072424.29887-1-yangyicong@huawei.com/

Change since v2:
- remove one redundant newline and add Jonathan's tag for Patch 1 and 5
Link: https://lore.kernel.org/linux-arm-kernel/20241022145305.47056-1-yangyicong@huawei.com/

Changes since v1:
Address Jonathan's comments and add tags for some patches
- Provide a generic cpumask/identifier attribute group
- refine the comments/commit as suggested
Link: https://lore.kernel.org/linux-arm-kernel/20241018095745.57057-1-yangyicong@huawei.com/

Junhao He (2):
  drivers/perf: hisi: Fix incorrect variable name "hha_pmu" in DDRC PMU
    driver
  drivers/perf: hisi: Delete redundant blank line of DDRC PMU

Yicong Yang (8):
  drivers/perf: hisi: Define a symbol namespace for HiSilicon Uncore
    PMUs
  drivers/perf: hisi: Don't update the associated_cpus on CPU offline
  drivers/perf: hisi: Migrate to one online CPU if no associated one
    online
  drivers/perf: hisi: Refactor the detection of associated CPUs
  drivers/perf: hisi: Extract topology information to a separate
    structure
  drivers/perf: hisi: Add a common function to retrieve topology from
    firmware
  drivers/perf: hisi: Provide a generic implementation of
    cpumask/identifier
  drivers/perf: hisi: Export associated CPUs of each PMU through sysfs

 Documentation/admin-guide/perf/hisi-pmu.rst   |   5 +-
 drivers/perf/hisilicon/hisi_uncore_cpa_pmu.c  |  42 +----
 drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c |  61 ++-----
 drivers/perf/hisilicon/hisi_uncore_hha_pmu.c  |  48 ++----
 drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c  |  44 ++---
 drivers/perf/hisilicon/hisi_uncore_pa_pmu.c   |  53 ++----
 drivers/perf/hisilicon/hisi_uncore_pmu.c      | 160 +++++++++++++-----
 drivers/perf/hisilicon/hisi_uncore_pmu.h      |  49 +++++-
 drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c |  43 +----
 drivers/perf/hisilicon/hisi_uncore_uc_pmu.c   |  45 ++---
 10 files changed, 248 insertions(+), 302 deletions(-)

Comments

Will Deacon Dec. 10, 2024, 12:05 p.m. UTC | #1
On Tue, Dec 03, 2024 at 08:50:39PM +0800, Yicong Yang wrote:
> From: Yicong Yang <yangyicong@hisilicon.com>
> 
> This series mainly contains the refactor of the HiSilicon Uncore PMU by
> extracting the common parts from each drivers into the core:
> - the retrieving of the PMU topology ID
> - the common sysfs attributes like cpumask and identifier
> 
> In order to achieve this, we need to do below preparation:
> - refactor the detection of associated CPUs for PMUs locates on a SICL
> - maintain the topology information in a dedicated data structure
> - provides a generic implementation of cpumask/identifier attributes
> 
> Besides also include below changes/cleanups in this patchset
> - add one new sysfs attributes for better describing the topology information
>   of the associated CPUs of the PMU.
> - define a symbol namespace for HiSilicon Uncore PMUs to avoid pollute the
>   common ones
> - two minor nonfunctional cleanups of DDRC PMU
> 
> Change since v3:
> - Split the associated_cpus refactor patches according to the functions, hope
>   will be easier to review
> - Drop the use of cpu_online_mask out of cpuhp
> Link: https://lore.kernel.org/linux-arm-kernel/20241026072424.29887-1-yangyicong@huawei.com/

This doesn't build on top of -rc2 (see log below). I suspect this is because
of the recent MODULE_IMPORT_NS() changes to use string literals [1].

Please can you send a v5?

Will

[1] cdd30ebb1b9f ("module: Convert symbol namespace to string literal")

--->8

In file included from ./include/linux/module.h:22,
                 from ./include/linux/device/driver.h:21,
                 from ./include/linux/device.h:32,
                 from ./include/linux/acpi.h:14,
                 from drivers/perf/hisilicon/hisi_uncore_hha_pmu.c:11:
drivers/perf/hisilicon/hisi_uncore_hha_pmu.c:559:18: error: expected ‘,’ or ‘;’ before ‘HISI_PMU’
  559 | MODULE_IMPORT_NS(HISI_PMU);
      |                  ^~~~~~~~
./include/linux/moduleparam.h:26:47: note: in definition of macro ‘__MODULE_INFO’
   26 |   = __MODULE_INFO_PREFIX __stringify(tag) "=" info
      |                                               ^~~~
./include/linux/module.h:299:30: note: in expansion of macro ‘MODULE_INFO’
  299 | #define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, ns)
      |                              ^~~~~~~~~~~
drivers/perf/hisilicon/hisi_uncore_hha_pmu.c:559:1: note: in expansion of macro ‘MODULE_IMPORT_NS’
  559 | MODULE_IMPORT_NS(HISI_PMU);
      | ^~~~~~~~~~~~~~~~
make[5]: *** [scripts/Makefile.build:194: drivers/perf/hisilicon/hisi_uncore_hha_pmu.o] Error 1
make[5]: *** Waiting for unfinished jobs....
In file included from ./include/linux/module.h:22,
                 from ./include/linux/device/driver.h:21,
                 from ./include/linux/device.h:32,
                 from ./include/linux/acpi.h:14,
                 from drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c:11:
drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c:595:18: error: expected ‘,’ or ‘;’ before ‘HISI_PMU’
  595 | MODULE_IMPORT_NS(HISI_PMU);
      |                  ^~~~~~~~
./include/linux/moduleparam.h:26:47: note: in definition of macro ‘__MODULE_INFO’
   26 |   = __MODULE_INFO_PREFIX __stringify(tag) "=" info
      |                                               ^~~~
./include/linux/module.h:299:30: note: in expansion of macro ‘MODULE_INFO’
  299 | #define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, ns)
      |                              ^~~~~~~~~~~
drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c:595:1: note: in expansion of macro ‘MODULE_IMPORT_NS’
  595 | MODULE_IMPORT_NS(HISI_PMU);
      | ^~~~~~~~~~~~~~~~
make[5]: *** [scripts/Makefile.build:194: drivers/perf/hisilicon/hisi_uncore_l3c_pmu.o] Error 1
/tmp/ccKFrDMm.s: Assembler messages:
/tmp/ccKFrDMm.s:7: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:8: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:9: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:10: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:11: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:12: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:13: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:14: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:15: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:16: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:17: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:18: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:19: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:20: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:21: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:22: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:23: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:24: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:25: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:26: Error: junk at end of line, first unrecognized character is `H'
/tmp/ccKFrDMm.s:27: Error: junk at end of line, first unrecognized character is `H'
make[5]: *** [scripts/Makefile.build:194: drivers/perf/hisilicon/hisi_uncore_pmu.o] Error 1
In file included from ./include/linux/module.h:22,
                 from ./include/linux/device/driver.h:21,
                 from ./include/linux/device.h:32,
                 from ./include/linux/acpi.h:14,
                 from drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c:11:
drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c:556:18: error: expected ‘,’ or ‘;’ before ‘HISI_PMU’
  556 | MODULE_IMPORT_NS(HISI_PMU);
      |                  ^~~~~~~~
./include/linux/moduleparam.h:26:47: note: in definition of macro ‘__MODULE_INFO’
   26 |   = __MODULE_INFO_PREFIX __stringify(tag) "=" info
      |                                               ^~~~
./include/linux/module.h:299:30: note: in expansion of macro ‘MODULE_INFO’
  299 | #define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, ns)
      |                              ^~~~~~~~~~~
drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c:556:1: note: in expansion of macro ‘MODULE_IMPORT_NS’
  556 | MODULE_IMPORT_NS(HISI_PMU);
      | ^~~~~~~~~~~~~~~~
make[5]: *** [scripts/Makefile.build:194: drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.o] Error 1
make[4]: *** [scripts/Makefile.build:440: drivers/perf/hisilicon] Error 2
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:440: drivers/perf] Error 2
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [scripts/Makefile.build:440: drivers] Error 2
Yicong Yang Dec. 10, 2024, 1:04 p.m. UTC | #2
On 2024/12/10 20:05, Will Deacon wrote:
> On Tue, Dec 03, 2024 at 08:50:39PM +0800, Yicong Yang wrote:
>> From: Yicong Yang <yangyicong@hisilicon.com>
>>
>> This series mainly contains the refactor of the HiSilicon Uncore PMU by
>> extracting the common parts from each drivers into the core:
>> - the retrieving of the PMU topology ID
>> - the common sysfs attributes like cpumask and identifier
>>
>> In order to achieve this, we need to do below preparation:
>> - refactor the detection of associated CPUs for PMUs locates on a SICL
>> - maintain the topology information in a dedicated data structure
>> - provides a generic implementation of cpumask/identifier attributes
>>
>> Besides also include below changes/cleanups in this patchset
>> - add one new sysfs attributes for better describing the topology information
>>   of the associated CPUs of the PMU.
>> - define a symbol namespace for HiSilicon Uncore PMUs to avoid pollute the
>>   common ones
>> - two minor nonfunctional cleanups of DDRC PMU
>>
>> Change since v3:
>> - Split the associated_cpus refactor patches according to the functions, hope
>>   will be easier to review
>> - Drop the use of cpu_online_mask out of cpuhp
>> Link: https://lore.kernel.org/linux-arm-kernel/20241026072424.29887-1-yangyicong@huawei.com/
> 
> This doesn't build on top of -rc2 (see log below). I suspect this is because
> of the recent MODULE_IMPORT_NS() changes to use string literals [1].
> 
> Please can you send a v5?

sure, will rebase on -rc2 and address this.

Thanks.

> 
> Will
> 
> [1] cdd30ebb1b9f ("module: Convert symbol namespace to string literal")
> 
> --->8
> 
> In file included from ./include/linux/module.h:22,
>                  from ./include/linux/device/driver.h:21,
>                  from ./include/linux/device.h:32,
>                  from ./include/linux/acpi.h:14,
>                  from drivers/perf/hisilicon/hisi_uncore_hha_pmu.c:11:
> drivers/perf/hisilicon/hisi_uncore_hha_pmu.c:559:18: error: expected ‘,’ or ‘;’ before ‘HISI_PMU’
>   559 | MODULE_IMPORT_NS(HISI_PMU);
>       |                  ^~~~~~~~
> ./include/linux/moduleparam.h:26:47: note: in definition of macro ‘__MODULE_INFO’
>    26 |   = __MODULE_INFO_PREFIX __stringify(tag) "=" info
>       |                                               ^~~~
> ./include/linux/module.h:299:30: note: in expansion of macro ‘MODULE_INFO’
>   299 | #define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, ns)
>       |                              ^~~~~~~~~~~
> drivers/perf/hisilicon/hisi_uncore_hha_pmu.c:559:1: note: in expansion of macro ‘MODULE_IMPORT_NS’
>   559 | MODULE_IMPORT_NS(HISI_PMU);
>       | ^~~~~~~~~~~~~~~~
> make[5]: *** [scripts/Makefile.build:194: drivers/perf/hisilicon/hisi_uncore_hha_pmu.o] Error 1
> make[5]: *** Waiting for unfinished jobs....
> In file included from ./include/linux/module.h:22,
>                  from ./include/linux/device/driver.h:21,
>                  from ./include/linux/device.h:32,
>                  from ./include/linux/acpi.h:14,
>                  from drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c:11:
> drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c:595:18: error: expected ‘,’ or ‘;’ before ‘HISI_PMU’
>   595 | MODULE_IMPORT_NS(HISI_PMU);
>       |                  ^~~~~~~~
> ./include/linux/moduleparam.h:26:47: note: in definition of macro ‘__MODULE_INFO’
>    26 |   = __MODULE_INFO_PREFIX __stringify(tag) "=" info
>       |                                               ^~~~
> ./include/linux/module.h:299:30: note: in expansion of macro ‘MODULE_INFO’
>   299 | #define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, ns)
>       |                              ^~~~~~~~~~~
> drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c:595:1: note: in expansion of macro ‘MODULE_IMPORT_NS’
>   595 | MODULE_IMPORT_NS(HISI_PMU);
>       | ^~~~~~~~~~~~~~~~
> make[5]: *** [scripts/Makefile.build:194: drivers/perf/hisilicon/hisi_uncore_l3c_pmu.o] Error 1
> /tmp/ccKFrDMm.s: Assembler messages:
> /tmp/ccKFrDMm.s:7: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:8: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:9: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:10: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:11: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:12: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:13: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:14: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:15: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:16: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:17: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:18: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:19: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:20: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:21: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:22: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:23: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:24: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:25: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:26: Error: junk at end of line, first unrecognized character is `H'
> /tmp/ccKFrDMm.s:27: Error: junk at end of line, first unrecognized character is `H'
> make[5]: *** [scripts/Makefile.build:194: drivers/perf/hisilicon/hisi_uncore_pmu.o] Error 1
> In file included from ./include/linux/module.h:22,
>                  from ./include/linux/device/driver.h:21,
>                  from ./include/linux/device.h:32,
>                  from ./include/linux/acpi.h:14,
>                  from drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c:11:
> drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c:556:18: error: expected ‘,’ or ‘;’ before ‘HISI_PMU’
>   556 | MODULE_IMPORT_NS(HISI_PMU);
>       |                  ^~~~~~~~
> ./include/linux/moduleparam.h:26:47: note: in definition of macro ‘__MODULE_INFO’
>    26 |   = __MODULE_INFO_PREFIX __stringify(tag) "=" info
>       |                                               ^~~~
> ./include/linux/module.h:299:30: note: in expansion of macro ‘MODULE_INFO’
>   299 | #define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, ns)
>       |                              ^~~~~~~~~~~
> drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c:556:1: note: in expansion of macro ‘MODULE_IMPORT_NS’
>   556 | MODULE_IMPORT_NS(HISI_PMU);
>       | ^~~~~~~~~~~~~~~~
> make[5]: *** [scripts/Makefile.build:194: drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.o] Error 1
> make[4]: *** [scripts/Makefile.build:440: drivers/perf/hisilicon] Error 2
> make[4]: *** Waiting for unfinished jobs....
> make[3]: *** [scripts/Makefile.build:440: drivers/perf] Error 2
> make[3]: *** Waiting for unfinished jobs....
> make[2]: *** [scripts/Makefile.build:440: drivers] Error 2
> .
>