From patchwork Wed Dec 11 10:59:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hillf Danton X-Patchwork-Id: 11284723 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 84E7B138C for ; Wed, 11 Dec 2019 10:59:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5B8792073B for ; Wed, 11 Dec 2019 10:59:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B8792073B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 648026B3190; Wed, 11 Dec 2019 05:59:37 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5F9BB6B3191; Wed, 11 Dec 2019 05:59:37 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50EA26B3192; Wed, 11 Dec 2019 05:59:37 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 3AE706B3190 for ; Wed, 11 Dec 2019 05:59:37 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id DFDEC2495 for ; Wed, 11 Dec 2019 10:59:36 +0000 (UTC) X-FDA: 76252564752.06.house97_8dea7b80e963d X-Spam-Summary: 2,0,0,d3a88c1d5842befe,d41d8cd98f00b204,hdanton@sina.com,:linux-kernel@vger.kernel.org::hdanton@sina.com,RULES_HIT:41:355:379:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2693:2890:3138:3139:3140:3141:3142:3165:3352:3866:3867:3868:3870:3871:3872:4042:4321:5007:6119:6120:6261:7903:9592:9707:10004:11026:11334:11473:11537:11658:11914:12043:12297:12438:12555:12679:12986:13069:13311:13357:13894:14096:14181:14384:14721:21080:21450:21451:21627:21740:21990:30001:30054,0,RBL:202.108.3.165:@sina.com:.lbl8.mailshell.net-62.18.2.100 64.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: house97_8dea7b80e963d X-Filterd-Recvd-Size: 2152 Received: from mail3-165.sinamail.sina.com.cn (mail3-165.sinamail.sina.com.cn [202.108.3.165]) by imf33.hostedemail.com (Postfix) with SMTP for ; Wed, 11 Dec 2019 10:59:34 +0000 (UTC) Received: from unknown (HELO localhost.localdomain)([221.219.0.244]) by sina.com with ESMTP id 5DF0CC110002931E; Wed, 11 Dec 2019 18:59:30 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 602631629981 From: Hillf Danton To: linux-kernel Cc: linux-mm , Hillf Danton Subject: [RFC 1/4] workqueue: fix selecting cpu for queuing work Date: Wed, 11 Dec 2019 18:59:19 +0800 Message-Id: <20191211105919.10652-1-hdanton@sina.com> In-Reply-To: <20191211104601.16468-1-hdanton@sina.com> References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.189958, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Round robin is needed only for unbound workqueue and wq_unbound_cpumask has nothing to do with standard workqueues, so we have to select cpu in case of WORK_CPU_UNBOUND also with workqueue type taken into account. Fixes: ef557180447f ("workqueue: schedule WORK_CPU_UNBOUND work on wq_unbound_cpumask CPUs") Signed-off-by: Hillf Danton Reviewed-by: Daniel Jordan --- a/kernel/workqueue.c +++ c/kernel/workqueue.c @@ -1409,16 +1409,19 @@ static void __queue_work(int cpu, struct if (unlikely(wq->flags & __WQ_DRAINING) && WARN_ON_ONCE(!is_chained_work(wq))) return; + rcu_read_lock(); retry: - if (req_cpu == WORK_CPU_UNBOUND) - cpu = wq_select_unbound_cpu(raw_smp_processor_id()); - /* pwq which will be used unless @work is executing elsewhere */ - if (!(wq->flags & WQ_UNBOUND)) - pwq = per_cpu_ptr(wq->cpu_pwqs, cpu); - else + if (wq->flags & WQ_UNBOUND) { + if (req_cpu == WORK_CPU_UNBOUND) + cpu = wq_select_unbound_cpu(raw_smp_processor_id()); pwq = unbound_pwq_by_node(wq, cpu_to_node(cpu)); + } else { + if (req_cpu == WORK_CPU_UNBOUND) + cpu = raw_smp_processor_id(); + pwq = per_cpu_ptr(wq->cpu_pwqs, cpu); + } /* * If @work was previously on a different pool, it might still be From patchwork Wed Dec 11 11:12:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hillf Danton X-Patchwork-Id: 11284755 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF050112B for ; Wed, 11 Dec 2019 11:12:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9388A214AF for ; Wed, 11 Dec 2019 11:12:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9388A214AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EC9BF6B319E; Wed, 11 Dec 2019 06:12:57 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E79B56B319F; Wed, 11 Dec 2019 06:12:57 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D90BE6B31A0; Wed, 11 Dec 2019 06:12:57 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id C51016B319E for ; Wed, 11 Dec 2019 06:12:57 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 3AD8A180AD820 for ; Wed, 11 Dec 2019 11:12:57 +0000 (UTC) X-FDA: 76252598394.04.wool33_70db34911c707 X-Spam-Summary: 2,0,0,6d12cdb5b8f5bea0,d41d8cd98f00b204,hdanton@sina.com,:linux-kernel@vger.kernel.org::hdanton@sina.com,RULES_HIT:41:355:379:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1539:1568:1711:1714:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3865:3871:5007:6119:6120:6261:7903:9707:10004:11026:11334:11473:11537:11658:11914:12043:12297:12438:13069:13311:13357:13894:14181:14384:14721:21080:21627:21740:21966:30054,0,RBL:202.108.3.167:@sina.com:.lbl8.mailshell.net-62.50.2.100 64.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:28,LUA_SUMMARY:none X-HE-Tag: wool33_70db34911c707 X-Filterd-Recvd-Size: 1552 Received: from mail3-167.sinamail.sina.com.cn (mail3-167.sinamail.sina.com.cn [202.108.3.167]) by imf01.hostedemail.com (Postfix) with SMTP for ; Wed, 11 Dec 2019 11:12:55 +0000 (UTC) Received: from unknown (HELO localhost.localdomain)([221.219.0.244]) by sina.com with ESMTP id 5DF0CF330001B1D9; Wed, 11 Dec 2019 19:12:52 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 924905629342 From: Hillf Danton To: linux-kernel Cc: linux-mm , Hillf Danton Subject: [RFC 2/4] workqueue: use smp_processor_id() on queuing work Date: Wed, 11 Dec 2019 19:12:41 +0800 Message-Id: <20191211111241.25000-1-hdanton@sina.com> In-Reply-To: <20191211104601.16468-1-hdanton@sina.com> References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.213778, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use the regular version with irq disabled. Signed-off-by: Hillf Danton --- c/kernel/workqueue.c +++ d/kernel/workqueue.c @@ -1415,11 +1415,11 @@ retry: /* pwq which will be used unless @work is executing elsewhere */ if (wq->flags & WQ_UNBOUND) { if (req_cpu == WORK_CPU_UNBOUND) - cpu = wq_select_unbound_cpu(raw_smp_processor_id()); + cpu = wq_select_unbound_cpu(smp_processor_id()); pwq = unbound_pwq_by_node(wq, cpu_to_node(cpu)); } else { if (req_cpu == WORK_CPU_UNBOUND) - cpu = raw_smp_processor_id(); + cpu = smp_processor_id(); pwq = per_cpu_ptr(wq->cpu_pwqs, cpu); } From patchwork Wed Dec 11 11:22:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hillf Danton X-Patchwork-Id: 11284759 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C79614E3 for ; Wed, 11 Dec 2019 11:22:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 805B2214AF for ; Wed, 11 Dec 2019 11:22:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 805B2214AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C2A7A6B31A7; Wed, 11 Dec 2019 06:22:45 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BDAC46B31A8; Wed, 11 Dec 2019 06:22:45 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF0B46B31A9; Wed, 11 Dec 2019 06:22:45 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0055.hostedemail.com [216.40.44.55]) by kanga.kvack.org (Postfix) with ESMTP id 96BAE6B31A7 for ; Wed, 11 Dec 2019 06:22:45 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 460C7181AEF15 for ; Wed, 11 Dec 2019 11:22:45 +0000 (UTC) X-FDA: 76252623090.13.tail08_34f33c30e454f X-Spam-Summary: 2,0,0,c8999a335f6cc0f5,d41d8cd98f00b204,hdanton@sina.com,:linux-kernel@vger.kernel.org::hdanton@sina.com,RULES_HIT:41:355:379:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1539:1568:1711:1714:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3867:3871:5007:6119:6120:6261:7903:9592:9707:10004:11026:11334:11473:11537:11658:11914:12043:12297:13069:13211:13229:13311:13357:13894:14181:14384:14721:21080:21627:21740:21987:21990:30054,0,RBL:202.108.3.166:@sina.com:.lbl8.mailshell.net-62.50.2.100 64.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: tail08_34f33c30e454f X-Filterd-Recvd-Size: 1615 Received: from mail3-166.sinamail.sina.com.cn (mail3-166.sinamail.sina.com.cn [202.108.3.166]) by imf14.hostedemail.com (Postfix) with SMTP for ; Wed, 11 Dec 2019 11:22:43 +0000 (UTC) Received: from unknown (HELO localhost.localdomain)([221.219.0.244]) by sina.com with ESMTP id 5DF0D17F000117A3; Wed, 11 Dec 2019 19:22:41 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 19633554920004 From: Hillf Danton To: linux-kernel Cc: linux-mm , Hillf Danton Subject: [RFC 3/4] workqueue: reap dead pool workqueue on queuing work Date: Wed, 11 Dec 2019 19:22:29 +0800 Message-Id: <20191211112229.22652-1-hdanton@sina.com> In-Reply-To: <20191211104601.16468-1-hdanton@sina.com> References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.266419, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Release rcu lock to reap dead pool workqueue. Signed-off-by: Hillf Danton --- d/kernel/workqueue.c +++ e/kernel/workqueue.c @@ -1409,9 +1409,9 @@ static void __queue_work(int cpu, struct if (unlikely(wq->flags & __WQ_DRAINING) && WARN_ON_ONCE(!is_chained_work(wq))) return; - - rcu_read_lock(); retry: + rcu_read_lock(); + /* pwq which will be used unless @work is executing elsewhere */ if (wq->flags & WQ_UNBOUND) { if (req_cpu == WORK_CPU_UNBOUND) @@ -1458,6 +1458,7 @@ retry: if (unlikely(!pwq->refcnt)) { if (wq->flags & WQ_UNBOUND) { spin_unlock(&pwq->pool->lock); + rcu_read_unlock(); cpu_relax(); goto retry; } From patchwork Wed Dec 11 11:33:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hillf Danton X-Patchwork-Id: 11284771 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 895F7112B for ; Wed, 11 Dec 2019 11:34:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6CC0820836 for ; Wed, 11 Dec 2019 11:34:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6CC0820836 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 962D06B31B0; Wed, 11 Dec 2019 06:34:07 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9129C6B31B1; Wed, 11 Dec 2019 06:34:07 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 828D56B31B2; Wed, 11 Dec 2019 06:34:07 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 6DE5D6B31B0 for ; Wed, 11 Dec 2019 06:34:07 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 15A1340D6 for ; Wed, 11 Dec 2019 11:34:07 +0000 (UTC) X-FDA: 76252651734.17.duck51_6a83b2b4e61f X-Spam-Summary: 2,0,0,34632d54acc241a7,d41d8cd98f00b204,hdanton@sina.com,:linux-kernel@vger.kernel.org::hdanton@sina.com,RULES_HIT:41:355:379:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1538:1567:1711:1714:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3867:3871:3872:5007:6120:6261:9707:10004:11334:11537:11658:11914:12296:12297:13069:13311:13357:13868:13894:14181:14384:14721:21080:21451:21627:21740:30054,0,RBL:202.108.3.165:@sina.com:.lbl8.mailshell.net-62.18.2.100 64.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:201,LUA_SUMMARY:none X-HE-Tag: duck51_6a83b2b4e61f X-Filterd-Recvd-Size: 1399 Received: from mail3-165.sinamail.sina.com.cn (mail3-165.sinamail.sina.com.cn [202.108.3.165]) by imf22.hostedemail.com (Postfix) with SMTP for ; Wed, 11 Dec 2019 11:34:05 +0000 (UTC) Received: from unknown (HELO localhost.localdomain)([221.219.0.244]) by sina.com with ESMTP id 5DF0D4290001DDA9; Wed, 11 Dec 2019 19:34:03 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 145384628816 From: Hillf Danton To: linux-kernel Cc: linux-mm , Hillf Danton Subject: [RFC 4/4] workqueue: use integer for cpu on queuing work Date: Wed, 11 Dec 2019 19:33:51 +0800 Message-Id: <20191211113351.24240-1-hdanton@sina.com> In-Reply-To: <20191211104601.16468-1-hdanton@sina.com> References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.080005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: It's a minor cleanup, see d84ff0512f1b ("workqueue: consistently use int for @cpu variables") for reasons. Signed-off-by: Hillf Danton --- e/kernel/workqueue.c +++ f/kernel/workqueue.c @@ -1393,7 +1393,7 @@ static void __queue_work(int cpu, struct struct worker_pool *last_pool; struct list_head *worklist; unsigned int work_flags; - unsigned int req_cpu = cpu; + int req_cpu = cpu; /* * While a work item is PENDING && off queue, a task trying to