From mboxrd@z Thu Jan 1 00:00:00 1970 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 80BEA1FECB1 for ; Thu, 9 Jan 2025 21:08:49 +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=1736456929; cv=none; b=ElMXHUzoaRoONB8oA24ITVJ5GqFueWIyEGUgUEeANvIOhrrD+NXx4pvqdZQ724hFnFkLSaZdy7zLSHOZ/Syt1l5ud/jQJp9ES+aOpKBCjf/XHanVudNQrAZk2dVMrEpBldm49IQ3HmvpNgSQS97nItYx5KLF/ChKiPFatmdNIbo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736456929; c=relaxed/simple; bh=sRG1ub27iyZz7wLpS2GPf7jSqc70ni5bXWzAyGtzqQs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GF8IE/81kVrXkE4bEdezpefZxYyg2O9xSrgoB4iPoB4U/3uMwWuuusOAzCuC+jOE4KMU40cZ18rw+scM+4MCOrqsI5ipZCQv+v20KPhmcNt8hfkn8HnqtyHRVSLoziE/D6WDlCDFtL7zLJnXfMiO2qx84/mL+x5j7N5RpqcRf3I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QRnlhUCB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QRnlhUCB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9227C4CED2; Thu, 9 Jan 2025 21:08:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736456929; bh=sRG1ub27iyZz7wLpS2GPf7jSqc70ni5bXWzAyGtzqQs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QRnlhUCBolzIrWsNgsi5S0g+1YTx5Q5u/GunGSdmaO19PHeqN3pU+shN5wfM5ILdQ XweLJI1yt078Vd8q/8TUOUW7aDOcEGLqZwhhicwAq4HlePqtPxnbI9mtSzqzOSM1Xv ojSP9bOEiGxTLqiTFUFC0XwtnEQnrFvXFx9EY6GGBgidtb1Rl3w97YJSQAkZxfuXoV 3M+UjHo7kt2+9csVswDoLP6lYGOnp5qhxgjxpK6ckDUIXQpZWYJvQklbJczyKgn74u xXyKfUe/ldZr3ONtB8aSTzW5oY62DG28PUnoZRMdSAfQIPERYC7Gc2OLrvY5EcvO29 FkdlhRMah+I9A== Date: Thu, 9 Jan 2025 11:08:47 -1000 From: Tejun Heo To: Imran Khan Cc: jiangshanlai@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] workqueue: warn if delayed_work is queued to an offlined cpu. Message-ID: References: <20250109101829.2026320-1-imran.f.khan@oracle.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20250109101829.2026320-1-imran.f.khan@oracle.com> On Thu, Jan 09, 2025 at 09:18:29PM +1100, Imran Khan wrote: > delayed_work submitted to an offlined cpu, will not get executed, > after the specified delay if the cpu remains offline. If the cpu > never comes online the work will never get executed. > checking for online cpu in __queue_delayed_work, does not sound > like a good idea because to do this reliably we need hotplug lock > and since work may be submitted from atomic contexts, we would > have to use cpus_read_trylock. But if trylock fails we would queue > the work on any cpu and this may not be optimal because our intended > cpu might still be online. > > Putting a WARN_ON for an already offlined cpu, will indicate users > of queue_delayed_work_on, if they are (wrongly) trying to queue > delayed_work on offlined cpu. > > Signed-off-by: Imran Khan > --- > kernel/workqueue.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/kernel/workqueue.c b/kernel/workqueue.c > index 8e0bb3c608239..10878b5e3d74f 100644 > --- a/kernel/workqueue.c > +++ b/kernel/workqueue.c > @@ -2508,6 +2508,7 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq, > return; > } > > + WARN_ON(cpu != WORK_CPU_UNBOUND && !cpu_online(cpu)); Can we use WARN_ON_ONCE() instead? Thanks. -- tejun