Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2787334ybg; Mon, 28 Oct 2019 02:21:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqz53v9VVgYPmSQtDmYl0hDMEl11EZdj3n7rWVmjmEyDm3U8hvXnPIioXxZRe5os819sVOkS X-Received: by 2002:aa7:c942:: with SMTP id h2mr19189854edt.238.1572254496808; Mon, 28 Oct 2019 02:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572254496; cv=none; d=google.com; s=arc-20160816; b=huQShnypf1YxXHuXufCSY+HYVoCQ9jqbpxdsHD89SKFGPqaBiJP3WN6s3hT7X0AzR1 eyILIhjM7XUgeh/MJ4hrcuvocDcNIenDDXrE2/s0058zg3YSuyhXfNYvdc1JEsPFhRGS moPVOzIZfxiLefb3xCHvyAfTL+lT9OuQ5mwEXCxMG6YmuUx45AzqknAAzGVh1dfXRzEt a7uN9yNBSOSLilUDmy44bY7LUlFWNsZhUNmlf6LSyGlwsogyKQ39uBi8GP01r1T2lJYr iXzbZjn1M/9DPrTtwRFOmzDRMj9PmwS5GR2tDihEaiNp71s4d7zvWtoXNpnj0/h9seZn jPmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zRBbpyvwLfS9ESCkaG6qnxIJGlzb4AKnu7ZAN0a0nAQ=; b=hnZ2g2dg8e6fptQKHX0OThHg/3AVxWEdqOM8/qUZd9nUzv+Fix76PMnqJnxH6niQEl RiS+BEoQ0Zye/DoGv2pF1d/uG4aTFN/wUNe4Oa17+Zsoikauf+5QoJtNY80gqaam1Z0A ufHS1yX0n5GP3+vOsvZfSUjk211nI2HozLPngDNClHVMcSdfUC0GUF/Ii6o92UfJBDCA gcc3673ALBSK0Q3SmpVPBpBSyUc0Rt1yRQOc1gonmh0hGSLWKD+WcQUKyGyj6nV6WHxw kcOyeKumvyVfEVgaj1Vv3Phq25A+UBxuh7zZz5DtxjrSJJ5DNGKibYAvPyXnkESrl+Gm f8Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UFnxUj3e; 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 e8si3390219edk.444.2019.10.28.02.21.13; Mon, 28 Oct 2019 02:21:36 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=UFnxUj3e; 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 S1732625AbfJ0VY5 (ORCPT + 99 others); Sun, 27 Oct 2019 17:24:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:46586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732607AbfJ0VYz (ORCPT ); Sun, 27 Oct 2019 17:24:55 -0400 Received: from localhost (100.50.158.77.rev.sfr.net [77.158.50.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 799552064A; Sun, 27 Oct 2019 21:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572211495; bh=q5B/yQeXzBm8k6uC+pLPwwWwKzsG+wyhHgoE4s85yVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UFnxUj3eo7mAQPC4Fo52wfV6CAoq2QWheq7Lwn40zA+ryunmBZW7tO4QX0mPciPHA OYsy3lCNNEO5Qm9izWc5M5l/cC2bekyrzl4s8GQxTq2RH/ddtSRCAVaeSjsS9DoOzV ai/hbtqYH+WxukadvTGKEHB4wThG5sXKarw62Djw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Shishkin , Arnaldo Carvalho de Melo , Jiri Olsa , Linus Torvalds , Peter Zijlstra , Peter Zijlstra , Stephane Eranian , Thomas Gleixner , Vince Weaver , Ingo Molnar Subject: [PATCH 5.3 170/197] perf/aux: Fix AUX output stopping Date: Sun, 27 Oct 2019 22:01:28 +0100 Message-Id: <20191027203403.772778913@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203351.684916567@linuxfoundation.org> References: <20191027203351.684916567@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Shishkin commit f3a519e4add93b7b31a6616f0b09635ff2e6a159 upstream. Commit: 8a58ddae2379 ("perf/core: Fix exclusive events' grouping") allows CAP_EXCLUSIVE events to be grouped with other events. Since all of those also happen to be AUX events (which is not the case the other way around, because arch/s390), this changes the rules for stopping the output: the AUX event may not be on its PMU's context any more, if it's grouped with a HW event, in which case it will be on that HW event's context instead. If that's the case, munmap() of the AUX buffer can't find and stop the AUX event, potentially leaving the last reference with the atomic context, which will then end up freeing the AUX buffer. This will then trip warnings: Fix this by using the context's PMU context when looking for events to stop, instead of the event's PMU context. Signed-off-by: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20191022073940.61814-1-alexander.shishkin@linux.intel.com Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -6839,7 +6839,7 @@ static void __perf_event_output_stop(str static int __perf_pmu_output_stop(void *info) { struct perf_event *event = info; - struct pmu *pmu = event->pmu; + struct pmu *pmu = event->ctx->pmu; struct perf_cpu_context *cpuctx = this_cpu_ptr(pmu->pmu_cpu_context); struct remote_output ro = { .rb = event->rb,