From: Greg KH <greg@kroah.com>
To: zhe.he@windriver.com
Cc: stable@vger.kernel.org
Subject: Re: [PATCH] perf/x86/intel: Delay memory deallocation until x86_pmu_dead_cpu()
Date: Mon, 11 Feb 2019 15:14:09 +0100 [thread overview]
Message-ID: <20190211141409.GA31763@kroah.com> (raw)
In-Reply-To: <1549893181-407670-1-git-send-email-zhe.he@windriver.com>
On Mon, Feb 11, 2019 at 09:53:01PM +0800, zhe.he@windriver.com wrote:
> From: Peter Zijlstra <peterz@infradead.org>
>
> 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@windriver.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> # With developer hat on
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> # With maintainer hat on
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: acme@kernel.org
> Cc: bp@alien8.de
> Cc: hpa@zytor.com
> Cc: jolsa@kernel.org
> Cc: kan.liang@linux.intel.com
> Cc: namhyung@kernel.org
> Cc: <stable@vger.kernel.org>
> Fixes: a7e3ed1e47011 ("perf: Add support for supplementary event registers").
> Link: https://lkml.kernel.org/r/20181219165350.6s3jvyxbibpvlhtq@linutronix.de
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> [ He Zhe: Fixes conflict caused by missing disable_counter_freeze which is
> introduced since v4.20 af3bdb991a5cb. ]
> Signed-off-by: He Zhe <zhe.he@windriver.com>
> ---
> This backport is for v4.19 and v4.14. The original commit id is 602cae04c4864.
Now queued up, thanks!
greg k-h
next prev parent reply other threads:[~2019-02-11 14:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-11 13:53 [PATCH] perf/x86/intel: Delay memory deallocation until x86_pmu_dead_cpu() zhe.he
2019-02-11 14:14 ` Greg KH [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-02-11 13:53 zhe.he
2019-02-11 14:14 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190211141409.GA31763@kroah.com \
--to=greg@kroah.com \
--cc=stable@vger.kernel.org \
--cc=zhe.he@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).