From patchwork Fri Apr 28 23:47:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 88781 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1290098vqo; Fri, 28 Apr 2023 17:10:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5rw5pSKf8CKig8AO1VR7E5ZtaO9NupxCd6/+roCjSNINgwCeqAnue3jBgPk/6GFHvV0myF X-Received: by 2002:a17:90b:224f:b0:246:ee10:cb5d with SMTP id hk15-20020a17090b224f00b00246ee10cb5dmr7127535pjb.14.1682727023945; Fri, 28 Apr 2023 17:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682727023; cv=none; d=google.com; s=arc-20160816; b=fM1OvkgvjIZq3NXBauxB7B4h9P6XEq6l+UXyMyjiWZKUAP/0VNHekMsjxZHtzmqCz+ hvGjLnPGa7hP115WyG46r9ppWv3tlIRGaKw0ynVkkc8xv+SdqDJA8DbvZQE3FBBZ5VdW uazc8gfnlQm8W0MfwuLinE99JQb5bkqbTKX94MuE0AXJwwc94NCQtM3H+ngsUwwsAPtJ pTW8Jl+EtJe5X9WxKvdBIsNNTaY9wfcjdMXhF/Pw/oyiKurZ9cVvuOYZ16GvopW4m+z/ yXLhpMRYk3eg//Quqdp1ktEJyZoVzBk9xrY9N3/309tAf91Z4ekXlQq6E3hATMb8PuHQ Qxzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:reply-to :message-id:subject:cc:to:from:date:dkim-signature; bh=F/acI7rL6nVN6DckJVkqXQVwlrehKxsuhzfM9wfgbCM=; b=OJvDeA1YSTOu/p9NW9YQB/RjZ8RXxIm2Na+fpHVLbc5u8WtPkXtfJ/n+BtJTR7IotZ 7kFgcfECU2iamnm14NXBvmmtO8HXs85OtHgnOajLGOFqwFdujIf9CorUwU9fmdMmvc9c hNYJuFeuydApdb70G45IdT/N0l50oAV28gxByMdGJ8Nc6cYrBpX/aQCk4fu+dVA6zWfA VHvy5vegpFbIF4x3eFfdugYPtKztcI4J2+dLNVFn5I/9HvJGjtNHAMCCSzwJobpKE1IY bZRE4BReH5/mHHu7VtCrikAZS3PJ2YQXhagnTtVU8f9m9cWrw+UMXWEDwlLcsYH/AYyJ eGRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a59f2r2Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a63d809000000b005186ed361f4si22093937pgh.315.2023.04.28.17.10.06; Fri, 28 Apr 2023 17:10:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a59f2r2Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1346854AbjD1XsV (ORCPT + 99 others); Fri, 28 Apr 2023 19:48:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347091AbjD1XsP (ORCPT ); Fri, 28 Apr 2023 19:48:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56A7D5BAC for ; Fri, 28 Apr 2023 16:47:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 90EED60E93 for ; Fri, 28 Apr 2023 23:47:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01B9CC433D2; Fri, 28 Apr 2023 23:47:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682725628; bh=R5vn2ZgdnPfmCjY37PzWzk8rZPbh5zWmOOaRiO9280E=; h=Date:From:To:Cc:Subject:Reply-To:From; b=a59f2r2YAmrSaA2nUjozRUiwjqqIZoWWf93NShGnXPGNZLmgOKd6clkLcbJqBI9lP jWJqq8/kLswsCpsxuTje9qcuBCCVyE5ZyrYKnBh5VNVRLS5ZGOJuaNSkS+ayzeLlP6 drd73vOstaYzeDLS6x0ozNmRjKLvWQASFDUMGPY2btMEdtdzn8kHP6/hSLNnIWCCms XZN6U9ZD5wjgFF8V0YWn4fQv9xMwzjSi2m90iVVzJPQFQnwxVzmm4mOFXxRw6HeyQc P9ZbVAdeoA3a6ylrfaD9GgC8MEP1Vqjs+5xCNIHJmWZThwTz9WkL3wsLJKtIENBOi3 kKMb+ZqHV7XBg== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 7FB4115404E8; Fri, 28 Apr 2023 16:47:07 -0700 (PDT) Date: Fri, 28 Apr 2023 16:47:07 -0700 From: "Paul E. McKenney" To: tj@kernel.org, jiangshanlai@gmail.com Cc: linux-kernel@vger.kernel.org Subject: [PATCH workqueues] Further upgrade queue_work_on() comment Message-ID: Reply-To: paulmck@kernel.org MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764467171661749484?= X-GMAIL-MSGID: =?utf-8?q?1764467171661749484?= The current queue_work_on() docbook comment says that the caller must ensure that the specified CPU can't go away, and further says that the penalty for failing to nail down the specified CPU is that the workqueue handler might find itself executing on some other CPU. This is true as far as it goes, but fails to note what happens if the specified CPU never was online. Therefore, further expand this comment to say that specifying a CPU that was never online will result in a splat. Signed-off-by: Paul E. McKenney Cc: Lai Jiangshan Cc: Tejun Heo diff --git a/kernel/workqueue.c b/kernel/workqueue.c index b8b541caed48..2dd3308edc01 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1537,6 +1537,8 @@ static void __queue_work(int cpu, struct workqueue_struct *wq, * We queue the work to a specific CPU, the caller must ensure it * can't go away. Callers that fail to ensure that the specified * CPU cannot go away will execute on a randomly chosen CPU. + * But note well that callers specifying a CPU that never has been + * online will get a splat. * * Return: %false if @work was already on a queue, %true otherwise. */