Re: [PATCH] perf/x86/intel: Delay memory deallocation until x86_pmu_dead_cpu()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 11, 2019 at 09:53:53PM +0800, zhe.he@xxxxxxxxxxxxx wrote:
> From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> 
> intel_pmu_cpu_prepare() allocated memory for ->shared_regs among other
> members of struct cpu_hw_events. This memory is released in
> intel_pmu_cpu_dying() which is wrong. The counterpart of the
> intel_pmu_cpu_prepare() callback is x86_pmu_dead_cpu().
> 
> Otherwise if the CPU fails on the UP path between CPUHP_PERF_X86_PREPARE
> and CPUHP_AP_PERF_X86_STARTING then it won't release the memory but
> allocate new memory on the next attempt to online the CPU (leaking the
> old memory).
> Also, if the CPU down path fails between CPUHP_AP_PERF_X86_STARTING and
> CPUHP_PERF_X86_PREPARE then the CPU will go back online but never
> allocate the memory that was released in x86_pmu_dying_cpu().
> 
> Make the memory allocation/free symmetrical in regard to the CPU hotplug
> notifier by moving the deallocation to intel_pmu_cpu_dead().
> 
> This started in commit:
> 
>    a7e3ed1e47011 ("perf: Add support for supplementary event registers").
> 
> In principle the bug was introduced in v2.6.39 (!), but it will almost
> certainly not backport cleanly across the big CPU hotplug rewrite between v4.7-v4.15...
> 
> [ bigeasy: Added patch description. ]
> [ mingo: Added backporting guidance. ]
> 
> Reported-by: He Zhe <zhe.he@xxxxxxxxxxxxx>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx> # With developer hat on
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx> # With maintainer hat on
> Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
> Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: acme@xxxxxxxxxx
> Cc: bp@xxxxxxxxx
> Cc: hpa@xxxxxxxxx
> Cc: jolsa@xxxxxxxxxx
> Cc: kan.liang@xxxxxxxxxxxxxxx
> Cc: namhyung@xxxxxxxxxx
> Cc: <stable@xxxxxxxxxxxxxxx>
> Fixes: a7e3ed1e47011 ("perf: Add support for supplementary event registers").
> Link: https://lkml.kernel.org/r/20181219165350.6s3jvyxbibpvlhtq@xxxxxxxxxxxxx
> Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
> [ He Zhe: Fixes conflict caused by missing disable_counter_freeze which is
>  introduced since v4.20 af3bdb991a5cb. ]
> Signed-off-by: He Zhe <zhe.he@xxxxxxxxxxxxx>
> ---
> This backport is for v4.9. The original commit id is 602cae04c4864.

Now queued up, thanks.

greg k-h



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux