From patchwork Sat Jul 29 13:53:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Tomlin X-Patchwork-Id: 12812 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1060233vqg; Sat, 29 Jul 2023 07:29:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlFe6K26iU54dw4KlBicPdJccUnSHMBR57pvLzPmbsD0X8GUbKOwZwt+B/czhXvttLnPhtU8 X-Received: by 2002:a17:906:18:b0:99b:6e54:bd6e with SMTP id 24-20020a170906001800b0099b6e54bd6emr1854346eja.56.1690640943012; Sat, 29 Jul 2023 07:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690640942; cv=none; d=google.com; s=arc-20160816; b=E+OHmh9vK4/11hRTMaAufE74ukuw010M7xWNuqHmyYToOxbnQDoxvKbT9H8xVA7wNS eJgqdUCsUqylSKeRUu+Z+4LFuzpTnRplMNxE1ho3lbtc2CtrA8Q7KcNfadchMoqUVcfX CTVHyxZ/7eXqFwKKq3qJYQE6Dr+FuEYnYkjX8qWp5YkdKRcCQEbWKxYOvDlsVvJxm5Tq m2O2eEL1lK11kxYG9YOKkWn05O0q3hvPPiocYYviyLa7Us10rp01ytPU6UydI43YfBlC z0koAu1t5vAmsjeWJdtuIDTD3q2l1okFIbENlvT3VnDAR6qWk8WHP/b9VeLy7PEKzxMo tYAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ItceX9cDOozwZpHaz0SKD4GPoPizIK47y64sO6xriYE=; fh=iIrmuiooHb58lVSZg9OlpW7yJYF2kt3Km03sQ9AihSM=; b=q+YZ5lMuzcJItu2Xg02Pmo+ZQHckX2H60vTc7g7QoufN/hPeMVpzlVQJ/PMBtehRmC TJGy7o2OCeKyqSyXncuGCpSPjZcsb3laDO3wlhpkbe3x+txD6i7b/X0UzAjTlOLP9qkW aQuS0EypDAPi50FfKp9xRVYLQBFp1wivKjaQqOAIxE69v2vm3jrmmFfQPL6MLBL2FQzO A2DPQaleVv3pRbACIPSfjfKxng0CDo0D6bN0vrO7oPzVZ0QJOByPB2UvFwcAjzjEKDJ+ +Mqc/OpflcSpVGoEkG4GxhYfYl/bSclwvHuPA1Wq82qtewhkQtvxd8exAnHxMjMyZdWm 3PzQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lg21-20020a170906f89500b00991bd84725asi4263167ejb.227.2023.07.29.07.28.39; Sat, 29 Jul 2023 07:29:02 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231621AbjG2N4A (ORCPT + 99 others); Sat, 29 Jul 2023 09:56:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231491AbjG2Nz4 (ORCPT ); Sat, 29 Jul 2023 09:55:56 -0400 X-Greylist: delayed 135 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 29 Jul 2023 06:55:52 PDT Received: from p3plsmtpa08-03.prod.phx3.secureserver.net (p3plsmtpa08-03.prod.phx3.secureserver.net [173.201.193.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A8AA1FE7 for ; Sat, 29 Jul 2023 06:55:51 -0700 (PDT) Received: from localhost ([82.27.99.45]) by :SMTPAUTH: with ESMTPA id PkNyqM7LIgssUPkO0q93dq; Sat, 29 Jul 2023 06:53:36 -0700 X-CMAE-Analysis: v=2.4 cv=XoY8e3J9 c=1 sm=1 tr=0 ts=64c519e0 a=YwMIiW7BGddQzL8MrqPWMg==:117 a=YwMIiW7BGddQzL8MrqPWMg==:17 a=Qe_DDWJ2S8ZzKdoxMNcA:9 X-SECURESERVER-ACCT: atomlin@atomlin.com From: Aaron Tomlin To: linux-kernel@vger.kernel.org Cc: tj@kernel.org, jiangshanlai@gmail.com, peterz@infradead.org Subject: [RFC PATCH 0/2] workqueue: Introduce PF_WQ_RESCUE_WORKER Date: Sat, 29 Jul 2023 14:53:32 +0100 Message-Id: <20230729135334.566138-1-atomlin@atomlin.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-CMAE-Envelope: MS4xfDm+ivhAG0siGQTlgWZ1nlzf+D2vp9U5BHNoR4ign5AtO7ygzgpr0Kj+Jq+BWNQ+RDj0fqB6LRpM0Eqaz55G37n+b/tU2V/lbJmSVFWagz8RscjdS5gf cWe+dbF5uKU+Non476fA6AHoiT1FqbOKj3ufRfnirk5UMvRFhSIC7mLBFOVbT+1tfKTrB6clDUSYj8DKi+RH2/VHi0bZVQt4StwBdVCjaFqDeAShb6E27Gqx ZaHGqvXV/v77Zx6M2dOlyZKYgYqwF8ZipH0Kf1QJhAc= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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: INBOX X-GMAIL-THRID: 1772765517508955464 X-GMAIL-MSGID: 1772765517508955464 The Linux kernel does not provide a way to differentiate between a kworker and a rescue kworker for user-mode. From user-mode, one can establish if a task is a kworker by testing for PF_WQ_WORKER in a specified task's flags bit mask (or bitmap) via /proc/[PID]/stat. Indeed, one can examine /proc/[PID]/stack and search for the function namely "rescuer_thread". This is only available to the root user. It can be useful to identify a rescue kworker since their CPU affinity cannot be modified and their initial CPU assignment can be safely ignored. Furthermore, a workqueue that was created with WQ_MEM_RECLAIM and WQ_SYSFS the cpumask file is not applicable to the rescue kworker. By design a rescue kworker should run anywhere. This patch series introduces PF_WQ_RESCUE_WORKER and ensures it is set and cleared appropriately and simplifies current_is_workqueue_rescuer(). Aaron Tomlin (2): workqueue: Introduce PF_WQ_RESCUE_WORKER workqueue: Simplify current_is_workqueue_rescuer() include/linux/sched.h | 2 +- kernel/workqueue.c | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-)