From patchwork Tue Sep 1 15:10:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 310502 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=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT 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 DA3DAC433E2 for ; Tue, 1 Sep 2020 15:32:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9CFB20E65 for ; Tue, 1 Sep 2020 15:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974365; bh=qIzc2g0EcLYoSanPApIcHyJK6rhR/iYiqcR/MpPeHDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=e82vGrF+94jDKNLPF0lQ0lW3vxole3U2gjycoPD/D6Q6RF7QL0PMUjmU5YbfxLd2Z jtIlgsEqXnJYCPV4ljqHxJH9Q2mQj5omVqwL+uEjaXBn2kTIf+hKUELC8vDf1TjfjA QC/nixPstS7txq3qeIwKjlnTEYZa0r/8lInwoyuY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731108AbgIAPcn (ORCPT ); Tue, 1 Sep 2020 11:32:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:36394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728009AbgIAPcm (ORCPT ); Tue, 1 Sep 2020 11:32:42 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 6F52220866; Tue, 1 Sep 2020 15:32:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974361; bh=qIzc2g0EcLYoSanPApIcHyJK6rhR/iYiqcR/MpPeHDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AuUuHZXGydmK+gNtCuOJ7IkMhi7JwgOCDEgt+t1kiSn6ZAAuQKlDewegv5nhNRIQ4 I+Ln4gtR6j7HH+D8WEHe2ET/vx4dv1lvnAcpPT3FCv3CEKCu43QJcMQJ1ce9Pf4E3d UbrjZJHqlSdzN4tWI9eq31aU3zsJxvXSsUX+m6/w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Kardashevskiy , Athira Rajeev , Michael Ellerman , Sasha Levin Subject: [PATCH 5.4 146/214] powerpc/perf: Fix soft lockups due to missed interrupt accounting Date: Tue, 1 Sep 2020 17:10:26 +0200 Message-Id: <20200901150959.973024097@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150952.963606936@linuxfoundation.org> References: <20200901150952.963606936@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Athira Rajeev [ Upstream commit 17899eaf88d689529b866371344c8f269ba79b5f ] Performance monitor interrupt handler checks if any counter has overflown and calls record_and_restart() in core-book3s which invokes perf_event_overflow() to record the sample information. Apart from creating sample, perf_event_overflow() also does the interrupt and period checks via perf_event_account_interrupt(). Currently we record information only if the SIAR (Sampled Instruction Address Register) valid bit is set (using siar_valid() check) and hence the interrupt check. But it is possible that we do sampling for some events that are not generating valid SIAR, and hence there is no chance to disable the event if interrupts are more than max_samples_per_tick. This leads to soft lockup. Fix this by adding perf_event_account_interrupt() in the invalid SIAR code path for a sampling event. ie if SIAR is invalid, just do interrupt check and don't record the sample information. Reported-by: Alexey Kardashevskiy Signed-off-by: Athira Rajeev Tested-by: Alexey Kardashevskiy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/1596717992-7321-1-git-send-email-atrajeev@linux.vnet.ibm.com Signed-off-by: Sasha Levin --- arch/powerpc/perf/core-book3s.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c index ca92e01d0bd1b..e32f7700303bc 100644 --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c @@ -2106,6 +2106,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val, if (perf_event_overflow(event, &data, regs)) power_pmu_stop(event, 0); + } else if (period) { + /* Account for interrupt in case of invalid SIAR */ + if (perf_event_account_interrupt(event)) + power_pmu_stop(event, 0); } }