Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp457165ybk; Wed, 13 May 2020 04:42:50 -0700 (PDT) X-Google-Smtp-Source: APiQypJO7pL2deTQjaV+Haj/7hs1qC/4i0XNJ1XFv1XcFKo9csVIXAyNswNvBCMn4/6flBgA6JDF X-Received: by 2002:a17:906:4749:: with SMTP id j9mr15775407ejs.23.1589370170105; Wed, 13 May 2020 04:42:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589370170; cv=none; d=google.com; s=arc-20160816; b=YS5w/azi0g6rOJ5BMGF2+Sb96FTS/g94U5ULEBQ1fczMC04MsG9qwrB9/7h/ukoGUP qbmlGU0xx2ueHuY+xj+u5EQTTLYX74cKcYP66fZDbM00+nqCdJvS8cGixyv9eqZS816b fhAJq0d/lvEmvC/Tkz9eMe4xEbGClB6cvXamACxdhKdWiqftvID0bSeP1XMI2+K21BqM /iHQ+hPEf278XoyLTWPk3g3d4ZklR3lWZ5wdV4mcKPeqeOZwK/IlDzRHCF9zsDVf6Wau IC21HYNGPTHJtfLHpCE386A920m/8V0QyaCyeH2oJ5xsWmw26WdEuRnNUjDS1c1/FYOW bKQA== 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=8iykZIXI4IdeXAxO1qeWLOQ71RfoRoi6nrusDeqTAHA=; b=aq93+6xUN2UvIJYxwCCq+I3oJa2NKI6qjpvCxluCy71H+6zdu2Vr0H3wOE99Ir0ghR XX3lzMT9Ds+rL2AYZduNyX/mt4R9yPma2Xn9UduWTO8nUbW0TTfuIDL7jgfSBqIvlNlY bx15iL4FVD+j3wOnGGkCFjc8dhSaNxwGpXVecrO9yyk1VNTvpaXaOQGlUaw52qBDmoHa sPm9i5qjt3AsOASSDDeimsDvANL74q4w6RGhm5XaH53NKqwvP1N+wprivUWWO5AeSrbi Z0Ue6WA6P4CLBwV08nP0ro95b6C9DUOQrdCgicdUsIhfN0lGY1Wco6Aexpk1/Hnrb81M Kh5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eIH2EZXK; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x22si9320931eju.478.2020.05.13.04.42.26; Wed, 13 May 2020 04:42: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=@redhat.com header.s=mimecast20190719 header.b=eIH2EZXK; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730892AbgEMLju (ORCPT + 99 others); Wed, 13 May 2020 07:39:50 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:25555 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727794AbgEMLju (ORCPT ); Wed, 13 May 2020 07:39:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589369988; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8iykZIXI4IdeXAxO1qeWLOQ71RfoRoi6nrusDeqTAHA=; b=eIH2EZXKC6tGzYiFF20bTgvt3ll/LOIH0hVE1ISxkY7fx5/irJolcJVh+0GQ/K4DjY44Fc C0Is4Hw1fw21KM5pL0I0+AyL1XYQWE6NZWhZn2Mo+BiEDKVNy+oWW3/BjDLI8rw59LsQih X0CIAkYQZE21S5l05BAnMj5ZRYyas1k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-437-5QuVWD6CMLuBDbs3J0yzuA-1; Wed, 13 May 2020 07:39:47 -0400 X-MC-Unique: 5QuVWD6CMLuBDbs3J0yzuA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6A976835B41; Wed, 13 May 2020 11:39:45 +0000 (UTC) Received: from krava (unknown [10.40.195.109]) by smtp.corp.redhat.com (Postfix) with SMTP id 33A885D9C5; Wed, 13 May 2020 11:39:42 +0000 (UTC) Date: Wed, 13 May 2020 13:39:41 +0200 From: Jiri Olsa To: Anand K Mistry Cc: linux-perf-users@vger.kernel.org, Alexander Shishkin , Arnaldo Carvalho de Melo , 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: <20200513113941.GK3158213@krava> References: <20200508145624.1.I4d7421c6bbb1f83ea58419082481082e19097841@changeid> <20200513122012.v3.1.I4d7421c6bbb1f83ea58419082481082e19097841@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200513122012.v3.1.I4d7421c6bbb1f83ea58419082481082e19097841@changeid> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, jirka