Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp250548ybt; Tue, 30 Jun 2020 20:07:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgmOCYIkd9cVwIgkEShB9SIXXoX8YjXSGFT9wZCscWnOBvthhtleREou6EN9J4ykmPSW3+ X-Received: by 2002:a17:906:4685:: with SMTP id a5mr19064067ejr.46.1593572856484; Tue, 30 Jun 2020 20:07:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593572856; cv=none; d=google.com; s=arc-20160816; b=PmTlM5qn1DWVOSisfUkznPDrew3FIR+b9RHWxNrc0gfN92PaPVcY9Aij4GydwOGhAv POo1iUk/8T/m8O/f5wQhWM9ODBxOfSOKLEatuLpYfLvXCgv9yPThCPBPaPsDoc/QTD8h CmaExFSbWDn+wsbKDbhsX40XSdMPYenR2jMF7DiR8Ej6+i9JsmsHYkWKcjPlJFnQywhr kTzHLgKbSpPHeK265pceATXUDietC/w4Majuw8dVXje9/OLAzOGe+07CWitADopNFiGo 4BR0AQVFnjAxrwx4zFoB1W/I2U5o1+2c0yIaLVhWOUwgwGf0D5i0J9INaianHm1bLq/O cp3Q== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=C+OQSk8SX2KjNV/BOEHQlX3V1mNEDOQ2Qwd9iZIvMHg=; b=AEiiA3E9/N+Ec81jHSEecjPLn5wwRXyQNZkK9Bl9V7ga66PkJUlxMOCYCFMyDUjK6x nKikftmWdCEh/MD1KqKrtCLYOwKZ8WBx3YNgkRVh6BRQLtKQKI8OSVdEvBVPTruBBhnH MWcZ6lF9M7rD211YTyo+zBpCs12ad5D19SGc6wvO0Zrm9Rc9DmOEMtonbFkG15BHFaXD QBCOjx578RKaK/y/gE5QI8q5cPTJcVNEqxG+RiJ8Mdu+2A6n3h5gBWXRinozMe/mRnNU lb8n51tyZiJtBTilP9xSNmDPuAeIGsxRM9hteF65Zk8Nc/u6t3vjCIJ2ynu4jN9bgIMG RG/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=gz+Cecqn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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. [23.128.96.18]) by mx.google.com with ESMTP id me25si3025989ejb.164.2020.06.30.20.07.13; Tue, 30 Jun 2020 20:07:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=gz+Cecqn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1726314AbgGADHE (ORCPT + 99 others); Tue, 30 Jun 2020 23:07:04 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:50612 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbgGADHD (ORCPT ); Tue, 30 Jun 2020 23:07:03 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06136vQ0180635; Wed, 1 Jul 2020 03:06:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=C+OQSk8SX2KjNV/BOEHQlX3V1mNEDOQ2Qwd9iZIvMHg=; b=gz+Cecqn0IukVu6qMxpbz8T6D7bIMqoRDj6GTQnesnHwSdWIcS4opddN7hIT1XSaa3an CdX9IncaylVgDZU8Van9Berq/2a2EBz/07d8wZGt2BusQP9zfWYK5a9t2+D/92H4WhMz 9k8/OCOnWsTEQQ2swd3+GWfI+YDF8ZWS65D9d9xadJ+tpiIfEc+VRsxtv8aGJq30mubn Q/6O26g/Y3eJuc0f9189LJTW8hnxw4vV4nq/OaBxX1FeylCbRFGorsdtGmL7MrnylwHU KRfYSnwmdmBtAPtYeK4i/FdJF0H9Ba7Gm2v8gFAZ+SiT5FYPuwKTC6QN+Nx332u3XaB/ bw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 31xx1dvr63-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 01 Jul 2020 03:06:57 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0612wlHC085708; Wed, 1 Jul 2020 03:06:56 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 31xfvtbt98-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jul 2020 03:06:56 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06136sV0029228; Wed, 1 Jul 2020 03:06:54 GMT Received: from [192.168.0.110] (/183.246.145.120) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 01 Jul 2020 03:06:53 +0000 Subject: Re: [PATCH 1/2] workqueue: don't always set __WQ_ORDERED implicitly To: Lai Jiangshan Cc: LKML , Tejun Heo , martin.petersen@oracle.com, linux-scsi@vger.kernel.org, open-iscsi@googlegroups.com, lduncan@suse.com, michael.christie@oracle.com References: <20200611100717.27506-1-bob.liu@oracle.com> <52fa1d81-e585-37eb-55e5-0ed07ce7adc0@oracle.com> From: Bob Liu Message-ID: Date: Wed, 1 Jul 2020 11:06:41 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9668 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007010018 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9668 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 adultscore=0 suspectscore=0 mlxlogscore=999 cotscore=-2147483648 lowpriorityscore=0 malwarescore=0 phishscore=0 impostorscore=0 mlxscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007010019 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/29/20 8:37 AM, Lai Jiangshan wrote: > On Mon, Jun 29, 2020 at 8:13 AM Bob Liu wrote: >> >> On 6/28/20 11:54 PM, Lai Jiangshan wrote: >>> On Thu, Jun 11, 2020 at 6:29 PM Bob Liu wrote: >>>> >>>> Current code always set 'Unbound && max_active == 1' workqueues to ordered >>>> implicitly, while this may be not an expected behaviour for some use cases. >>>> >>>> E.g some scsi and iscsi workqueues(unbound && max_active = 1) want to be bind >>>> to different cpu so as to get better isolation, but their cpumask can't be >>>> changed because WQ_ORDERED is set implicitly. >>> >>> Hello >>> >>> If I read the code correctly, the reason why their cpumask can't >>> be changed is because __WQ_ORDERED_EXPLICIT, not __WQ_ORDERED. >>> >>>> >>>> This patch adds a flag __WQ_ORDERED_DISABLE and also >>>> create_singlethread_workqueue_noorder() to offer an new option. >>>> >>>> Signed-off-by: Bob Liu >>>> --- >>>> include/linux/workqueue.h | 4 ++++ >>>> kernel/workqueue.c | 4 +++- >>>> 2 files changed, 7 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h >>>> index e48554e..4c86913 100644 >>>> --- a/include/linux/workqueue.h >>>> +++ b/include/linux/workqueue.h >>>> @@ -344,6 +344,7 @@ enum { >>>> __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */ >>>> __WQ_LEGACY = 1 << 18, /* internal: create*_workqueue() */ >>>> __WQ_ORDERED_EXPLICIT = 1 << 19, /* internal: alloc_ordered_workqueue() */ >>>> + __WQ_ORDERED_DISABLE = 1 << 20, /* internal: don't set __WQ_ORDERED implicitly */ >>>> >>>> WQ_MAX_ACTIVE = 512, /* I like 512, better ideas? */ >>>> WQ_MAX_UNBOUND_PER_CPU = 4, /* 4 * #cpus for unbound wq */ >>>> @@ -433,6 +434,9 @@ struct workqueue_struct *alloc_workqueue(const char *fmt, >>>> #define create_singlethread_workqueue(name) \ >>>> alloc_ordered_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, name) >>>> >>>> +#define create_singlethread_workqueue_noorder(name) \ >>>> + alloc_workqueue("%s", WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | \ >>>> + WQ_UNBOUND | __WQ_ORDERED_DISABLE, 1, (name)) >>> >>> I think using __WQ_ORDERED without __WQ_ORDERED_EXPLICIT is what you >>> need, in which case cpumask is allowed to be changed. >>> >> >> I don't think so, see function workqueue_apply_unbound_cpumask(): >> >> wq_unbound_cpumask_store() >> > workqueue_set_unbound_cpumask() >> > workqueue_apply_unbound_cpumask() { >> ... >> 5276 /* creating multiple pwqs breaks ordering guarantee */ >> 5277 if (wq->flags & __WQ_ORDERED) >> 5278 continue; >> ^^^^ >> Here will skip apply cpumask if only __WQ_ORDERED is set. > > wq_unbound_cpumask_store() is for changing the cpumask of > *all* workqueues. I don't think it can be used to make > scsi and iscsi workqueues bound to different cpu. > > apply_workqueue_attrs() is for changing the cpumask of the specific > workqueue, which can change the cpumask of __WQ_ORDERED workqueue > (but without __WQ_ORDERED_EXPLICIT). > Yes, you are right. I made a mistake. Sorry for the noise. Regards, Bob >> >> 5280 ctx = apply_wqattrs_prepare(wq, wq->unbound_attrs); >> >> }