From patchwork Mon Nov 23 12:22:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 330653 Delivered-To: patch@linaro.org Received: by 2002:a92:ae0b:0:0:0:0:0 with SMTP id s11csp1951563ilh; Mon, 23 Nov 2020 04:25:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjGEJ04uMu/gR8OkY3nu9V7mh61hV+VGkOjAmF2kq41Ece0OKzdWF/vfrt5nWjPil21hRc X-Received: by 2002:a17:906:2f87:: with SMTP id w7mr47130859eji.83.1606134301252; Mon, 23 Nov 2020 04:25:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606134301; cv=none; d=google.com; s=arc-20160816; b=P5vE2rU6e1md9rKHJExoiIoiLMygEQp0+LrwemxSOI5DrYguAGp8W5JnWHeNOChXpp ej6fdbcG+ceuGJo+ReGwTVnmjSjuvujs3EfYSCAe/nfhPH7Zq4y+ix4CPKf41mYYidt5 GufG9Cao5JZwTK9hSJReFEoaYHRBATqysLfmnM08j/YLgJ82HNBxIdyA/zStbF3ccIba /pRTmdU7VKWULEBCVfDPUb9MBkStrZ1nuxiYhljESE+LDlVZFF+Ghe1DU2uEA1mv4V53 mH/qqWvLUEYrsfCrMbcBX4jRdUf/Bj7F+TAsUUXuqCuLmD2YebAAUfqxUfYMkMOME8n8 2Niw== 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=FjCIVNZORHasQZZ3yEXzfIn2Ce5/vchqWpWIWHP8Gk8=; b=SXV+i3XHxYbcfoNyygfaZT1S2IVz/j01ZzUHwhCJ/3/FHnM/hr/l7W/hhz8CQe+s3L sAg7aKNLbUhTcDmBTke1ifjGnFpRasPaCrjHFJoEbWCf89aXPSoC3UKcHoyGUg8Gv2Xi g3t/t1InT7zchjKgIM0HVA8m3wZ0q0Ubpz+W8WQsENMu5jTzRfj1uaQQPiwIjwDgnlQT Ef4E7LPWcqOV1u6wMRpbSkiF5XBz7XMEyeXL/IeE/TUTNMXXEs+yYfWRc3O4rHNOCMC7 OOvMl/7t7ySEVSC7NaHBEHyXClBPdCFkpx/+uZ69R30wFKxR5faNzoc26qn5WNapRvGH 0R8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HIaLvUA9; 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 n8si6564598edv.27.2020.11.23.04.25.01; Mon, 23 Nov 2020 04:25:01 -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=HIaLvUA9; 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 S1729770AbgKWMYS (ORCPT + 14 others); Mon, 23 Nov 2020 07:24:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:33770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729771AbgKWMYP (ORCPT ); Mon, 23 Nov 2020 07:24:15 -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 64E6220728; Mon, 23 Nov 2020 12:24:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134255; bh=76l3zAfG964D45CtF8vkuHVfmhTKm31v6OXflPeosIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HIaLvUA91/MUB3jqP6tDwfqbhg9/ql/9mO8zGmia1tZFOF2pCTG9JqenNPOztLm4C 7dsdTn/WL5WOQnE3Yz7dFQKcJjd6bdUgQPkpGtJJIXEqMEXzGxI4/Py01TyC3Pslfy pv54ofW9EoUFT9mAIovfKk7Bx1LI8OU0pJ5O/BsY= 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.4 19/38] perf lock: Dont free "lock_seq_stat" if read_count isnt zero Date: Mon, 23 Nov 2020 13:22:05 +0100 Message-Id: <20201123121805.230222756@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121804.306030358@linuxfoundation.org> References: <20201123121804.306030358@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 de16aaed516e6..daf2dc0232450 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; }