Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1237408pxu; Mon, 23 Nov 2020 15:35:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFrd7jFYeJ2jczvoPb6vLJhTbEPOX4inqaLHPoi+UUrIORkllO5Cjj9LmagPUWGVH6wOYv X-Received: by 2002:a17:906:2452:: with SMTP id a18mr1837421ejb.66.1606174506645; Mon, 23 Nov 2020 15:35:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606174506; cv=none; d=google.com; s=arc-20160816; b=Xmb7QZNuTzywBKYw8Byq+NmVo8UqoZ0LRoxry61BtQgKpRqryQLlXcZaPQFh1IjT4y wrzbLu4NgRfeJbaVJuroG2lgDZRDGOY0D94m0w8IlgsPjasgtN5jZqQjFmnu+URY8UFb 9L9hkMvhsOX6dXnvmdf4XxLfDUHVI6b0xcMGfgJ75L2rprt3AYGsg/iF76YsRdunsxyc iN3te5AcqWpHZfSKo/8MBEbtcPW/VXy3djG4LsWfK5IxcG9T7WCoxAIcO3zSFjnSEIZ3 qP+T9Aj4nW3NQxDSmjoGWSyxBcYmLg3uXRs7cOO9W10fbsHHI8gGHb8W2hFuz/xwBAfF Aiuw== 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=uqjTUFYmHyEu2Fr5tl+gHe628iCiZZcNkQ1Sxc2stfE=; b=IdZB/6THnty3xemW3jzOUi9krsV4k7UHepAol4gMuCMNUc3gzqH1b0ESKpOd1p/Rne oHHKFwhVFnbb4k0D1D+ltJqULbyNBcpOOB+7YZuvEEgWYAF8ddEPwv2d4lFE/AHXQjdt uGFsyKY2iKBKzKtmTo+0mjtR11zNWSy7C1QfTfKOcw4MEm3qM4oba4esyE/cFOucAi2w C2xOSN8zBtoRIrhGk4p3lQEutBIsHs3Tb0rKBwl0B2EEhRrwZF/27Cr2sE54ZZOQBddo D+4Lfbg6obf8I5OmUuOBBLZkoaNYGJ6wOpe/8nUfWANos8YVK+JoUFjh6HZUcZrucFy0 73VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="TNgW3y4/"; 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 s15si7699283edj.165.2020.11.23.15.34.44; Mon, 23 Nov 2020 15:35:06 -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="TNgW3y4/"; 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 S1730120AbgKWMbu (ORCPT + 99 others); Mon, 23 Nov 2020 07:31:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:42222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730847AbgKWMbZ (ORCPT ); Mon, 23 Nov 2020 07:31:25 -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 72BB92076E; Mon, 23 Nov 2020 12:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134685; bh=m+6Ivt4YjbhoMgnnjH0z+omp/8njCcODphmrNNh/EGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TNgW3y4/OS+DAzAiYdVkl/T+u2NC72rCOEWM07xaiLbNWpalg3jgAkAN3/h6SoTch kKSxToopOKRDJiqAM2tcofHo9lWWzQ+kwUONMIT6/IlJWkATH1Bdlsx8F10ivLhi8l rwl42dPkrae9CP+4nNElmoAs8VSAA1QcD78O4Fk4= 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.19 46/91] perf lock: Dont free "lock_seq_stat" if read_count isnt zero Date: Mon, 23 Nov 2020 13:22:06 +0100 Message-Id: <20201123121811.555738702@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121809.285416732@linuxfoundation.org> References: <20201123121809.285416732@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 6e0189df2b3ba..0cb7f7b731fb0 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -620,7 +620,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