Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5677174rdb; Wed, 13 Dec 2023 16:30:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IF4OZ8cZogU/sgzjlRpUqErxgw7rw9Qqm/N1ioxIHXi2Lb2KXN1ip8MHkLqlWiXGtQFvx0F X-Received: by 2002:a05:6e02:18c7:b0:35d:61e2:16ed with SMTP id s7-20020a056e0218c700b0035d61e216edmr13430447ilu.9.1702513843439; Wed, 13 Dec 2023 16:30:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702513843; cv=none; d=google.com; s=arc-20160816; b=WZZIrmme45I0pVIgGvCmO2hNwz/wxniAGSqAarsmidLSagAD4pZuX7WiMhzMjlxFc2 rMqW4Cw52bOGCy00VvCSeJYTORaFMyAXuj4aFtKDY1JA1+ueJ8ziHPsGCCqCyXzJ8645 dXnKBe0iFKiTRC1XLigLGchgb3qtfyjjybv19Upz/zoCHZYNhTSvkoOpQgppt9ZUVKYt nh9MseINS1o0+2Xa4PTxR73R92XyF3sD/l0TbwWZfeUIja7LMd5hgmiGEL+1bg7GCp8n he203qlSGEuqo+lJsh7HVOqTxVRMfohVoMlwSamDjvBQ4jT30eSSiJjdMT8zoYIIlHJ3 oq0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=IOSXxu0Ty5SRYxvtBv47EJc9VazQTq5FR1JKdC1EXXI=; fh=rYn4Rpi2RjZpGfoO5D/xhph2Rs7DjAJ0pKP94bI8UgY=; b=Z4xNSIM/bDPL/S7rod2XirsaVHCtXa5k1F0+rPas+6kRommG+vJtswxOiceuo0dLK5 PmMk1AR61UdwdraMFXdjb4tasIVPtHjX0ndCJamhmFL1/+6m+XJZbeQk19YfE5mln3kF uua52Xt5tmvRuUXlyc+A4KYdzinHRn9qaH7SU8t2XR7KvEZs0QrqVDmMosI6oVwY/3Jl 83QOA/E1Ysntvsjb0M8iRELKJ4GKYrAgtbDwseGBPwUAd0G6rwZN1tP7FAYlSJDLWJ0l 9w8OZ/jyD6zDkPxpeljDsIo0nGy6tLbMZsDuppMA4BhYAA7/c6xQ3acFu4HH0gUUZgUw RvKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QDCE7vVI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id k2-20020a63f002000000b005bdf597ed49si10511006pgh.56.2023.12.13.16.30.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 16:30:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QDCE7vVI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 morse.vger.email (Postfix) with ESMTP id 6ED07809C43B; Wed, 13 Dec 2023 16:30:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234086AbjLNA2U (ORCPT + 99 others); Wed, 13 Dec 2023 19:28:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230122AbjLNA2T (ORCPT ); Wed, 13 Dec 2023 19:28:19 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89631D0 for ; Wed, 13 Dec 2023 16:28:25 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-35d718382b7so31291285ab.1 for ; Wed, 13 Dec 2023 16:28:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702513705; x=1703118505; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=IOSXxu0Ty5SRYxvtBv47EJc9VazQTq5FR1JKdC1EXXI=; b=QDCE7vVIY78NTdQ9XluI2oW8wwIFVZpfq0lzriZAmrPM0gwM/PkfWcCq6gAfAjcqS6 Ka19swcDBm4Sc0wa1XokZGB7ik1d20AYBCXyxYXpH8TjPGK3KtCJOICPmZWuxLZGk3Dn XDIizSluSF1vXG3dACqEHjMhxU0TFBNJvt2XQCbf93Kb6Vfhty71Xg4QtLYBE43EtRLc wKnZ+GdoGFpXu5v5Ck0i9F4pX6cVR74rzelsYIrVTwfbICDYXyS1ftn48FwKMn5AVpe8 b6Mr0g1Wq9cEpRuvSATC+Od1h7nxufw2pawV4p4Jt05UoclsnL0x4kmp0tMwPIWG/e09 z9/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702513705; x=1703118505; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IOSXxu0Ty5SRYxvtBv47EJc9VazQTq5FR1JKdC1EXXI=; b=e65krjGPpSklgVD2uouGKZY55A3HH7Ea+S6jECduAMruHwE56KQ0H7SrZtKmPY7zp4 ed+Sh7QR3KGJfR9zhAySC3opOHN2qyCu9d3tijI5dAqcol8pWQsvwNOj5u+49suhh5NZ rTxAHcgHJiu3kbY8/iIcAcAyh5yFIyRnA+S1Iyz59Tr9B858BqEXfySrpBIgKxcU9mw7 7L7pfeouV67Z637gdAAn0M1zQ3hc0NUK4+QF2KePfhUqBVCwVZitxUAeN5hw9G5M70En uuv/P8TT7F1hpyK41M6ZS0Q1cnKFVXTKrb+J3lTcNsHC1QG6ovoj9Zb+2/rEPIhWvvDr //Lg== X-Gm-Message-State: AOJu0YyGlcW1JlFR8ruBEBh9XC1QYY4lnfmIzSSj7eRw75uSR+rcesgo 6GwRfUfacb+YzHnDXQP5c/EB2wLdJAUzG/4UHztFRvz68yk= X-Received: by 2002:a05:6e02:1c4d:b0:35f:7629:87d3 with SMTP id d13-20020a056e021c4d00b0035f762987d3mr1990455ilg.43.1702513704644; Wed, 13 Dec 2023 16:28:24 -0800 (PST) MIME-Version: 1.0 References: <20231211052850.3513230-1-debug.penguin32@gmail.com> In-Reply-To: From: Nhat Pham Date: Wed, 13 Dec 2023 16:28:13 -0800 Message-ID: Subject: Re: [PATCH] mm/zswap: Improve with alloc_workqueue() call To: Ronald Monthero Cc: sjenning@redhat.com, akpm@linux-foundation.org, Dan Streetman , Vitaly Wool , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 16:30:25 -0800 (PST) On Wed, Dec 13, 2023 at 5:20=E2=80=AFAM Ronald Monthero wrote: > > Hi Nhat, > Thanks for checking. > On Tue, Dec 12, 2023 at 12:16=E2=80=AFAM Nhat Pham wr= ote: > > > > On Sun, Dec 10, 2023 at 9:31=E2=80=AFPM Ronald Monthero > > 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 > > > --- > > > 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 =3D false; > > > } > > > > > > - shrink_wq =3D create_workqueue("zswap-shrink"); > > > + shrink_wq =3D 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 alre= ady. > 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/ =3D> 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.