Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2620170ybl; Thu, 29 Aug 2019 10:33:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPfg8gTfxffdQtjHRHQm0KGPauO0eb2N2C540loYZNNfgNmiECk8E8qV9NnHpe5fP1mETR X-Received: by 2002:a17:902:b116:: with SMTP id q22mr10913674plr.338.1567100019347; Thu, 29 Aug 2019 10:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567100019; cv=none; d=google.com; s=arc-20160816; b=Pg/q9JTJeFIz60cHjSvO6OouzpT4dCzCc2qmLp+SOJ3yxGItKkQt534f1K6oO2ckjm 2VkxLZDalhLwrtV+syYZtpK98/ldWC+u8E3d96mQgFS9O2Xtfa8UwwLYR+w5cxK5Tbs7 aiGIkBFUFGtosq0TH6xvpcoiC+Vi4R0egPpzrxYUnMss4YTFtxspW/pZyF9AcRZ/iyY5 coV0ij33qG/GBIh3IDfpEPggZEY5GOEZFi7TfaozIdMKlKwVM+rORRPmE4YOX+1z8EHZ AUmrjX3S/gg5N5nMBezosZ5+14ARz2Lcg6g7T7hIICbsC3bLKHffp9mPWFG+lMPV7sgH zDYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=H0/g58Ti3RBu0trSXJbyxqtFqN/+XmUcOY+U5Vqoh2w=; b=qHWB5K7DQRf+vzarmLSI/YBMhEuQ2dhJKXgiMta+Pnriesu1a3kYl3j3sKsjJ53UNJ 1qQ2vkYvsVvEwPhjxSCcD/OtlwfY3CC2uu58qNPGDrOMvEDsvmdizEQrZPqu77fwO0v6 Lo2mQ1eQAJZMWXhYMzXMp+AxANqD6510FNel3sT9QdjoQCkWsbYnVw7WiKo79TXaBz/I 8lBMBgHWbU/JxFbbcPsl7wiWbxzac/8U1QC0gheZDk0lbL6s6K5gVbTH45/h6T8PsHJd 8zqBRfiGGyLfZ+sf6oHQw1OgFo1HPQRq2U6QdGtEVytqItGncm/Tq6UAXwf1AFnIFdNU YArQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=WpPw99UE; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cu10si2782839pjb.16.2019.08.29.10.33.12; Thu, 29 Aug 2019 10:33:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=WpPw99UE; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727173AbfH2Rc6 (ORCPT + 99 others); Thu, 29 Aug 2019 13:32:58 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:44566 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727364AbfH2Rc6 (ORCPT ); Thu, 29 Aug 2019 13:32:58 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7THTi5N121276; Thu, 29 Aug 2019 17:32:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=H0/g58Ti3RBu0trSXJbyxqtFqN/+XmUcOY+U5Vqoh2w=; b=WpPw99UEdBXdABNj+jLEUm8Oj6LncT4nRr/X6uLJjQbidSvowy5/STzNM8uSHjCxNW3P BEUhj4916uJYmUwoT+tBB1FsthEKTJcs23KRZesEJKdTXk3YmstxnH+8QdlwLrG4F0GX BQlZReFaLn0/qS+fF3pK/R0Eli3ezK42+PkkcFKKbosswdCcFH5QXsdAF4D2nVksXWTe +J9QyX46IuBrmffOudtDjh1C7hs+keYatUbUN0uG2TM+xZ5IsilzB+eXQtYeJvDY/siy OqXduKbAPrDzU0en5fEagUKdMfMjdkGKWgHDckwv0bfw6hxhYLcvb64DN9ZEVpdLLnju Rw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2upk56r0rh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Aug 2019 17:32:42 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7THWdBe008284; Thu, 29 Aug 2019 17:32:42 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2unvu0b2dc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Aug 2019 17:32:42 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7THWf7W017326; Thu, 29 Aug 2019 17:32:41 GMT Received: from zissou.us.oracle.com (/10.152.34.58) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 29 Aug 2019 10:32:41 -0700 From: Daniel Jordan To: Herbert Xu , Steffen Klassert Cc: Lai Jiangshan , Peter Zijlstra , Tejun Heo , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Jordan Subject: [PATCH v2 7/9] padata: use separate workqueues for parallel and serial work Date: Thu, 29 Aug 2019 13:30:36 -0400 Message-Id: <20190829173038.21040-8-daniel.m.jordan@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190829173038.21040-1-daniel.m.jordan@oracle.com> References: <20190829173038.21040-1-daniel.m.jordan@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9364 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908290186 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9364 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908290185 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org padata currently uses one per-CPU workqueue per instance for all work. Prepare for running parallel jobs on an unbound workqueue by introducing dedicated workqueues for parallel and serial work. Signed-off-by: Daniel Jordan Acked-by: Steffen Klassert Cc: Herbert Xu Cc: Lai Jiangshan Cc: Peter Zijlstra Cc: Tejun Heo Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- include/linux/padata.h | 6 ++++-- kernel/padata.c | 28 ++++++++++++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/include/linux/padata.h b/include/linux/padata.h index e04f7d873adb..b5f18802d015 100644 --- a/include/linux/padata.h +++ b/include/linux/padata.h @@ -128,7 +128,8 @@ struct parallel_data { * struct padata_instance - The overall control structure. * * @cpu_notifier: cpu hotplug notifier. - * @wq: The workqueue in use. + * @parallel_wq: The workqueue used for parallel work. + * @serial_wq: The workqueue used for serial work. * @pd: The internal control structure. * @cpumask: User supplied cpumasks for parallel and serial works. * @cpumask_change_notifier: Notifiers chain for user-defined notify @@ -140,7 +141,8 @@ struct parallel_data { */ struct padata_instance { struct hlist_node node; - struct workqueue_struct *wq; + struct workqueue_struct *parallel_wq; + struct workqueue_struct *serial_wq; struct parallel_data *pd; struct padata_cpumask cpumask; struct blocking_notifier_head cpumask_change_notifier; diff --git a/kernel/padata.c b/kernel/padata.c index 29d44edd6733..eefe4dd3d979 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -152,7 +152,7 @@ int padata_do_parallel(struct padata_instance *pinst, list_add_tail(&padata->list, &queue->parallel.list); spin_unlock(&queue->parallel.lock); - queue_work_on(target_cpu, pinst->wq, &queue->work); + queue_work_on(target_cpu, pinst->parallel_wq, &queue->work); out: rcu_read_unlock_bh(); @@ -260,7 +260,7 @@ static void padata_reorder(struct parallel_data *pd) list_add_tail(&padata->list, &squeue->serial.list); spin_unlock(&squeue->serial.lock); - queue_work_on(cb_cpu, pinst->wq, &squeue->work); + queue_work_on(cb_cpu, pinst->serial_wq, &squeue->work); } spin_unlock_bh(&pd->lock); @@ -277,7 +277,7 @@ static void padata_reorder(struct parallel_data *pd) next_queue = per_cpu_ptr(pd->pqueue, pd->cpu); if (!list_empty(&next_queue->reorder.list)) - queue_work(pinst->wq, &pd->reorder_work); + queue_work(pinst->serial_wq, &pd->reorder_work); } static void invoke_padata_reorder(struct work_struct *work) @@ -770,7 +770,8 @@ static void __padata_free(struct padata_instance *pinst) padata_free_pd(pinst->pd); free_cpumask_var(pinst->cpumask.pcpu); free_cpumask_var(pinst->cpumask.cbcpu); - destroy_workqueue(pinst->wq); + destroy_workqueue(pinst->serial_wq); + destroy_workqueue(pinst->parallel_wq); kfree(pinst); } @@ -919,18 +920,23 @@ static struct padata_instance *padata_alloc(const char *name, if (!pinst) goto err; - pinst->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, - 1, name); - if (!pinst->wq) + pinst->parallel_wq = alloc_workqueue("%s_parallel", WQ_MEM_RECLAIM | + WQ_CPU_INTENSIVE, 1, name); + if (!pinst->parallel_wq) goto err_free_inst; get_online_cpus(); - if (!alloc_cpumask_var(&pinst->cpumask.pcpu, GFP_KERNEL)) + pinst->serial_wq = alloc_workqueue("%s_serial", WQ_MEM_RECLAIM | + WQ_CPU_INTENSIVE, 1, name); + if (!pinst->serial_wq) goto err_put_cpus; + + if (!alloc_cpumask_var(&pinst->cpumask.pcpu, GFP_KERNEL)) + goto err_free_serial_wq; if (!alloc_cpumask_var(&pinst->cpumask.cbcpu, GFP_KERNEL)) { free_cpumask_var(pinst->cpumask.pcpu); - goto err_put_cpus; + goto err_free_serial_wq; } if (!padata_validate_cpumask(pinst, pcpumask) || !padata_validate_cpumask(pinst, cbcpumask)) @@ -964,9 +970,11 @@ static struct padata_instance *padata_alloc(const char *name, err_free_masks: free_cpumask_var(pinst->cpumask.pcpu); free_cpumask_var(pinst->cpumask.cbcpu); +err_free_serial_wq: + destroy_workqueue(pinst->serial_wq); err_put_cpus: put_online_cpus(); - destroy_workqueue(pinst->wq); + destroy_workqueue(pinst->parallel_wq); err_free_inst: kfree(pinst); err: -- 2.23.0