From patchwork Mon Nov 23 12:21:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 330664 Delivered-To: patch@linaro.org Received: by 2002:a92:ae0b:0:0:0:0:0 with SMTP id s11csp1995386ilh; Mon, 23 Nov 2020 05:24:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXjVXDmXEEhxNEFpfcV/saDFcW7/d7UUMTAjUTizB+ACQCUjGvJr2/JPMXEMqxQ2ODD6lY X-Received: by 2002:a17:906:1646:: with SMTP id n6mr14727990ejd.89.1606137795717; Mon, 23 Nov 2020 05:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606137795; cv=none; d=google.com; s=arc-20160816; b=CzXr86tJeoNQL3/qcebL2ZdkSwGCRTnRja5Z9XO9lCwxjJCaauFhTKLPa4EPxF/lbg bXubUE/+hLb4LXzC4hCAQL6A3Nu+KAzFyzwZoEtZB/WogENcj266WWf5Hc2TwxIHZlAH 32mCASiZmZFAqItSOvR4X3N+hRin0Aw5mviSerMMKyRBm6m50tX/kJPaNYMbr/R0hOs6 x74BDr9y7jALuBBrb78JtUK8+o4lTO780X4VC7ww735kJSwFSk2JbK8nEKpCaWEO4uWs c9Li7zAI5fjVQ+AP8ib9U7rq0Ark+IWUKY/rWY7tOJNWOeHkhozjl1qMVxjOaH4AjKNc fIBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Jq/BMgzbLQ0Nc0e/9RPZvys1HzlWGbZRLYAMH9LGjEc=; b=LHYFqZGoBKVOFqiHkVKKqlUEZh+X/6Rrcbgf5dMm07WFRNtXEcSuOUvRA1N7PPfiMD 6H0kDd9yxwyIpiuVSzjfHKniJ7wDEw1kZqKXahMtPt20Va/jQoHF40l1h9YQUpx9pS1V s7qfCHJeAjo0aBqUdS78P1T879SQI2UF8ipw5Ak4RiTweifaFCL5IDxwU/wA3+1LMAn3 sw/PdFn3+GAig/FaY5TakIhWJOBLL1shvBZ/EzUMqRl8p7LGsN6kzu3uc3S9RVuOuOGk josHZADvuTarHvUpvcrzSh2eV2jfAyiJkGU8RfZQPgm6qT2ov0XHmZwSrG1jh0l3IQ9/ HTLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Iv9oHY0G; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si7179380edi.1.2020.11.23.05.23.15; Mon, 23 Nov 2020 05:23:15 -0800 (PST) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Iv9oHY0G; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388968AbgKWNWV (ORCPT + 14 others); Mon, 23 Nov 2020 08:22:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:49048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731812AbgKWMgt (ORCPT ); Mon, 23 Nov 2020 07:36:49 -0500 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 9A7992076E; Mon, 23 Nov 2020 12:36:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135009; bh=iyLc2Xp9CAtOzka8BC8tnDHk5JEE1wHkizSzbrrYD1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Iv9oHY0GiZySikqbk35nI9YRekvDBokM++gMQPrlnMSB2vtyDBGqtfth8ISHpN+rv dC4MtBEIdWphh8aQnHfZNRKlBBflhnsoRG9+GDZoorXNKQTyJ41nKpeZO6u8M8MycW U1FLCzHskq1SyhO950CqrT/YVVyhur/vY+rKe/SE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leo Yan , Jiri Olsa , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.4 072/158] perf lock: Dont free "lock_seq_stat" if read_count isnt zero Date: Mon, 23 Nov 2020 13:21:40 +0100 Message-Id: <20201123121823.412221847@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Leo Yan [ Upstream commit b0e5a05cc9e37763c7f19366d94b1a6160c755bc ] When execute command "perf lock report", it hits failure and outputs log as follows: perf: builtin-lock.c:623: report_lock_release_event: Assertion `!(seq->read_count < 0)' failed. Aborted This is an imbalance issue. The locking sequence structure "lock_seq_stat" contains the reader counter and it is used to check if the locking sequence is balance or not between acquiring and releasing. If the tool wrongly frees "lock_seq_stat" when "read_count" isn't zero, the "read_count" will be reset to zero when allocate a new structure at the next time; thus it causes the wrong counting for reader and finally results in imbalance issue. To fix this issue, if detects "read_count" is not zero (means still have read user in the locking sequence), goto the "end" tag to skip freeing structure "lock_seq_stat". Fixes: e4cef1f65061 ("perf lock: Fix state machine to recognize lock sequence") Signed-off-by: Leo Yan Acked-by: Jiri Olsa Link: https://lore.kernel.org/r/20201104094229.17509-2-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/builtin-lock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.27.0 diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 474dfd59d7eb2..d06665077dfe0 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -621,7 +621,7 @@ static int report_lock_release_event(struct evsel *evsel, case SEQ_STATE_READ_ACQUIRED: seq->read_count--; BUG_ON(seq->read_count < 0); - if (!seq->read_count) { + if (seq->read_count) { ls->nr_release++; goto end; }