mbox series

[v3,00/10] perf: Avoid placing cpumask on the stack

Message ID 20240403155950.2068109-1-dawei.li@shingroup.cn
Headers show
Series perf: Avoid placing cpumask on the stack | expand

Message

Dawei Li April 3, 2024, 3:59 p.m. UTC
Hi all,

This is v3 of previous series on elimination of placing cpumask var on
stack.

Change since v2:
- Update commit message for patch[2-10]. [Mark] 
- Add Reviewed-by from Mark for patch[2-10].

Change since v1:
- Change from dynamic allocation to a temporary var free helper:
  cpumask_any_and_but().	[Mark]

- Some minor coding style improvements, reverse chrismas tree e.g.

- For cpumask_any_and_but() itself:
  - Moved to cpumask.h, just like other helpers.
  - Return value converted to unsigned int.
  - Remove EXPORT_SYMBOL, for obvious reason.

v1:
https://lore.kernel.org/lkml/20240402105610.1695644-1-dawei.li@shingroup.cn/
https://lore.kernel.org/lkml/1486381132-5610-1-git-send-email-mark.rutland@arm.com/

v2:
https://lore.kernel.org/lkml/20240403125109.2054881-1-dawei.li@shingroup.cn/

Dawei Li (9):
  perf/alibaba_uncore_drw: Avoid placing cpumask on the stack
  perf/arm-cmn: Avoid placing cpumask on the stack
  perf/arm_cspmu: Avoid placing cpumask on the stack
  perf/arm_dsu: Avoid placing cpumask on the stack
  perf/dwc_pcie: Avoid placing cpumask on the stack
  perf/hisi_pcie: Avoid placing cpumask on the stack
  perf/hisi_uncore: Avoid placing cpumask on the stack
  perf/qcom_l2: Avoid placing cpumask on the stack
  perf/thunderx2: Avoid placing cpumask on the stack

Mark Rutland (1):
  cpumask: add cpumask_any_and_but()

 drivers/perf/alibaba_uncore_drw_pmu.c    | 10 +++-------
 drivers/perf/arm-cmn.c                   | 10 +++++-----
 drivers/perf/arm_cspmu/arm_cspmu.c       |  8 +++-----
 drivers/perf/arm_dsu_pmu.c               | 19 ++++++-------------
 drivers/perf/dwc_pcie_pmu.c              | 10 ++++------
 drivers/perf/hisilicon/hisi_pcie_pmu.c   |  9 ++++-----
 drivers/perf/hisilicon/hisi_uncore_pmu.c |  6 ++----
 drivers/perf/qcom_l2_pmu.c               |  8 +++-----
 drivers/perf/thunderx2_pmu.c             | 10 +++-------
 include/linux/cpumask.h                  | 23 +++++++++++++++++++++++
 10 files changed, 56 insertions(+), 57 deletions(-)

Thanks,

    Dawei

Comments

Jonathan Cameron April 5, 2024, 9:54 a.m. UTC | #1
On Wed, 3 Apr 2024 23:59:47 +0800
Dawei Li <dawei.li@shingroup.cn> wrote:

> In general it's preferable to avoid placing cpumasks on the stack, as
> for large values of NR_CPUS these can consume significant amounts of
> stack space and make stack overflows more likely.
> 
> Use cpumask_any_and_but() to avoid the need for a temporary cpumask on
> the stack.
> 
> Suggested-by: Mark Rutland <mark.rutland@arm.com>
> Reviewed-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Jonathan Cameron April 5, 2024, 9:54 a.m. UTC | #2
On Wed, 3 Apr 2024 23:59:48 +0800
Dawei Li <dawei.li@shingroup.cn> wrote:

> In general it's preferable to avoid placing cpumasks on the stack, as
> for large values of NR_CPUS these can consume significant amounts of
> stack space and make stack overflows more likely.
> 
> Use cpumask_any_and_but() to avoid the need for a temporary cpumask on
> the stack.
> 
> Suggested-by: Mark Rutland <mark.rutland@arm.com>
> Reviewed-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Shuai Xue April 8, 2024, 12:30 a.m. UTC | #3
On 2024/4/3 23:59, Dawei Li wrote:
> In general it's preferable to avoid placing cpumasks on the stack, as
> for large values of NR_CPUS these can consume significant amounts of
> stack space and make stack overflows more likely.
> 
> Use cpumask_any_and_but() to avoid the need for a temporary cpumask on
> the stack.
> 
> Suggested-by: Mark Rutland <mark.rutland@arm.com>
> Reviewed-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Dawei Li <dawei.li@shingroup.cn>

Reviewed-by: Shuai Xue <xueshuai@linux.alibaba.com>

Thank you.

Shuai
Will Deacon April 9, 2024, 4:59 p.m. UTC | #4
On Wed, 03 Apr 2024 23:59:40 +0800, Dawei Li wrote:
> This is v3 of previous series on elimination of placing cpumask var on
> stack.
> 
> Change since v2:
> - Update commit message for patch[2-10]. [Mark]
> - Add Reviewed-by from Mark for patch[2-10].
> 
> [...]

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

[01/10] cpumask: add cpumask_any_and_but()
        https://git.kernel.org/will/c/897fa2c38c07
[02/10] perf/alibaba_uncore_drw: Avoid placing cpumask on the stack
        https://git.kernel.org/will/c/2f6589df124e
[03/10] perf/arm-cmn: Avoid placing cpumask on the stack
        https://git.kernel.org/will/c/60c73240f304
[04/10] perf/arm_cspmu: Avoid placing cpumask on the stack
        https://git.kernel.org/will/c/b5310fa1fe8e
[05/10] perf/arm_dsu: Avoid placing cpumask on the stack
        https://git.kernel.org/will/c/bea2a13b207e
[06/10] perf/dwc_pcie: Avoid placing cpumask on the stack
        https://git.kernel.org/will/c/cf276ee46bc4
[07/10] perf/hisi_pcie: Avoid placing cpumask on the stack
        https://git.kernel.org/will/c/d7df79e6af29
[08/10] perf/hisi_uncore: Avoid placing cpumask on the stack
        https://git.kernel.org/will/c/b78d0fa25462
[09/10] perf/qcom_l2: Avoid placing cpumask on the stack
        https://git.kernel.org/will/c/fc85cee97029
[10/10] perf/thunderx2: Avoid placing cpumask on the stack
        https://git.kernel.org/will/c/595275ca4984

Cheers,