Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp660230ybk; Wed, 20 May 2020 08:49:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnVuFamjmJvvi8i0kV+CVKBtRb/FOv94tfIHX1Cy5v+zZKdtWTEx06K55TPQBMb66kRJKS X-Received: by 2002:a17:906:5a99:: with SMTP id l25mr4008909ejq.235.1589989740544; Wed, 20 May 2020 08:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589989740; cv=none; d=google.com; s=arc-20160816; b=MrdK+AlIJjObfFrSLhWev5JP3P1o0hOoTVBEmr9WgLFblPSygYDAYNa1w//sA1+zsx XA3/Cm9JQW9SAKC0K/mv5opjOExywSQ3nqgFjM7HXkpGSN9XIG5Iq2h1wibeYAIpip4x /9N/mr+/Fx9nqQb3NSYWQ9HXQB76i2yzJleOiXQH1+ocw1gZCQflCjcXfahGti+Z71ht lGgPj+Ea03em2P3fFmRqdjH2GbaFdjf3YpGGR3E9jgQZ5VlRksWwO0BzJBgIlX9mLjDS OqgaBeFbgg7/uMUgkqhHNw0LwfUo+OlmU7OaTNYkfsUiGiNvgKmPQQegJjmoGZIb1+DP btyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=5cKNIu6oLiU5NZjBODWmidd0+T22/YRkfKPPSDWEm6c=; b=jV5My3RVr1Ta2Ag09+efQ51kOTg/9CyQZ+x1loknA4/dvm5PZUE4ssYNpxjQaPcelt rnM6x0cxcu4Op4foUdjGqnTzasZbw0yfQe/NbtDIiCC78Mvy0GfbC3Lq8SH7uyEkwUXn P1wTF8Ldib1nOdTgbmk9lo2WRZNLaob7MTagjSEwr1ca+OvMSqoDs/HdJef0+KzWdcvJ AqyyXbA7RY/oh+bOh4UsMHlSbg8rRmMcNdgweAqLnvkhUOFoHbcLeCJYjHgFOM+WOsv4 13t0PtyYWIPlSlIaLlGz6z6N8ktpY0BncjVvafB5ATseQ9CVQPe5yg/mJkgHBNgAFmZz 84nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s80+r20f; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l24si1651146edr.396.2020.05.20.08.48.33; Wed, 20 May 2020 08:49:00 -0700 (PDT) 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=@kernel.org header.s=default header.b=s80+r20f; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726831AbgETPrH (ORCPT + 99 others); Wed, 20 May 2020 11:47:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:36498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726691AbgETPrH (ORCPT ); Wed, 20 May 2020 11:47:07 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (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 6475B20709; Wed, 20 May 2020 15:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589989626; bh=RVEMDBCL04OQbznOldT6yF83HEYpiWi2l9Yt3I18qsg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=s80+r20fIdm93fdte+1ohs1iI2BcmvV8lU7OlyjUdKYXjiei3d/nA/GKeWKRHX/fn NQq13l+KZplmz5yTVPqQFEkFKgZpU8UrQp4MttuKQcU9m1S4nKNhxhJ7RURQMs2KQ3 ZWecSKBFX6UjyVd1wozIvKPGemuRC2zzWH8NWDD8= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 50B9C40AFD; Wed, 20 May 2020 12:47:04 -0300 (-03) Date: Wed, 20 May 2020 12:47:04 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: Anand K Mistry , linux-perf-users@vger.kernel.org, Alexander Shishkin , Ingo Molnar , Mark Rutland , Namhyung Kim , Peter Zijlstra , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] perf record: Use an eventfd to wakeup when done Message-ID: <20200520154704.GL32678@kernel.org> References: <20200508145624.1.I4d7421c6bbb1f83ea58419082481082e19097841@changeid> <20200513122012.v3.1.I4d7421c6bbb1f83ea58419082481082e19097841@changeid> <20200513113941.GK3158213@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200513113941.GK3158213@krava> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, May 13, 2020 at 01:39:41PM +0200, Jiri Olsa escreveu: > On Wed, May 13, 2020 at 12:20:23PM +1000, Anand K Mistry wrote: > > The setting and checking of 'done' contains a rare race where the signal > > handler setting 'done' is run after checking to break the loop, but > > before waiting in evlist__poll(). In this case, the main loop won't wake > > up until either another signal is sent, or the perf data fd causes a > > wake up. > > > > The following simple script can trigger this condition (but you might > > need to run it for several hours): > > for ((i = 0; i >= 0; i++)) ; do > > echo "Loop $i" > > delay=$(echo "scale=4; 0.1 * $RANDOM/32768" | bc) > > ./perf record -- sleep 30000000 >/dev/null& > > pid=$! > > sleep $delay > > kill -TERM $pid > > echo "PID $pid" > > wait $pid > > done > > > > At some point, the loop will stall. Adding logging, even though perf has > > received the SIGTERM and set 'done = 1', perf will remain sleeping until > > a second signal is sent. > > > > Signed-off-by: Anand K Mistry > > > > --- > > > > Changes in v3: > > - Move done_fd creation to below session initialisation > > - Close done_fd on exit > > - Log errno when write(done_fd) fails > > Acked-by: Jiri Olsa I've made this dependent on HAVE_EVENTFD_SUPPORT, so that it continues building on older systems, - Arnaldo