Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3739506imu; Tue, 18 Dec 2018 03:27:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vc13M4Vtc/D+RYHtDoW1C9k+5jxkKAGiYnGSVIgijBsHEiFzKKyEB49YW6OoVjoxAqkG8g X-Received: by 2002:a63:4342:: with SMTP id q63mr15435110pga.63.1545132446712; Tue, 18 Dec 2018 03:27:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545132446; cv=none; d=google.com; s=arc-20160816; b=QtsYz3bPXLAps79TJaW190chHHhhCc6a5eNA55fLFBM15WiUpRXwVULin22aIVxa0T hQ2StJtXnbYzDXMCJOsXVaupNN7aIKX+vAvcApxtZC1kJDxpbsMrgRGddFfeCEY3CdGz J7uOTFmYTVucW3pog5R4ONEKElmsoVinkXTxffqrwMNMj/lMWRLBjZkTVus+L4ZcVTYE z4rBEWQQ8Et0ivftmxMqv0j7ULNYLnJ5E9M2I+8hGeOFUsBt7Y9eFxJXD/YQCSCKdGlQ DJUnqbOw5PBAE9sAX/Z5Jr6YWPbl6dYJmPKJZhzBjF0zuxx065ysquytzQKgfXPuAEV+ z7ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=kwnDNLgUG4XAM8hKqtjo55bZPjB2C2RhyL7yZN1Q310=; b=j6tdGAzvriBeyLVFYFxX4hbYOkSJ1dI4A6VbufeV683559kHljhNHfgxHm03Wf7aSH zARc+wYJRgmd5f0PeYyhzAioBYbzMbxXiM+sNJNIpnuIm34OgLS+O5RvHvry1n092gco 8k4LxXNylHqg8d2wwf1MBWknWgf0ZF/hHV/6qlgC71t+1AR3cm3ax2QJ6NAr/HPd7Nsb Rb5CS6VShnuAtwUk6qXi/UbRH4mMN329u7pPWB3sAwQkiU5MNmHbocsl+hl8qDHtv1qe LvvlVWzW+QtQld67n6XvJLmx47MAtzqPFioYSBIPGY8F11nLOPlqoX/XV2Dr70RsoSDh s3DQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t136si11298244pfc.262.2018.12.18.03.27.10; Tue, 18 Dec 2018 03:27:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726556AbeLRLZu (ORCPT + 99 others); Tue, 18 Dec 2018 06:25:50 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:55661 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726421AbeLRLZu (ORCPT ); Tue, 18 Dec 2018 06:25:50 -0500 Received: from [5.158.153.52] (helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1gZDVB-0007TC-TC; Tue, 18 Dec 2018 12:25:30 +0100 Date: Tue, 18 Dec 2018 12:25:23 +0100 (CET) From: Thomas Gleixner To: Peter Zijlstra cc: zhe.he@windriver.com, acme@kernel.org, ak@linux.intel.com, alexander.shishkin@linux.intel.com, bp@alien8.de, hpa@zytor.com, jolsa@kernel.org, jolsa@redhat.com, kan.liang@linux.intel.com, mingo@redhat.com, namhyung@kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org Subject: Re: [PATCH] perf/x86/intel: Avoid unnecessary reallocations of memory allocated in cpu hotplug prepare state In-Reply-To: <20181218110209.GD15430@hirez.programming.kicks-ass.net> Message-ID: References: <1545129033-21757-1-git-send-email-zhe.he@windriver.com> <20181218110209.GD15430@hirez.programming.kicks-ass.net> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 18 Dec 2018, Peter Zijlstra wrote: > On Tue, Dec 18, 2018 at 06:30:33PM +0800, zhe.he@windriver.com wrote: > > Besides, in preempt-rt full mode, the freeing can happen in atomic context and > > thus cause the following BUG. > > Hurm, I though we fixed all those long ago.. Either we missed that one or it came back somehow. > And no, the patch is horrible; that's what we have things like > x86_pmu::cpu_dead() for. Like the below? Thanks, tglx 8<------------ --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3559,6 +3559,14 @@ static void free_excl_cntrs(int cpu) static void intel_pmu_cpu_dying(int cpu) { + fini_debug_store_on_cpu(cpu); + + if (x86_pmu.counter_freezing) + disable_counter_freeze(); +} + +static void intel_pmu_cpu_dead(int cpu) +{ struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu); struct intel_shared_regs *pc; @@ -3570,11 +3578,6 @@ static void intel_pmu_cpu_dying(int cpu) } free_excl_cntrs(cpu); - - fini_debug_store_on_cpu(cpu); - - if (x86_pmu.counter_freezing) - disable_counter_freeze(); } static void intel_pmu_sched_task(struct perf_event_context *ctx, @@ -3663,6 +3666,7 @@ static __initconst const struct x86_pmu .cpu_prepare = intel_pmu_cpu_prepare, .cpu_starting = intel_pmu_cpu_starting, .cpu_dying = intel_pmu_cpu_dying, + .cpu_dead = intel_pmu_cpu_dead, }; static struct attribute *intel_pmu_attrs[]; @@ -3703,6 +3707,7 @@ static __initconst const struct x86_pmu .cpu_prepare = intel_pmu_cpu_prepare, .cpu_starting = intel_pmu_cpu_starting, .cpu_dying = intel_pmu_cpu_dying, + .cpu_dead = intel_pmu_cpu_dead, .guest_get_msrs = intel_guest_get_msrs, .sched_task = intel_pmu_sched_task, };