Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2438915imm; Mon, 28 May 2018 08:06:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoRrRqpCKGDn96pFE1Qu8ASJTwfTb2JZLLR2/8HHxMS8K+eUQnrYNh10MIdmrcK5Y96eAeX X-Received: by 2002:a17:902:43:: with SMTP id 61-v6mr14221040pla.112.1527520002034; Mon, 28 May 2018 08:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527520002; cv=none; d=google.com; s=arc-20160816; b=OMTaAnNs066vR2AcqZHafWGl9YUuTCQ7Dd4sg1aiF8Dx+qFnUSMRS753rjlCceu8jB yLdtPAFSVYYzTiqT/jLpceZqur6VNpCE1sRsf2fPaZ1YyPOhWA13yEK5kKhnG5Sel7za dwujN89IhDCF8e7YtvyJ8eeE1NTv07R54IU+mxAgXs09W3M/fC9cu3PXcSx7z4r/bvN1 j6MapGg/job2TnHtdMxK/rmoMXiBzsdmNbRffm21lhxaJg7kS0eY+aOEsytpCSZZxYb2 2z9cX2jcfJA93cA4tuatKlQhmEJlBTWN7ik2FPV+zfh1Uu3EuFPnFibcQvjW8PVHEQ+c QnMQ== 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 :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=s2pggWUxSvGJjzcFG1eAzIc1TcqIyqELQi2q205teZw=; b=m+MtqNrDJrxpCor2e8WaiKwOAkksLyx7U/KRK4U430FpL1xGJsfE4pAWVRYGGzFK4d wIF/EVz/A7y6Cobel37oX9EKDUlQje2pBO0BH57DyBSYI3MYanEjShMxPapIoJfP69qE Z13Sy12ePT7cswZ1YAZUTVD5XdH62xkD2OxsPEXSU0pkrI5pHpdq4pJfVDRzqBnB7kos GBnUDZqIgK+dzpbH+TCJxZ7rJLVRQ6JyeH94d/kCXo87JBF39Jgy17+hrUWxhCLRti2y /peRLhtgRW202x5lPaR4AFnjsLyrgctVGJzzq1rN06IOZIDBR2Mp2dWfRE2QLl8y2a2C TLiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XfKLUmkp; 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 q6-v6si4971755plr.134.2018.05.28.08.06.27; Mon, 28 May 2018 08:06:41 -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=XfKLUmkp; 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 S939564AbeE1PFw (ORCPT + 99 others); Mon, 28 May 2018 11:05:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:44452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033929AbeE1KZI (ORCPT ); Mon, 28 May 2018 06:25:08 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 89E9C20883; Mon, 28 May 2018 10:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527503108; bh=lgPR+Hea8IjHqtU57i+1S5nz7mUvqtcnvxX8iajdXuQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XfKLUmkpwnIvDOkHpHXLkBBAGwymqdnlE5+xk6XF+6IovqjdQ9Dz6WWhYNIPY/R7A xtBsaaV8oGPdYUeTabfSo2jyTf0jwqCOZWTASf1l5vq4ufyOicExzlN2WjQmxXUGIH Em4RPk1dNweCW6F7tVyeNo0LVa5G+lGf4Uu3ydBA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Alexander Shishkin , Arnaldo Carvalho de Melo , Jiri Olsa , Linus Torvalds , Stephane Eranian , Thomas Gleixner , Vince Weaver , Ingo Molnar , Sasha Levin Subject: [PATCH 4.4 218/268] perf/core: Fix perf_output_read_group() Date: Mon, 28 May 2018 12:03:12 +0200 Message-Id: <20180528100226.962117774@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Peter Zijlstra [ Upstream commit 9e5b127d6f33468143d90c8a45ca12410e4c3fa7 ] Mark reported his arm64 perf fuzzer runs sometimes splat like: armv8pmu_read_counter+0x1e8/0x2d8 armpmu_event_update+0x8c/0x188 armpmu_read+0xc/0x18 perf_output_read+0x550/0x11e8 perf_event_read_event+0x1d0/0x248 perf_event_exit_task+0x468/0xbb8 do_exit+0x690/0x1310 do_group_exit+0xd0/0x2b0 get_signal+0x2e8/0x17a8 do_signal+0x144/0x4f8 do_notify_resume+0x148/0x1e8 work_pending+0x8/0x14 which asserts that we only call pmu::read() on ACTIVE events. The above callchain does: perf_event_exit_task() perf_event_exit_task_context() task_ctx_sched_out() // INACTIVE perf_event_exit_event() perf_event_set_state(EXIT) // EXIT sync_child_event() perf_event_read_event() perf_output_read() perf_output_read_group() leader->pmu->read() Which results in doing a pmu::read() on an !ACTIVE event. I _think_ this is 'new' since we added attr.inherit_stat, which added the perf_event_read_event() to the exit path, without that perf_event_read_output() would only trigger from samples and for @event to trigger a sample, it's leader _must_ be ACTIVE too. Still, adding this check makes it consistent with the @sub case for the siblings. Reported-and-Tested-by: Mark Rutland Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- kernel/events/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -5299,7 +5299,8 @@ static void perf_output_read_group(struc if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) values[n++] = running; - if (leader != event) + if ((leader != event) && + (leader->state == PERF_EVENT_STATE_ACTIVE)) leader->pmu->read(leader); values[n++] = perf_event_count(leader);