From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 704CBC169C4 for ; Mon, 11 Feb 2019 14:14:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C431222B8 for ; Mon, 11 Feb 2019 14:14:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kroah.com header.i=@kroah.com header.b="wjIkEzET"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="20KdL730" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726170AbfBKOOM (ORCPT ); Mon, 11 Feb 2019 09:14:12 -0500 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:49505 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbfBKOOM (ORCPT ); Mon, 11 Feb 2019 09:14:12 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id BCDD221FD3; Mon, 11 Feb 2019 09:14:11 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 11 Feb 2019 09:14:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=Y15y7lS1/IE/s78r/ZWU6lYGj0r cl/S+r/Fazm/nL04=; b=wjIkEzET/4T9ZN4w1Sit43uJxIsR4RUZLG4BA6d1UyG jCGDQe0rbIL+tGiwUwd4IN3dPHH5nU6q82+FD6hWM0m0+Sd0z2xKmLPddbNwU2HJ wCiIaq8ztcf7AqvIwU8GIHoOT7MLLO7FE2u2WvT8Hz3HqjGaPlWiuBKhTjsNMbDD +HeD9WueUZ9ky4wgX89p4beUhJoTK4jfWFrYM5sjB03UheqMoPTCNsFGqZB944mb XbwqeIS+haBZh/Fk+Y6gi35EpVunn+062wIi5860E3GhpuwNWWqhiCZVTovyPxeJ yn32QwU3n4C8Kj1F0plyIMetRuQzSlUy0byYONmlkvQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=Y15y7l S1/IE/s78r/ZWU6lYGj0rcl/S+r/Fazm/nL04=; b=20KdL730JGERw0PKcz1sLp fWlITfK1mFlmEWuGekrZKlOCQ16rhrHUrJ/QzOytDZg61cKAchINvFDGjDTAHkVV S22IdDp6066sMjABNHq4RV//i6HjB2oonatwRmAXWodzDOBXms0TLfsoQ+fhzJtk Ki2ODbFYnWLNK/3hH7108UZrNXNZcHPNeCYz6EDlem4wTse0l5VBERrG8aKcYzDs fDAfVwPnyDWFiJpIn5EFTDAxFiYwF8UCHcnWRHHRmD8SUpiaTfPBQjSJaeHrKaeL CGCgap5DZrcweUT/yaEF0cWXf1FfWlScXZeyOlSeoIl9PKLrj9hETH/031n9u66w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrleelgdeghecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucenucfjughrpeffhffvuffkfhggtggujggfsehttdertddtredvnecuhfhrohhmpe firhgvghcumffjuceoghhrvghgsehkrhhorghhrdgtohhmqeenucffohhmrghinhepkhgv rhhnvghlrdhorhhgnecukfhppeekfedrkeeirdekledruddtjeenucfrrghrrghmpehmrg hilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhmnecuvehluhhsthgvrhfuihiivgep td X-ME-Proxy: Received: from localhost (5356596b.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 9D64A10288; Mon, 11 Feb 2019 09:14:10 -0500 (EST) Date: Mon, 11 Feb 2019 15:14:09 +0100 From: Greg KH To: zhe.he@windriver.com Cc: stable@vger.kernel.org Subject: Re: [PATCH] perf/x86/intel: Delay memory deallocation until x86_pmu_dead_cpu() Message-ID: <20190211141409.GA31763@kroah.com> References: <1549893181-407670-1-git-send-email-zhe.he@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1549893181-407670-1-git-send-email-zhe.he@windriver.com> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Mon, Feb 11, 2019 at 09:53:01PM +0800, zhe.he@windriver.com wrote: > From: Peter Zijlstra > > 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 > Signed-off-by: Peter Zijlstra (Intel) # With developer hat on > Signed-off-by: Sebastian Andrzej Siewior > Signed-off-by: Peter Zijlstra (Intel) # With maintainer hat on > Cc: Alexander Shishkin > Cc: Arnaldo Carvalho de Melo > Cc: Jiri Olsa > Cc: Linus Torvalds > Cc: Peter Zijlstra > Cc: Thomas Gleixner > 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: > Fixes: a7e3ed1e47011 ("perf: Add support for supplementary event registers"). > Link: https://lkml.kernel.org/r/20181219165350.6s3jvyxbibpvlhtq@linutronix.de > Signed-off-by: Ingo Molnar > [ He Zhe: Fixes conflict caused by missing disable_counter_freeze which is > introduced since v4.20 af3bdb991a5cb. ] > Signed-off-by: He Zhe > --- > This backport is for v4.19 and v4.14. The original commit id is 602cae04c4864. Now queued up, thanks! greg k-h