Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp553562ybk; Wed, 13 May 2020 07:05:50 -0700 (PDT) X-Google-Smtp-Source: APiQypKfO5cZNOh5NflbeUhNNACgMLH7wmn+bVcP5FeD3VsyVwK9Nek054KvrzxxqeYFrmC8QJIg X-Received: by 2002:a17:906:7c42:: with SMTP id g2mr22896699ejp.328.1589378750505; Wed, 13 May 2020 07:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589378750; cv=none; d=google.com; s=arc-20160816; b=1Jw3HXSIGGZpvXgDM5mPI01dn5DY+ML0ifZkRYlgoeilnO+lCkYYn9qZiNeC97GO1o Fo0qyc39cgjXSBVAM1jFwm4W0AMqkkfGhCtEi1x3QOGx0SbdCOPWArM00z9yanCkLJ+x dAy6AabkMuzNxDFMndK81io/NyBuissys18riCHUmsunjCMfJSt/If5MwxMF1oLIdYTj nI4wfgw0siGX7mXc3B9yaNBWlBGXKSXYG6fOQALR4nX/wbxRFuNo2XdHP7UWnUpU0JY9 tSduR26o2d+MrG7x7BqnoyyWAYc4toXiGAfpdERAYlJ75Uh+ycQ516HDtZUx0hjXPE/9 NqHQ== 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:date:from :dkim-signature; bh=3G6NbBH687PhEorC78hABjQaW3UsFMQBwTyJIw1H2/I=; b=ybCpT+on4HJnMJiXX+ArkUn2d8P+KnYFHfzLieBFNFX2sA+YQbI0CWd8sFBXq8msj4 9Ug9vxd7bMlXBDkaEEMM/uGCYojMEi4WgeKoo90JOnvTTCAbJ3Vy3vRAEghxh/bom4ld yTTsAj2Q8S9lJWV1jaSci2E2aQWBOq9FaVk/uqvG1E8j3smiDCixI9uwz+uCEbJEo+Gz YO8tU1MFZQ9I6rI8et1vl6piWXkxtdwKfPk1A+PUP5Ru2/fyt3Lr0Gw2PfSqo8niXk0v VCwatJ2sySPgNbrtNCOK64gABC+q9SdZT9jM+NkhwHoGAf6rayBO28uvtYw6YcCwWEwv a4mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="SH57vh/s"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a16si5546660ejs.58.2020.05.13.07.05.26; Wed, 13 May 2020 07:05:50 -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=@gmail.com header.s=20161025 header.b="SH57vh/s"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388889AbgEMODS (ORCPT + 99 others); Wed, 13 May 2020 10:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388667AbgEMODO (ORCPT ); Wed, 13 May 2020 10:03:14 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53D06C061A0C; Wed, 13 May 2020 07:03:13 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id i68so14212775qtb.5; Wed, 13 May 2020 07:03:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3G6NbBH687PhEorC78hABjQaW3UsFMQBwTyJIw1H2/I=; b=SH57vh/sOIcptFApDczlfojRaN6agT0pZE3ZV9iMvKl8bM7q23eLJ8uMJBceitk6li Lh6vjsAB4mMkuXFPcptqbCUVIDeEPxfgziOZeDkkzQtxhcoMnp1GeeWlm5wP+iqMYT7E xDYj+Pim7kC7nnybV/fyXpqG3dKFluKiQViguzHrH8SRwfavN1m1KclS5T1u81yLNMCS eM1LtG24h+Fk5oul+xeCekaxzqdBx0VvUE8idtLs/wGibvypKjUI88QZqzHEUqb0xjhA IboDfMAJ8hixQ1MIdrDrUICySE6Ui2sE144r2/pdz4Ep5ceYy6Uiq18riYiPDBsOayTb Ahdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3G6NbBH687PhEorC78hABjQaW3UsFMQBwTyJIw1H2/I=; b=p1BoLz6JsEmmu+uDilcYvr8II2TjGfqUqdQvGq2fyxKiwoKRhsSRHPuL6aj5eoS1pz ipGNiACyBOikaj1EqJsV6IePrB6xkWjxaYfAN73WHHahdrZikHU4SOz1CFxZ7ZN42120 AM1qC4FXYuIXUxNcKtl9xmoxC2ImEGf4XskSF1F1f0pStka/DDFS/1bGSIQs5I8MtH+3 ROU8DZhSf26DE2D5mh1wzplyzpWan4qYQ5FiD8HYuuDp2z563l3qI+Zz59qKwFyAuk3U HNYMR071ub0p3Gl8adjU26uIqDojruh+gh26rWAGoT9MT60JQlYkuqqWSthVodPoaX+y WaAQ== X-Gm-Message-State: AGi0PuYtIWkoIGhjETXHbL+r+chdxGV9HMroZzXIB3AtD0TrJQgoYOsY Tac5RaPsTh1k4pHxHxAgelg= X-Received: by 2002:ac8:544e:: with SMTP id d14mr28416241qtq.283.1589378592497; Wed, 13 May 2020 07:03:12 -0700 (PDT) Received: from quaco.ghostprotocols.net ([179.97.37.151]) by smtp.gmail.com with ESMTPSA id s125sm13898384qkh.51.2020.05.13.07.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 07:03:11 -0700 (PDT) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 9BD6D40AFD; Wed, 13 May 2020 11:03:08 -0300 (-03) Date: Wed, 13 May 2020 11:03:08 -0300 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: <20200513140308.GF5583@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 Thanks, applied. - Arnaldo