Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3323200yba; Tue, 16 Apr 2019 09:03:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMOVMMWwDTFx+Fjk90ULydgCZr5srfSY1GO0WuyIQvFUKVJduq5NdFKLwIjigHfkjvITNH X-Received: by 2002:a17:902:3e5:: with SMTP id d92mr79311961pld.11.1555430619130; Tue, 16 Apr 2019 09:03:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555430619; cv=none; d=google.com; s=arc-20160816; b=lZUTyEM6CPTSXfi1sfhd9yDdAvTL8klVIPflE/31wgzCHjsM5nYAlxSjGF7ipalQMF lCCYCEkVr/nTCDR6UuyNaYvzAQsGqqqkIbJBKUViHUUoEV6lXiP0v2vAp341+14+kZ3/ EYn3CoPWL4a8QJ7wiErVwYEYp2UWtVzBCVZUA0Fkb2ldaxZ1SPjkaF5Y4CtEmRRKp8S5 6IvOzOxkaLyeucryMEXgNmq3nLIsV4I+KgrZirxvgYQEs8uMFl/n8RenZBlvHejjiT/+ 7PKDwYbxE5F5KO1vCbBI3qk2miANuBzAmm6wJ02+96RBX+HTCbpYEVTLNNkFMLnyaDwo PwSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=WtKhjdTfQlfUsMeqsmlvMSOhCwdqmo7ofqAEaaY1ZcY=; b=UixJoEv7glMcFVGKuHKNQvWa+np5m/hJIyWixB4FsVxCTk0oS1zYxeapf2ODQJByLo ttQ7OPi6ERlKjgufwKRX625DSK96v6x1JKFC6UPv9M/F1Y7E7IbEDy6Q5czT43Iwwxys IIvTB+/PNq55h1zc2Czuhi64jGolkN4615AyeJPmQDyVDuJg6y4+TTV/5i9+4JudaDdE hIq1A/I9sGvew5XR7cdaZU7bzxj19odJQI/LxxCi7HCQacmbnCzLVrp8RP8r562NKZ/2 nivb1Ch2x+bHktUGk679L2FbdBk++pO0pBZcTaNk+T1Xsu4JHkFlmZP8frJlt6VqrOxt 3Rxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x4si47897222pll.344.2019.04.16.09.03.22; Tue, 16 Apr 2019 09:03:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730034AbfDPQCC (ORCPT + 99 others); Tue, 16 Apr 2019 12:02:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36988 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729984AbfDPQCA (ORCPT ); Tue, 16 Apr 2019 12:02:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8476D307E047; Tue, 16 Apr 2019 16:02:00 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E9945D71B; Tue, 16 Apr 2019 16:01:58 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Andi Kleen , Adrian Hunter , Song Liu , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH 08/12] perf tools: Fix side band thread draining Date: Tue, 16 Apr 2019 18:01:23 +0200 Message-Id: <20190416160127.30203-9-jolsa@kernel.org> In-Reply-To: <20190416160127.30203-1-jolsa@kernel.org> References: <20190416160127.30203-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 16 Apr 2019 16:02:00 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Current perf_evlist__poll_thread code could finish without draining the data. Adding the logic that makes sure we won't finish before the drain. Fixes: 657ee5531903 ("perf evlist: Introduce side band thread") Link: http://lkml.kernel.org/n/tip-41i888xyim9n5ceyr44jb468@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/evlist.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index f2bbae38278d..4b6783ff5813 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1868,12 +1868,12 @@ static void *perf_evlist__poll_thread(void *arg) { struct perf_evlist *evlist = arg; bool draining = false; - int i; + int i, done = 0; + + while (!done) { + bool got_data = false; - while (draining || !(evlist->thread.done)) { - if (draining) - draining = false; - else if (evlist->thread.done) + if (evlist->thread.done) draining = true; if (!draining) @@ -1894,9 +1894,13 @@ static void *perf_evlist__poll_thread(void *arg) pr_warning("cannot locate proper evsel for the side band event\n"); perf_mmap__consume(map); + got_data = true; } perf_mmap__read_done(map); } + + if (draining && !got_data) + break; } return NULL; } -- 2.17.2