Message ID | 20231211052850.3513230-1-debug.penguin32@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6846626vqy; Sun, 10 Dec 2023 21:37:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFC7b1hnW92sm+T2B9AaovoHP0LaJK/ZdGRC29Pt6l/9IAWyzsTSuPL36DPlaLgnqoSzeF1 X-Received: by 2002:a05:6a21:a5a2:b0:18f:1dc8:882b with SMTP id gd34-20020a056a21a5a200b0018f1dc8882bmr5767218pzc.21.1702273038774; Sun, 10 Dec 2023 21:37:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702273038; cv=none; d=google.com; s=arc-20160816; b=htc35OOpzNZ+eZzcaN0oVNF4UizQASzUtTREK28d6ge2/87gcaW397+8fVbgjWsyiv 8VaE5GD2akrsX7+9eO8sNii6uDn3087gNWmDx4KNH1IBj9A1yLQydUahqk/mlqEUcl58 mbIkC9Lk3drgHxVJZ931URU29ZSXhD4AdprG1kCRCSy6KwDlBXutYLZbPNhMYfVUvu/M Vh/uVlssh97KETSEkh+7om74vEYeNrbiwEj2rqEF2Fbz/XKD1r7xX9fL+S+j8A2UV+j9 cwCUVcBgtqc/bRFYPNwqRvdSFss5IkojP3YtYC6+6N97MPSvUw0O3XUA3BioKHCnm8Ri C33w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=hfVl0zhVcrsmg6t5d7DiGBu3+0T17ial1OcP+myLVb8=; fh=ctLU+uAVDTMi7uZU3C97gmjTGHoqWqcuTsk3s0DraTc=; b=TiNyYOZRja+vzXQBvJ9JwsYN7DIVDzehn9VveWaNK/jyDcTPzApvlH4bf7UboUZk04 Z/4m2SIMSNMl2tmjEH5QjmeU3k4VSp3flsnZGIZe9gVjvvjQL5//SjN3fuG53CVK+oPs Dpn9WMwWmkGYsBEpQK/ri/jGUDmtjNoKj+e5Vbuv0Zg9vczx5NOme2e/VixY3EDhHzFs 5As0OWfxbDmTp29wOzUp2xdB1N2jYfGJCvUEYR1bv3E8umc49c6QsZ9fsIRlv6O3YQ3L jOWrA39+jd8EDTA3I2fempJtHlOXrHYDlQsebypNzSZPRLTMKcqp+C/TTwL6i5rP5D0o wJjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20230601 header.b=BhpzvzDn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e12-20020a65688c000000b005b96662f77asi5502253pgt.482.2023.12.10.21.37.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 21:37:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20230601 header.b=BhpzvzDn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id AA09B809502F; Sun, 10 Dec 2023 21:37:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229990AbjLKFbi (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Mon, 11 Dec 2023 00:31:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbjLKFbh (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 11 Dec 2023 00:31:37 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCC06D7 for <linux-kernel@vger.kernel.org>; Sun, 10 Dec 2023 21:31:43 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40c26a45b2dso21583665e9.1 for <linux-kernel@vger.kernel.org>; Sun, 10 Dec 2023 21:31:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702272702; x=1702877502; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hfVl0zhVcrsmg6t5d7DiGBu3+0T17ial1OcP+myLVb8=; b=BhpzvzDnVg1dT61O231xo5wbAC/dd+BxrnVi2IjgSK8DJ7wpFWtYr48ix6OuJcFoNk auDwa/hlJpEbELeui/V0rrtwEJCqvEcaO4qYhFN1v6YSZf9VAL5eCyZlEk8dqPBFlXtV 9TdWl3ibMLp2C/kJ/VvcIBrBoATEeHLfd5xtFqk5JfthOc5AhalUx5FZpl9Hdsom5Fy1 /q74wH6iSEZRlREpgd/cVpuU0l16D9smAzaCCA1Tbzj72k58VI0iN9hI3UgARCEVoQoT 1u22fU/UuRDhXeV7SkUu2AEoizNpA/4UOW8D5R//6NKgP+cKVttU+PW+zubG/rN9O9mp B8WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702272702; x=1702877502; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hfVl0zhVcrsmg6t5d7DiGBu3+0T17ial1OcP+myLVb8=; b=QhwL+d33++N4g/xgI4CMGAkYYZ61D5hBL19TvdxOe9aSvIGYUPs0e+imqb/705DPLv q2o1Wken1wWAptO8C6X3NIInwmXkvOupmBMYhzNruZwFnkxi/epBRQhAianl46384IQU rnzlSL4Rmntlr+m+l7LzSxaDKYX2vYICQcyJvtzgDlZZ4Q7atlMLHmpHP66CKAVw/QOI Ir/6Y8lD06YP34Ru3P5QIHKYhtXaNO+ISumqUGOd7Q90RRl7AYsBwvXc5++jN8JfVDmC iiNvBGTQ5uFjOVFlgOO58W46lUtAvheqBDEltkhx3xoVueJpbwcVc4j9rEvBnVRgfbyo VSCw== X-Gm-Message-State: AOJu0YzG43CRuL9bnEmynunFuViVb+xFcAMyPcOmwx1g9yPbQC8OSvie +iU1B82UP3z9LXRv0iDmpER+TDktIWs= X-Received: by 2002:a05:600c:3503:b0:40c:32f9:afd4 with SMTP id h3-20020a05600c350300b0040c32f9afd4mr1873235wmq.9.1702272702050; Sun, 10 Dec 2023 21:31:42 -0800 (PST) Received: from eagle-5590.. ([193.160.245.66]) by smtp.gmail.com with ESMTPSA id m8-20020adffa08000000b00333332a8d39sm7639223wrr.55.2023.12.10.21.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 21:31:41 -0800 (PST) From: Ronald Monthero <debug.penguin32@gmail.com> Cc: sjenning@redhat.com, akpm@linux-foundation.org, Ronald Monthero <debug.penguin32@gmail.com>, Dan Streetman <ddstreet@ieee.org>, Vitaly Wool <vitaly.wool@konsulko.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm/zswap: Improve with alloc_workqueue() call Date: Mon, 11 Dec 2023 15:28:49 +1000 Message-Id: <20231211052850.3513230-1-debug.penguin32@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 10 Dec 2023 21:37:17 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784962653563192025 X-GMAIL-MSGID: 1784962653563192025 |
Series |
mm/zswap: Improve with alloc_workqueue() call
|
|
Commit Message
Ronald Monthero
Dec. 11, 2023, 5:28 a.m. UTC
Use alloc_workqueue() to create and set finer
work item attributes instead of create_workqueue()
which is to be deprecated.
Signed-off-by: Ronald Monthero <debug.penguin32@gmail.com>
---
mm/zswap.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Sun, Dec 10, 2023 at 9:31 PM Ronald Monthero <debug.penguin32@gmail.com> wrote: > > Use alloc_workqueue() to create and set finer > work item attributes instead of create_workqueue() > which is to be deprecated. > > Signed-off-by: Ronald Monthero <debug.penguin32@gmail.com> > --- > mm/zswap.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/zswap.c b/mm/zswap.c > index 74411dfdad92..64dbe3e944a2 100644 > --- a/mm/zswap.c > +++ b/mm/zswap.c > @@ -1620,7 +1620,8 @@ static int zswap_setup(void) > zswap_enabled = false; > } > > - shrink_wq = create_workqueue("zswap-shrink"); > + shrink_wq = alloc_workqueue("zswap-shrink", > + WQ_UNBOUND|WQ_MEM_RECLAIM, 0); Hmmm this changes the current behavior a bit right? create_workqueue() is currently defined as: alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name)) I think this should be noted in the changelog, at the very least, even if it is fine. We should be as explicit as possible about behavior changes. > if (!shrink_wq) > goto fallback_fail; > > -- > 2.34.1 > >
Hi Nhat, Thanks for checking. On Tue, Dec 12, 2023 at 12:16 AM Nhat Pham <nphamcs@gmail.com> wrote: > > On Sun, Dec 10, 2023 at 9:31 PM Ronald Monthero > <debug.penguin32@gmail.com> wrote: > > > > Use alloc_workqueue() to create and set finer > > work item attributes instead of create_workqueue() > > which is to be deprecated. > > > > Signed-off-by: Ronald Monthero <debug.penguin32@gmail.com> > > --- > > mm/zswap.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/mm/zswap.c b/mm/zswap.c > > index 74411dfdad92..64dbe3e944a2 100644 > > --- a/mm/zswap.c > > +++ b/mm/zswap.c > > @@ -1620,7 +1620,8 @@ static int zswap_setup(void) > > zswap_enabled = false; > > } > > > > - shrink_wq = create_workqueue("zswap-shrink"); > > + shrink_wq = alloc_workqueue("zswap-shrink", > > + WQ_UNBOUND|WQ_MEM_RECLAIM, 0); > > Hmmm this changes the current behavior a bit right? create_workqueue() > is currently defined as: > > alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name)) create_workqueue is deprecated and it's observed that most of the subsystems have changed to using alloc_workqueue. So it's a small minority of few remnant instances in the kernel and some drivers still using create_workqueue. With the create_workqueue defined as is , it hardcodes the workqueue flags to be per cpu and unbound in nature and not giving the flexibility of using any other wait queue flags/attributes. ( WQ_CPU_INTENSIVE, WQ_HIGHPRI, WQ_RESCUER, WQ_FREEZEABLE, WQ_UNBOUND) . Hence most of the subsystems and drivers use the alloc_workqueue( ) api. #define create_workqueue(name) \ alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name)) > I think this should be noted in the changelog, at the very least, even > if it is fine. We should be as explicit as possible about behavior > changes. > imo, it's sort of known and consistently changed for quite some time already. https://lists.openwall.net/linux-kernel/2016/06/07/1086 https://lists.openwall.net/linux-kernel/2011/01/03/124 https://lwn.net/Articles/403891/ => quoted: "The long-term plan, it seems, is to convert all create_workqueue() users over to an appropriate alloc_workqueue() call; eventually create_workqueue() will be removed" glad to take some suggestions , thoughts ? BR, ronald
On Wed, Dec 13, 2023 at 5:20 AM Ronald Monthero <debug.penguin32@gmail.com> wrote: > > Hi Nhat, > Thanks for checking. > On Tue, Dec 12, 2023 at 12:16 AM Nhat Pham <nphamcs@gmail.com> wrote: > > > > On Sun, Dec 10, 2023 at 9:31 PM Ronald Monthero > > <debug.penguin32@gmail.com> wrote: > > > > > > Use alloc_workqueue() to create and set finer > > > work item attributes instead of create_workqueue() > > > which is to be deprecated. > > > > > > Signed-off-by: Ronald Monthero <debug.penguin32@gmail.com> > > > --- > > > mm/zswap.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/mm/zswap.c b/mm/zswap.c > > > index 74411dfdad92..64dbe3e944a2 100644 > > > --- a/mm/zswap.c > > > +++ b/mm/zswap.c > > > @@ -1620,7 +1620,8 @@ static int zswap_setup(void) > > > zswap_enabled = false; > > > } > > > > > > - shrink_wq = create_workqueue("zswap-shrink"); > > > + shrink_wq = alloc_workqueue("zswap-shrink", > > > + WQ_UNBOUND|WQ_MEM_RECLAIM, 0); > > > > Hmmm this changes the current behavior a bit right? create_workqueue() > > is currently defined as: > > > > alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name)) > > create_workqueue is deprecated and it's observed that most of the > subsystems have changed to using alloc_workqueue. So it's a small > minority of few remnant instances in the kernel and some drivers still > using create_workqueue. With the create_workqueue defined as is , it > hardcodes the workqueue flags to be per cpu and unbound in nature and > not giving the flexibility of using any other wait queue > flags/attributes. ( WQ_CPU_INTENSIVE, WQ_HIGHPRI, WQ_RESCUER, > WQ_FREEZEABLE, WQ_UNBOUND) . Hence most of the subsystems and drivers > use the alloc_workqueue( ) api. > #define create_workqueue(name) \ > alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name)) > > > I think this should be noted in the changelog, at the very least, even > > if it is fine. We should be as explicit as possible about behavior > > changes. > > > imo, it's sort of known and consistently changed for quite some time already. > https://lists.openwall.net/linux-kernel/2016/06/07/1086 > https://lists.openwall.net/linux-kernel/2011/01/03/124 > https://lwn.net/Articles/403891/ => quoted: "The long-term plan, it > seems, is to convert all create_workqueue() users over to an > appropriate alloc_workqueue() call; eventually create_workqueue() will > be removed" > > glad to take some suggestions , thoughts ? > > BR, > ronald I should have been clearer. I'm not against the change per-se - I agree that we should replace create_workqueue() with alloc_workqueue(). What I meant was, IIUC, there are two behavioral changes with this new workqueue creation: a) We're replacing a bounded workqueue (which as you noted, is fixed by create_workqueue()) with an unbounded one (WQ_UNBOUND). This seems fine to me - I doubt locality buys us much here. b) create_workqueue() limits the number of concurrent per-cpu execution contexts at 1 (i.e only one single global reclaimer), whereas after this patch this is set to the default value. This seems fine to me too - I don't remember us taking advantage of the previous concurrency limitation. Also, in practice, the task_struct is one-to-one with the zswap_pool's anyway, and most of the time, there is just a single pool being used. (But it begs the question - what's the point of using 0 instead of 1 here?) Both seem fine (to me anyway - other reviewers feel free to take a look and fact-check everything). I just feel like this should be explicitly noted in the changelog, IMHO, in case we are mistaken and need to revisit this :) Either way, not a NACK from me.
On Wed, Dec 13, 2023 at 4:28 PM Nhat Pham <nphamcs@gmail.com> wrote: > > concurrency limitation. Also, in practice, the task_struct is /s/task/work. I was looking at some articles about tasks recently, so my brain just auto-completed. I was referring to pool->shrink_work here.
On Thu, Dec 14, 2023 at 10:28 AM Nhat Pham <nphamcs@gmail.com> wrote: > .. < snipped > > I should have been clearer. I'm not against the change per-se - I > agree that we should replace create_workqueue() with > alloc_workqueue(). What I meant was, IIUC, there are two behavioral > changes with this new workqueue creation: > > a) We're replacing a bounded workqueue (which as you noted, is fixed > by create_workqueue()) with an unbounded one (WQ_UNBOUND). This seems > fine to me - I doubt locality buys us much here. Yes the workqueue attribute change per se but the existing functionality remains seamless and the change is more a forward looking change. imo under a memory pressure scenario an unbound workqueue might workaround the scenario better as the number of backing pools is dynamic. And with the WQ_UNBOUND attribute the scheduler is more open to exercise some improvisations in any demanding scenarios for offloading cpu time slicing for workers, ie if any other worker of the same primary cpu had to be served due to workers with WQ_HIGHPRI and WQ_CPU_INTENSIVE.Although normal and highpri worker-pools don't interact with each other, the target cpu atleast need not be the same if our worker for zswap is WQ_UNBOUND. Also noting that the existing wq of zwap worker has the WQ_MEM_RECLAIM attribute, so is there a rescue worker for zswap during a memory pressure scenario ? Quoting: "All work items which might be used on code paths that handle memory reclaim are required to be queued on wq's that have a rescue-worker reserved for execution under memory pressure. Else it is possible that the worker-pool deadlocks waiting for execution contexts to free up" Also additional thought if adding WQ_FREEZABLE attribute while creating the zswap worker make sense in scenarios to handle freeze and unfreeze of specific cgroups or file system wide freeze and unfreeze scenarios ? Does zswap worker participate in freeze/unfreeze code path scenarios ? > b) create_workqueue() limits the number of concurrent per-cpu > execution contexts at 1 (i.e only one single global reclaimer), > whereas after this patch this is set to the default value. This seems > fine to me too - I don't remember us taking advantage of the previous > concurrency limitation. Also, in practice, the task_struct is > one-to-one with the zswap_pool's anyway, and most of the time, there > is just a single pool being used. (But it begs the question - what's > the point of using 0 instead of 1 here?) Nothing in particular but I left it at default 0, which can go upto 256 ( @maxactive per cpu). But if zswap worker is always intended to only have 1 active worker per cpu, then that's fine with 1, otherwise a default setting might be flexible for scaling. just a thought, does having a higher value help for larger memory systems ? > Both seem fine (to me anyway - other reviewers feel free to take a > look and fact-check everything). I just feel like this should be > explicitly noted in the changelog, IMHO, in case we are mistaken and > need to revisit this :) Either way, not a NACK from me. Thanks Nhat, for checking. Above are my thoughts, I could be missing some info or incorrect on certain fronts so I would seek clarifications. Also thanks in advance to other experts/maintainers, please share feedback and suggestions. BR, ronald
On Fri, Dec 15, 2023 at 1:04 AM Ronald Monthero <debug.penguin32@gmail.com> wrote: > > On Thu, Dec 14, 2023 at 10:28 AM Nhat Pham <nphamcs@gmail.com> wrote: > > > .. > < snipped > > > > I should have been clearer. I'm not against the change per-se - I > > agree that we should replace create_workqueue() with > > alloc_workqueue(). What I meant was, IIUC, there are two behavioral > > changes with this new workqueue creation: > > > > a) We're replacing a bounded workqueue (which as you noted, is fixed > > by create_workqueue()) with an unbounded one (WQ_UNBOUND). This seems > > fine to me - I doubt locality buys us much here. > > Yes the workqueue attribute change per se but the existing > functionality remains seamless and the change is more a forward > looking change. imo under a memory pressure scenario an unbound > workqueue might workaround the scenario better as the number of > backing pools is dynamic. And with the WQ_UNBOUND attribute the > scheduler is more open to exercise some improvisations in any > demanding scenarios for offloading cpu time slicing for workers, ie if > any other worker of the same primary cpu had to be served due to > workers with WQ_HIGHPRI and WQ_CPU_INTENSIVE.Although normal and > highpri worker-pools don't interact with each other, the target cpu > atleast need not be the same if our worker for zswap is WQ_UNBOUND. I don't object to the change per-se. I just meant that these changes/discussion should be spelled out in the patch's changelog :) IMHO, we should document behavior changes if there are any. For instance, when we switched to kmap_local_page() for zswap, there is a discussion in the changelog regarding how it differs from the old (and deprecated) kmap_atomic(): https://lore.kernel.org/linux-mm/20231127160058.586446-1-fabio.maria.de.francesco@linux.intel.com/ and how that difference doesn't matter in the case of zswap. > > Also noting that the existing wq of zwap worker has the WQ_MEM_RECLAIM > attribute, so is there a rescue worker for zswap during a memory > pressure scenario ? > Quoting: "All work items which might be used on code paths that handle > memory reclaim are required to be queued on wq's that have a > rescue-worker reserved for execution under memory pressure. Else it is > possible that the worker-pool deadlocks waiting for execution contexts > to free up" Seems like it, but this behavior is not changed by your patch :) So i'm not too concerned by it one way or another. > > Also additional thought if adding WQ_FREEZABLE attribute while > creating the zswap worker make sense in scenarios to handle freeze and > unfreeze of specific cgroups or file system wide freeze and unfreeze > scenarios ? Does zswap worker participate in freeze/unfreeze code path > scenarios ? I don't think so, no? This zswap worker is scheduled upon the zswap pool limit hit (which happens on the zswap store/swapping/memory reclaim) path. > > > b) create_workqueue() limits the number of concurrent per-cpu > > execution contexts at 1 (i.e only one single global reclaimer), > > whereas after this patch this is set to the default value. This seems > > fine to me too - I don't remember us taking advantage of the previous > > concurrency limitation. Also, in practice, the task_struct is > > one-to-one with the zswap_pool's anyway, and most of the time, there > > is just a single pool being used. (But it begs the question - what's > > the point of using 0 instead of 1 here?) > > Nothing in particular but I left it at default 0, which can go upto > 256 ( @maxactive per cpu). > But if zswap worker is always intended to only have 1 active worker per cpu, > then that's fine with 1, otherwise a default setting might be flexible > for scaling. > just a thought, does having a higher value help for larger memory systems ? I don't think having higher value helps here tbh. We only have one work_struct per pool, so it shouldn't make a difference either way :) > > > Both seem fine (to me anyway - other reviewers feel free to take a > > look and fact-check everything). I just feel like this should be > > explicitly noted in the changelog, IMHO, in case we are mistaken and > > need to revisit this :) Either way, not a NACK from me. > > Thanks Nhat, for checking. Above are my thoughts, I could be missing > some info or incorrect > on certain fronts so I would seek clarifications. > Also thanks in advance to other experts/maintainers, please share > feedback and suggestions. > > BR, > ronald Also +Chris Li, who is also working on improving zswap :)
diff --git a/mm/zswap.c b/mm/zswap.c index 74411dfdad92..64dbe3e944a2 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1620,7 +1620,8 @@ static int zswap_setup(void) zswap_enabled = false; } - shrink_wq = create_workqueue("zswap-shrink"); + shrink_wq = alloc_workqueue("zswap-shrink", + WQ_UNBOUND|WQ_MEM_RECLAIM, 0); if (!shrink_wq) goto fallback_fail;