Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2127312ybt; Sun, 28 Jun 2020 08:56:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7WNr3vZ6Tc2ytA6qx2wX9TOivokbfmo4U8HPr7aRAOzwroUwV3sEg12ASw/4b2jd9a2wM X-Received: by 2002:a50:b2c2:: with SMTP id p60mr13028072edd.374.1593359770979; Sun, 28 Jun 2020 08:56:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593359770; cv=none; d=google.com; s=arc-20160816; b=xIfOBSD5n4KTmwz6PNf/6oLrXerB61tjq1bjz43n5aFf5UPpg09iACX4UprDglphlf Tnzp+v5IlEeHfkwNSh8oOCLa9jTbzOT/ExmkOqWeFt9WODbzwFMCRiJnNwVvoFmqO17Q ZyXBw0YTH2pLNPLUJKJvkIgDv1kmo9wSWu02DYiN8S7h5r28aA5YmBxqiaf7mG4Axwpw WP+TYoJSI6tMwJh8J0cyWNfzrE+mm6rQiqU060LCm8BlWIM4owmB4uwpQZjBp87efBD/ eU1NpgKQ9q6w6mFPs6HaNUNIvzymUko6d402Slh+5hdTcPmVHmkEF5EtGP11GvgO8hWK dzwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=sEfpGNC1wgHInVbFM/yJkO/397CoGeIpiR31ps+GqnY=; b=w/qZIJLhkLPv6RtXjan9Ze9bcHOXlVEQbwu4Flx32cAXlRMDoPzcVyPBCUeiNyHxl1 /5eLCDMdyM5ZycrqXerDhU02+lE1bym0eGQHKAVOECHSHRSrCmpl7MyVjegyC15eGe0z 7Bz1YX5zv1LUigduBrq6pcr5X64mLhwUGmWehQQivi2KkzuxTDz1YerM00JUGa65H4i2 9WCIzH6r4Fh/EZy5nezzPScK5TxZYBypirqoUhv9V/86ZncSTbkMyLTEaku26ZjXb/3v W/I4rT16GBcp/fJEn7UixXcK/vEHAebTalPSXvWxnoioi04nlVAqGn5ehZjqLG/uKPNT 8tmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RySqVmaj; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k19si11708235eji.419.2020.06.28.08.55.47; Sun, 28 Jun 2020 08:56:10 -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=@gmail.com header.s=20161025 header.b=RySqVmaj; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726075AbgF1Pyw (ORCPT + 99 others); Sun, 28 Jun 2020 11:54:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbgF1Pyv (ORCPT ); Sun, 28 Jun 2020 11:54:51 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A2F9C03E979; Sun, 28 Jun 2020 08:54:51 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id g18so14218893wrm.2; Sun, 28 Jun 2020 08:54:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sEfpGNC1wgHInVbFM/yJkO/397CoGeIpiR31ps+GqnY=; b=RySqVmajWV6OJ+iQX3hGEZ4N8UoeksvAL7R8YX+DoCwaicjMoJaqy342V+OpKzHsqi lPZ7R4qe5X2nZczwgkpCv3yI9NlZOSryVdb52+xYjoFqvQ9gX4b0HHd9IrC14w7Iklcb uFEIsCZxQps4O0qGBKX5GgyhxoIvTaG+iEaNSPDGVt0qFgxXPOvaL5Tsj6rItoVy+C+A 6E2eeL/708cAfNpuCiYhdeOJY0/A59LoAS8QaDmWW3POhxp0K3i94z+/1ScJEqH6zpFr D7KPM15Jsui4v9h53M6+2hRUX3Zb1b7Vcs2S+5po6Ixh2sPc5Ty8o7cmY/h4dELa4hwn XsHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sEfpGNC1wgHInVbFM/yJkO/397CoGeIpiR31ps+GqnY=; b=BhFCl2218dBr+fIiYNxL52MIlbv9pZwNQKrapZWXKr5jfaL7amDOjwcuryP2IZ7d/c ia2z5NTXJYv/cK+AUjqLAJrCvCLXWffJTld0HJxKX13CNeUy6EQI5ZrAIZwA4Te4q1f1 U/teA2Vli1ziNMlXdgq2kqo2J0tH5XtaMYpx3rhH7BrV3wJo/YqwvB9ebZUZQ6tmtpf+ RFxc3yafD2eLS7kDC3oLJHAICfqJUDbI0HGtwulQQfCi35WC6iLYoUpCRg4TTmmXIhiB pUDEeFdYkMVVhioi35PeqlnIQJmKn4RabSJSi1VsQ0P2Uh92IbR8cOigSEPtCxchvfw7 XYtQ== X-Gm-Message-State: AOAM533q9sPK4rHyTcaHXsKx4X1gDn+nRSp1uimNXmXTK30hAnE3VRUb 8MCvamTqGEJiYDVJURRjL6+UDf1vTNjNzXJ+tx4= X-Received: by 2002:a5d:55c9:: with SMTP id i9mr13066890wrw.404.1593359690077; Sun, 28 Jun 2020 08:54:50 -0700 (PDT) MIME-Version: 1.0 References: <20200611100717.27506-1-bob.liu@oracle.com> In-Reply-To: <20200611100717.27506-1-bob.liu@oracle.com> From: Lai Jiangshan Date: Sun, 28 Jun 2020 23:54:38 +0800 Message-ID: Subject: Re: [PATCH 1/2] workqueue: don't always set __WQ_ORDERED implicitly To: Bob Liu Cc: LKML , Tejun Heo , martin.petersen@oracle.com, linux-scsi@vger.kernel.org, open-iscsi@googlegroups.com, lduncan@suse.com, michael.christie@oracle.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Just use alloc_workqueue() with __WQ_ORDERED and max_active=1. It can be wrapped as a new function or macro, but I don't think create_singlethread_workqueue_noorder() is a good name for it. > extern void destroy_workqueue(struct workqueue_struct *wq); > > struct workqueue_attrs *alloc_workqueue_attrs(void); > diff --git a/kernel/workqueue.c b/kernel/workqueue.c > index 4e01c44..2167013 100644 > --- a/kernel/workqueue.c > +++ b/kernel/workqueue.c > @@ -4237,7 +4237,9 @@ struct workqueue_struct *alloc_workqueue(const char *fmt, > * on NUMA. > */ > if ((flags & WQ_UNBOUND) && max_active == 1) > - flags |= __WQ_ORDERED; > + /* the caller may don't want __WQ_ORDERED to be set implicitly. */ > + if (!(flags & __WQ_ORDERED_DISABLE)) > + flags |= __WQ_ORDERED; > > /* see the comment above the definition of WQ_POWER_EFFICIENT */ > if ((flags & WQ_POWER_EFFICIENT) && wq_power_efficient) > -- > 2.9.5 >