Received: by 2002:aa6:c429:0:b029:98:93ff:f56f with SMTP id g9csp3387054lkq; Mon, 23 Nov 2020 04:31:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyL7VDyf4eu+OLH1GHpkrgNubSElUFbs/LA36iM21gSxvpCRrB/y4sh+IqpQmrjEnA2ruNR X-Received: by 2002:a05:6402:1a31:: with SMTP id be17mr1499189edb.377.1606134715524; Mon, 23 Nov 2020 04:31:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606134715; cv=none; d=google.com; s=arc-20160816; b=YutOcNZ/z4eRUb42Mz0ur1MZ1d0XhKgbrWxm8r/OFLQXP1/X+0/PuR52YAmXIOKBE2 shEnVW3JCSxc23DUm07AjVG82ydwCwoxH3uZeseYTe3dqK2Jckd3oo5fpBK3TKqnZACF SBxnKuDecB6vvVXRqatZIkAsL56g5DQXJba/9txZIf/ZaPFmeSaNScqkR+5XzBQscxIQ KVKAlVma+AN4cP6S5wDLjuV22h/dPrGKs/FZgm9ZMUzF5Li3viJfmOHtZcXIC3NnXiWa wDLG5ZDoGBwi2DIc09Mw4hX7Eyn1+fxTMkY+7NTnSfJ9FSEnTc7/Pw/6Qnnnd1kwYkYl Oqwg== 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=VIwo10dDJ5Ou+LwQpRpm5JskfZFPNUlJjmlQgtCU6sY=; b=RLMiuFRZvWYOt1AM7qe3PWmrX87GaexDOv8b2eNGYkt2/qfevlofNW7e5fmyUgqyyw 5oJAeTsRJvLupA9Zh1rhIDw7Myc9j/+ez91WyRu4E+kzuxkORiKX+S1LsvpP/TslR/KQ aaMOVa/UYATgIM3eDSEnQEk4CKOS41djxxQqegmm5joKh42yF0fCzLy9mI62h3Dut998 z1RXsUSF2/2zjoLOmBBH2KB2MaP1VC2SMIKEB0Ee7iqn+tFRccjZW2Q5xcSjgkzwky82 gGRUpRTTBi3Jb6m7T2Y5ZmRmXZmJ15DZEiYlT+L+eIouEZq57ne55EmlR7Lti0qcdm+/ 3u3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E9vOlZ0r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 i23si6443782edg.60.2020.11.23.04.31.32; Mon, 23 Nov 2020 04:31:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=E9vOlZ0r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1730176AbgKWM0i (ORCPT + 99 others); Mon, 23 Nov 2020 07:26:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:36616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730161AbgKWM0g (ORCPT ); Mon, 23 Nov 2020 07:26:36 -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 F16372076E; Mon, 23 Nov 2020 12:26:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134395; bh=fGuMjDQB6aewA/ah+Bku1v2flQrg5ZmdrHoOCslK4mw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E9vOlZ0rExRx1NJEwjAxXuDdQc/2UVDAholsXhnCdWGcVLXNetXeL4aU1g3NKeUW3 x3FrY56qNf88gRMK2svmMHDOH64jaNonqkt2YwI8YCZ4XROyy22rFVuPjoFAcphhu9 W4DNt5yJycxjB0T5Sz8EAt8KkP9nQ7S8MJ/h8JcM= 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 4.9 26/47] perf lock: Dont free "lock_seq_stat" if read_count isnt zero Date: Mon, 23 Nov 2020 13:22:12 +0100 Message-Id: <20201123121806.814869489@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121805.530891002@linuxfoundation.org> References: <20201123121805.530891002@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index ce3bfb48b26f0..956b0aa916cfe 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -616,7 +616,7 @@ static int report_lock_release_event(struct perf_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; } -- 2.27.0