Message ID | 20221103030933.840989-1-l3b2w1@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp291826wru; Wed, 2 Nov 2022 20:24:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6t3kcg2Xb//lpUOYIF89dSairZFmSlOhVIYf5FDvULFesKSxqJj9DSBmTtyYys+71C8ory X-Received: by 2002:a63:fe58:0:b0:46f:dc58:b23c with SMTP id x24-20020a63fe58000000b0046fdc58b23cmr12811205pgj.205.1667445888416; Wed, 02 Nov 2022 20:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667445888; cv=none; d=google.com; s=arc-20160816; b=GJqEybK5DRhbfELg5Ol3ZzmTew57yuzGAsaIJFNXSObDpg8zKiuMYgEsuFtU8ragAD EtIX0ircfUCerV3fdGr3D/sm4jdRI/xkxw2zcbhQ81P2fPDhhCxpeWs9kRU+Ut5dmo3h hy9FO1gbRsBOfPpmnl0ET585IVhwEgoivzkwjSrna4Q5d/sAdKYD6GrVQDMmcEBUetq6 l1qje1RStHi/te2++vTzmXAJQrphZ+KDAXyAC4dkU8rtW/jz0+qByTBtOEreBJgnrmMp aHGA6L+5BEBFusAKVIghV0i2TnxbkQ2izXppGWbFza7KuS3gvGhgdcZFrbhdLXZZzwYQ uRaA== 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:dkim-signature; bh=BdWhTXBxXiysd2poPDnV59IYfoHF6Yvsi7EDbvrcVKE=; b=Rj/MRxWFGIoQyKU3MqDWrHXoqCy1c6jZsCl2rLonVFbz46iq15Hfb7FNVJKhBZ/LrO ayZjVntvB96/pJUcsJLmP+ZLxCjhiAUAgO1gDBD800f2JUxWzaK9eo36QrYHv2O+Y9kF qj9gPtHXmk8XdqYti7N1JKsVdadd8XXEmilc7UoJokCBE9GkStf3ked1Qt5FXXCT7Q0p JmTCd/zosJlAoanWD6UyzRR73x2qCt1gQ4Z1ku8QWV21gnXrcinawzMG7PSDrdSt33fW XAcL0pQJTNCIVCMc6IN7jH9k6AjvtlvxETr/qC958/i7bx+TJsLd08OcF6M3Iq0huTve BokQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gYbvK43L; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020a17090aa88400b002130053cad7si4030534pjq.7.2022.11.02.20.24.35; Wed, 02 Nov 2022 20:24:48 -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=@gmail.com header.s=20210112 header.b=gYbvK43L; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230017AbiKCDKC (ORCPT <rfc822;yves.mi.zy@gmail.com> + 99 others); Wed, 2 Nov 2022 23:10:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230353AbiKCDJr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Nov 2022 23:09:47 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AB0D14009 for <linux-kernel@vger.kernel.org>; Wed, 2 Nov 2022 20:09:41 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id y4so702215plb.2 for <linux-kernel@vger.kernel.org>; Wed, 02 Nov 2022 20:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=BdWhTXBxXiysd2poPDnV59IYfoHF6Yvsi7EDbvrcVKE=; b=gYbvK43L1DZqFx+ncvrgw/oZ6CiqmHTE5VXqD3ed95nY7yH3kULTt25HQtXLklnJaB tgtwTvK906H+5ij8UMm2GcH5+gE1/axheql6d5qiYQXIUI7OkBd8aDXwPJ3pGNo+SzKI 6vjBAhPqgRSNZaaaGYlpjeAnJ8RLRoB4rW6cUWEjufDq7lP2SB2uv/PcMP5NoCcti8cU 94Wh1hJUdzBwdlUhPD50yHQArO9HJG77bepaWCd04enO5PUAu6rsZV2giYlMWRg8s6RA PqbBmJ/bS4WQhFMgbyQboPxkvbpdkk/R/IeAv+lUTDBo8t/cdpyfmQVROOJyAgRYZjDP 7DQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BdWhTXBxXiysd2poPDnV59IYfoHF6Yvsi7EDbvrcVKE=; b=8SVFoAyNH4U1g2mn1pj55onNRCfywUUOCeR6vBKOLDvMougJjmQxST31vSrAtGd8XQ 4mybaj45YKuq45tpDQern1+CW5JfuME9ShU1kC2vA8KcCjBK1g4tKf/Hs5odTag5W4i8 cDxJ2X/1Bdo8MXKCrYphNV85TQuFW+9j0aC4XfqjQiRLMgkuRjWW5Sv27eQp/kzVCdyp zR+GXWwtAUyt4BBpVxnxkX48Q7Z1MKU9ih+GizDI7wZ8mRGi61NPIlYIon4H/6zSknLt Wg2E9pwo/DCFkBnZY8WCxqafQ2d7nNmvw6YK7FOjXDxhYXpoSdWxXRIsGuxmSCUjBrwc WlFA== X-Gm-Message-State: ACrzQf2Q+gTGUctNjgrsg85zh7fN65JrnxPlOMr9s97F1bcj3k4nUALz bjLvIntSQCnLpbMuAshSS19PllrNb/LBlA== X-Received: by 2002:a17:90b:3886:b0:213:5ccc:973b with SMTP id mu6-20020a17090b388600b002135ccc973bmr45301295pjb.193.1667444980508; Wed, 02 Nov 2022 20:09:40 -0700 (PDT) Received: from localhost.localdomain (l3b2w1.cn. [159.138.1.25]) by smtp.gmail.com with ESMTPSA id q1-20020a17090a7a8100b0020d67a726easm2177563pjf.10.2022.11.02.20.09.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 20:09:40 -0700 (PDT) From: Binglei Wang <l3b2w1@gmail.com> X-Google-Original-From: Binglei Wang To: tj@kernel.org, jiangshanlai@gmail.com Cc: linux-kernel@vger.kernel.org, Binglei Wang <l3b2w1@gmail.com> Subject: [PATCH] workqueue: make workers threads stick to HK_TYPE_KTHREAD cpumask Date: Thu, 3 Nov 2022 11:09:33 +0800 Message-Id: <20221103030933.840989-1-l3b2w1@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748443739621326278?= X-GMAIL-MSGID: =?utf-8?q?1748443739621326278?= |
Series |
workqueue: make workers threads stick to HK_TYPE_KTHREAD cpumask
|
|
Commit Message
Binglei Wang
Nov. 3, 2022, 3:09 a.m. UTC
From: Binglei Wang <l3b2w1@gmail.com> When new worker thread created, set its affinity to HK_TYPE_KTHREAD cpumask. When hotplug cpu online, rebind workers's affinity to HK_TYPE_KTHREAD cpumask. Make workers threads stick to HK_TYPE_KTHREAD cpumask all the time. Signed-off-by: Binglei Wang <l3b2w1@gmail.com> --- kernel/workqueue.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
Comments
Hi Binglei, Thank you for the patch! Yet something to improve: [auto build test ERROR on tj-wq/for-next] [also build test ERROR on linus/master v6.1-rc3 next-20221103] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Binglei-Wang/workqueue-make-workers-threads-stick-to-HK_TYPE_KTHREAD-cpumask/20221103-111140 base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-next patch link: https://lore.kernel.org/r/20221103030933.840989-1-l3b2w1%40gmail.com patch subject: [PATCH] workqueue: make workers threads stick to HK_TYPE_KTHREAD cpumask config: nios2-randconfig-r014-20221103 compiler: nios2-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/96d045fb333d1098f273ad89d6a7215d8ea02ac4 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Binglei-Wang/workqueue-make-workers-threads-stick-to-HK_TYPE_KTHREAD-cpumask/20221103-111140 git checkout 96d045fb333d1098f273ad89d6a7215d8ea02ac4 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=nios2 SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): kernel/workqueue.c: In function 'create_worker': >> kernel/workqueue.c:1958:25: error: assignment to 'const struct cupmask *' from incompatible pointer type 'const struct cpumask *' [-Werror=incompatible-pointer-types] 1958 | cpumask = housekeeping_cpumask(HK_TYPE_KTHREAD); | ^ kernel/workqueue.c:1959:59: warning: pointer type mismatch in conditional expression 1959 | kthread_bind_mask(worker->task, cpumask ? cpumask : pool->attrs->cpumask); | ^ cc1: some warnings being treated as errors vim +1958 kernel/workqueue.c 1913 1914 /** 1915 * create_worker - create a new workqueue worker 1916 * @pool: pool the new worker will belong to 1917 * 1918 * Create and start a new worker which is attached to @pool. 1919 * 1920 * CONTEXT: 1921 * Might sleep. Does GFP_KERNEL allocations. 1922 * 1923 * Return: 1924 * Pointer to the newly created worker. 1925 */ 1926 static struct worker *create_worker(struct worker_pool *pool) 1927 { 1928 struct worker *worker; 1929 int id; 1930 char id_buf[16]; 1931 const struct cupmask *cpumask = NULL; 1932 1933 /* ID is needed to determine kthread name */ 1934 id = ida_alloc(&pool->worker_ida, GFP_KERNEL); 1935 if (id < 0) 1936 return NULL; 1937 1938 worker = alloc_worker(pool->node); 1939 if (!worker) 1940 goto fail; 1941 1942 worker->id = id; 1943 1944 if (pool->cpu >= 0) 1945 snprintf(id_buf, sizeof(id_buf), "%d:%d%s", pool->cpu, id, 1946 pool->attrs->nice < 0 ? "H" : ""); 1947 else 1948 snprintf(id_buf, sizeof(id_buf), "u%d:%d", pool->id, id); 1949 1950 worker->task = kthread_create_on_node(worker_thread, worker, pool->node, 1951 "kworker/%s", id_buf); 1952 if (IS_ERR(worker->task)) 1953 goto fail; 1954 1955 set_user_nice(worker->task, pool->attrs->nice); 1956 1957 if (housekeeping_enabled(HK_TYPE_KTHREAD)) > 1958 cpumask = housekeeping_cpumask(HK_TYPE_KTHREAD); 1959 kthread_bind_mask(worker->task, cpumask ? cpumask : pool->attrs->cpumask); 1960 1961 /* successful, attach the worker to the pool */ 1962 worker_attach_to_pool(worker, pool); 1963 1964 /* start the newly created worker */ 1965 raw_spin_lock_irq(&pool->lock); 1966 worker->pool->nr_workers++; 1967 worker_enter_idle(worker); 1968 wake_up_process(worker->task); 1969 raw_spin_unlock_irq(&pool->lock); 1970 1971 return worker; 1972 1973 fail: 1974 ida_free(&pool->worker_ida, id); 1975 kfree(worker); 1976 return NULL; 1977 } 1978
Hi Binglei, Thank you for the patch! Yet something to improve: [auto build test ERROR on tj-wq/for-next] [also build test ERROR on linus/master v6.1-rc3 next-20221103] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Binglei-Wang/workqueue-make-workers-threads-stick-to-HK_TYPE_KTHREAD-cpumask/20221103-111140 base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-next patch link: https://lore.kernel.org/r/20221103030933.840989-1-l3b2w1%40gmail.com patch subject: [PATCH] workqueue: make workers threads stick to HK_TYPE_KTHREAD cpumask config: hexagon-randconfig-r014-20221102 compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 791a7ae1ba3efd6bca96338e10ffde557ba83920) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/96d045fb333d1098f273ad89d6a7215d8ea02ac4 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Binglei-Wang/workqueue-make-workers-threads-stick-to-HK_TYPE_KTHREAD-cpumask/20221103-111140 git checkout 96d045fb333d1098f273ad89d6a7215d8ea02ac4 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All error/warnings (new ones prefixed by >>): >> kernel/workqueue.c:1958:11: error: incompatible pointer types assigning to 'const struct cupmask *' from 'const struct cpumask *' [-Werror,-Wincompatible-pointer-types] cpumask = housekeeping_cpumask(HK_TYPE_KTHREAD); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> kernel/workqueue.c:1959:42: warning: pointer type mismatch ('const struct cupmask *' and 'struct cpumask *') [-Wpointer-type-mismatch] kthread_bind_mask(worker->task, cpumask ? cpumask : pool->attrs->cpumask); ^ ~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ 1 warning and 1 error generated. vim +1958 kernel/workqueue.c 1913 1914 /** 1915 * create_worker - create a new workqueue worker 1916 * @pool: pool the new worker will belong to 1917 * 1918 * Create and start a new worker which is attached to @pool. 1919 * 1920 * CONTEXT: 1921 * Might sleep. Does GFP_KERNEL allocations. 1922 * 1923 * Return: 1924 * Pointer to the newly created worker. 1925 */ 1926 static struct worker *create_worker(struct worker_pool *pool) 1927 { 1928 struct worker *worker; 1929 int id; 1930 char id_buf[16]; 1931 const struct cupmask *cpumask = NULL; 1932 1933 /* ID is needed to determine kthread name */ 1934 id = ida_alloc(&pool->worker_ida, GFP_KERNEL); 1935 if (id < 0) 1936 return NULL; 1937 1938 worker = alloc_worker(pool->node); 1939 if (!worker) 1940 goto fail; 1941 1942 worker->id = id; 1943 1944 if (pool->cpu >= 0) 1945 snprintf(id_buf, sizeof(id_buf), "%d:%d%s", pool->cpu, id, 1946 pool->attrs->nice < 0 ? "H" : ""); 1947 else 1948 snprintf(id_buf, sizeof(id_buf), "u%d:%d", pool->id, id); 1949 1950 worker->task = kthread_create_on_node(worker_thread, worker, pool->node, 1951 "kworker/%s", id_buf); 1952 if (IS_ERR(worker->task)) 1953 goto fail; 1954 1955 set_user_nice(worker->task, pool->attrs->nice); 1956 1957 if (housekeeping_enabled(HK_TYPE_KTHREAD)) > 1958 cpumask = housekeeping_cpumask(HK_TYPE_KTHREAD); > 1959 kthread_bind_mask(worker->task, cpumask ? cpumask : pool->attrs->cpumask); 1960 1961 /* successful, attach the worker to the pool */ 1962 worker_attach_to_pool(worker, pool); 1963 1964 /* start the newly created worker */ 1965 raw_spin_lock_irq(&pool->lock); 1966 worker->pool->nr_workers++; 1967 worker_enter_idle(worker); 1968 wake_up_process(worker->task); 1969 raw_spin_unlock_irq(&pool->lock); 1970 1971 return worker; 1972 1973 fail: 1974 ida_free(&pool->worker_ida, id); 1975 kfree(worker); 1976 return NULL; 1977 } 1978
Hi Binglei, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on tj-wq/for-next] [also build test WARNING on linus/master v6.1-rc3 next-20221104] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Binglei-Wang/workqueue-make-workers-threads-stick-to-HK_TYPE_KTHREAD-cpumask/20221103-111140 base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-next patch link: https://lore.kernel.org/r/20221103030933.840989-1-l3b2w1%40gmail.com patch subject: [PATCH] workqueue: make workers threads stick to HK_TYPE_KTHREAD cpumask config: arm64-randconfig-r032-20221102 compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 791a7ae1ba3efd6bca96338e10ffde557ba83920) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install arm64 cross compiling tool for clang build # apt-get install binutils-aarch64-linux-gnu # https://github.com/intel-lab-lkp/linux/commit/96d045fb333d1098f273ad89d6a7215d8ea02ac4 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Binglei-Wang/workqueue-make-workers-threads-stick-to-HK_TYPE_KTHREAD-cpumask/20221103-111140 git checkout 96d045fb333d1098f273ad89d6a7215d8ea02ac4 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): kernel/workqueue.c:1958:11: error: incompatible pointer types assigning to 'const struct cupmask *' from 'const struct cpumask *' [-Werror,-Wincompatible-pointer-types] cpumask = housekeeping_cpumask(HK_TYPE_KTHREAD); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> kernel/workqueue.c:1959:42: warning: pointer type mismatch ('const struct cupmask *' and 'cpumask_var_t' (aka 'struct cpumask *')) [-Wpointer-type-mismatch] kthread_bind_mask(worker->task, cpumask ? cpumask : pool->attrs->cpumask); ^ ~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ 1 warning and 1 error generated. vim +1959 kernel/workqueue.c 1913 1914 /** 1915 * create_worker - create a new workqueue worker 1916 * @pool: pool the new worker will belong to 1917 * 1918 * Create and start a new worker which is attached to @pool. 1919 * 1920 * CONTEXT: 1921 * Might sleep. Does GFP_KERNEL allocations. 1922 * 1923 * Return: 1924 * Pointer to the newly created worker. 1925 */ 1926 static struct worker *create_worker(struct worker_pool *pool) 1927 { 1928 struct worker *worker; 1929 int id; 1930 char id_buf[16]; 1931 const struct cupmask *cpumask = NULL; 1932 1933 /* ID is needed to determine kthread name */ 1934 id = ida_alloc(&pool->worker_ida, GFP_KERNEL); 1935 if (id < 0) 1936 return NULL; 1937 1938 worker = alloc_worker(pool->node); 1939 if (!worker) 1940 goto fail; 1941 1942 worker->id = id; 1943 1944 if (pool->cpu >= 0) 1945 snprintf(id_buf, sizeof(id_buf), "%d:%d%s", pool->cpu, id, 1946 pool->attrs->nice < 0 ? "H" : ""); 1947 else 1948 snprintf(id_buf, sizeof(id_buf), "u%d:%d", pool->id, id); 1949 1950 worker->task = kthread_create_on_node(worker_thread, worker, pool->node, 1951 "kworker/%s", id_buf); 1952 if (IS_ERR(worker->task)) 1953 goto fail; 1954 1955 set_user_nice(worker->task, pool->attrs->nice); 1956 1957 if (housekeeping_enabled(HK_TYPE_KTHREAD)) 1958 cpumask = housekeeping_cpumask(HK_TYPE_KTHREAD); > 1959 kthread_bind_mask(worker->task, cpumask ? cpumask : pool->attrs->cpumask); 1960 1961 /* successful, attach the worker to the pool */ 1962 worker_attach_to_pool(worker, pool); 1963 1964 /* start the newly created worker */ 1965 raw_spin_lock_irq(&pool->lock); 1966 worker->pool->nr_workers++; 1967 worker_enter_idle(worker); 1968 wake_up_process(worker->task); 1969 raw_spin_unlock_irq(&pool->lock); 1970 1971 return worker; 1972 1973 fail: 1974 ida_free(&pool->worker_ida, id); 1975 kfree(worker); 1976 return NULL; 1977 } 1978
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 7cd5f5e7e..77b303f5e 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1928,6 +1928,7 @@ static struct worker *create_worker(struct worker_pool *pool) struct worker *worker; int id; char id_buf[16]; + const struct cupmask *cpumask = NULL; /* ID is needed to determine kthread name */ id = ida_alloc(&pool->worker_ida, GFP_KERNEL); @@ -1952,7 +1953,10 @@ static struct worker *create_worker(struct worker_pool *pool) goto fail; set_user_nice(worker->task, pool->attrs->nice); - kthread_bind_mask(worker->task, pool->attrs->cpumask); + + if (housekeeping_enabled(HK_TYPE_KTHREAD)) + cpumask = housekeeping_cpumask(HK_TYPE_KTHREAD); + kthread_bind_mask(worker->task, cpumask ? cpumask : pool->attrs->cpumask); /* successful, attach the worker to the pool */ worker_attach_to_pool(worker, pool); @@ -5027,20 +5031,26 @@ static void unbind_workers(int cpu) static void rebind_workers(struct worker_pool *pool) { struct worker *worker; + const struct cpumask *cpumask = NULL; lockdep_assert_held(&wq_pool_attach_mutex); + if (housekeeping_enabled(HK_TYPE_KTHREAD)) + cpumask = housekeeping_cpumask(HK_TYPE_KTHREAD); + /* * Restore CPU affinity of all workers. As all idle workers should * be on the run-queue of the associated CPU before any local * wake-ups for concurrency management happen, restore CPU affinity * of all workers first and then clear UNBOUND. As we're called * from CPU_ONLINE, the following shouldn't fail. + * + * Also consider the housekeeping HK_TYPE_KTHREAD cpumask. */ for_each_pool_worker(worker, pool) { kthread_set_per_cpu(worker->task, pool->cpu); WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, - pool->attrs->cpumask) < 0); + cpumask ? cpumask : pool->attrs->cpumask) < 0); } raw_spin_lock_irq(&pool->lock);