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