Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp196989lqj; Wed, 10 Apr 2024 08:01:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXuYTqvAln6Plo/Dq+V5gw6Fv0zxGPTT6OtLdA/wqPBNNUmpnD9HNw7tvoI0NITMvVgap3alpX0e7GjrTHDA+0oCf7oT2GchPv1aeR/SQ== X-Google-Smtp-Source: AGHT+IG2m13R32ZUjdry1xbMm8lnKY69CRHKMiGBjffd+h7SOcfyQHWIMImQaDghwRVcz862DhTL X-Received: by 2002:a17:906:c796:b0:a51:fd99:8759 with SMTP id cw22-20020a170906c79600b00a51fd998759mr2161577ejb.45.1712761301282; Wed, 10 Apr 2024 08:01:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712761301; cv=pass; d=google.com; s=arc-20160816; b=YtVVaYjhlYUPOBTZAyKXCSGCmuYuY4RKzukQArYqXVDyQYZRfEyWOoRMy6m6xd+gat qUOtIQD4GXmNvgR7wHxzr28QXBJZYoPrx1DujwiAa3c+hKVgSGtynF+18sxmVufbQf4k nOLLMyqWkb2XjLMNV0VmCw8DXFZw8fxvS5MVPb7wZvPX6PDBN2KSJUER2gkERlffO2HZ VK3RO/6z/TevoEMdb+UY1j7LbYWp1/3Arj40kYmn56ruGrto66eoPwcNSDSiBPjiZtfX wL/y6n2sRfgYx/nL8l/JPKUcf/jd6C17wBXC+yM5beKjxyubJmU4y3hSf51bGdnHrdIk X+mQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=auOpaEGkIvNWeEsni+MmnZZ4zDr/oQKixOdPaDdn7cA=; fh=tWedduKdZfmc5x5dPveXf04NtuTwlscpi5X/WE4lpxw=; b=j0Baez5ruI9kG76ciaLY5cvkxex8+4tbA60cZds7fPla5MTzHmYn2REG99YOmt90M1 DhpHtCcJ7yqLLvWaGN0SKdoxcv8bNvg2fTXKe9BIs2lHhvqDSLjHgDtpAighLQq5Ag8+ 2UdsXzjuliorhJQbA1myJ/Igm1nlA62z7DdGE/W9Hbr0A9WhzVDrsEpm/Fo44i2MAm93 ZcCWZrr9oDRTDuISaEFUIFmkTRZP2TJNbHhVzti8Lmim4uZHUGRrRDNsXFGAuJZZUmJq RVhvZdabuBg1/KsWRj1t7Mp0uP3NSXULNwM2C4AFrh+O+kB8TIHf6THNjSYMxlGaKh6h KtPA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b07fLTai; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-138800-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138800-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r27-20020a170906365b00b00a46f3e5367dsi5655869ejb.586.2024.04.10.08.01.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 08:01:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138800-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b07fLTai; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-138800-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138800-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C22A51F2EF0B for ; Wed, 10 Apr 2024 14:51:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD5C516F0C6; Wed, 10 Apr 2024 14:43:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b07fLTai" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC07816131C; Wed, 10 Apr 2024 14:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712760179; cv=none; b=jc7M/tlfOyHt7HDp1znR5hKNi3dSTMsEgVPRpjRuQ3bzsposMEoBHBDvNKZma53fqF1u4zfZGUG/+5IMJLGmHMBZvgBGVV1eoKdnhtCz+9qzQ5S/PvHQtsAOkkM5JTWLehEx7CyHqG+WXD5s9p9OMkaws8fVcsSWestvSy+aWpM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712760179; c=relaxed/simple; bh=luoVgNyj4zzwwoGosR+LKd29Ur7JRFYhyAO39bS3iYY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=u0ZZJdEgvxxQXGUZMGZa8unUx7JwfP/et4TU/mCow6rKqeJqiUpFI0rmQIrht6nGkbLK/KnFpDgSzeAhsAuLQLrBnIag69QCtwZpLcziOUe0apmgtphNyqO4Ez2M8DsMazyE9FEcyvM8N9f1G/S1Fmpu0JOw+yoJbMnRfLM3GC8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b07fLTai; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8AC9C433C7; Wed, 10 Apr 2024 14:42:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712760179; bh=luoVgNyj4zzwwoGosR+LKd29Ur7JRFYhyAO39bS3iYY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b07fLTaipG3I0kSFOt/zafbbHHiO4S32fLcqmYd6q0R37s3ScVmqRr1uG2MBoOyAS T81YMrNBgj2dJG1nDvP8oXw3IBGjaIduAuo4sfs7kypXW6perKZOQa8tj9dxeoImIN MbruKyDrUpoVlILRrZEPaBctf6piqLJtrAi+t+pBHG8VtAthdxbt62CbDhpDkhcE0M MZcOGJOZxVs9dEa/zznCVHr+2aWv/B5aP4yLYyVld1u4TDwaVRTzEbzHFFEB6P2Ymr z4cqJc2EvNO+hl43NNh/54nap8qjZcfyye30Y1vntHhuq6oiAbB3Ab2uEKUEhYe3FU Hj9WQB0qtU6wg== Date: Wed, 10 Apr 2024 16:42:56 +0200 From: Frederic Weisbecker To: Sebastian Andrzej Siewior Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Adrian Hunter , Alexander Shishkin , Arnaldo Carvalho de Melo , Ian Rogers , Ingo Molnar , Jiri Olsa , Marco Elver , Mark Rutland , Namhyung Kim , Peter Zijlstra , Thomas Gleixner , Arnaldo Carvalho de Melo Subject: Re: [PATCH v3 2/4] perf: Enqueue SIGTRAP always via task_work. Message-ID: References: <20240322065208.60456-1-bigeasy@linutronix.de> <20240322065208.60456-3-bigeasy@linutronix.de> <20240409085732.FBItbOSO@linutronix.de> <20240409134729.JpcBYOsK@linutronix.de> <20240410134702.dcWYciZB@linutronix.de> <20240410140633.0MHBLpMI@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240410140633.0MHBLpMI@linutronix.de> Le Wed, Apr 10, 2024 at 04:06:33PM +0200, Sebastian Andrzej Siewior a ?crit : > On 2024-04-10 16:00:17 [+0200], Frederic Weisbecker wrote: > > Le Wed, Apr 10, 2024 at 03:47:02PM +0200, Sebastian Andrzej Siewior a ?crit : > > > On 2024-04-10 13:37:05 [+0200], Frederic Weisbecker wrote: > > > > > Couldn't we either flush _or_ remove the task_work in perf_release()? > > > > > > > > Right so the problem in perf_release() is that we may be dealing with task works > > > > of other tasks than current. In that case, task_work_cancel() is fine if it > > > > successes. But if it fails, you don't have the guarantee that the task work > > > > isn't concurrently running or about to run. And you have no way to know about > > > > that. So then you need some sort of flushing indeed. > > > > > > Since perf_release() preemptible, a wait/sleep for completion would be > > > best (instead of flushing). > > > > Like this then? > > > > https://lore.kernel.org/all/202403310406.TPrIela8-lkp@intel.com/T/#m63c28147d8ac06b21c64d7784d49f892e06c0e50 > > Kind of, yes. Do we have more than one waiter? If not, maybe that > rcuwait would work then. Indeed there is only one waiter so that should work. Would that be something you can call while preemption is disabled? Thanks. > Otherwise (>1 waiter) we did establish that we may need a per-task > counter for recursion handling so preempt-disable shouldn't be a problem > then. The pending_work_wq must not be used outside of task context (means > no hardirq or something like that). > > Sebastian