Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5397992rwb; Mon, 21 Nov 2022 22:27:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf5KOpj70ACCrGw0++E/pHMEcfPGpfeyPHsGDcNpPJDX0gQuvViptw6++SMilb8SgGyk1IBX X-Received: by 2002:a17:902:aa06:b0:188:beef:b68f with SMTP id be6-20020a170902aa0600b00188beefb68fmr2180249plb.172.1669098477812; Mon, 21 Nov 2022 22:27:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669098477; cv=none; d=google.com; s=arc-20160816; b=a2Qa7MVqKzFNcQ0clokHl67srWnfKqF9cKhLgVQv3Do89TgwiYwu+BYuManOwM5hpH eWBaMtY/LHpteDhshQ32b0YnEjXMHZi9bB2vyZG4NAApmhfG2H3cimQOzueNqr8ZjELA W9ym/qI/EyelKsALDZpn0NPCDuKdeI9NJ169d/lqUmyzSNFiWuQEus3DmsiX1SzMZRf5 XF5XkGvO9S2xA46mRpm5u6JjLlqcIV9YJRirtWrN/F0UxL3ZqLnHy5iHPSUii43eOeF4 aLrmvqeyL0tldIXL1wLa6hqM4Yc+70e+r5XhnfJJEQDaZQNT/y/5jaqWuM104/r3sbs8 nMAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xFskJ0PAbtgFIfn0uL3HVp5AGazR7CNgIuFH1JnZjto=; b=vIhbXeMSrondUJ9SjZ4j0by3O0OhfKKzSVbe0QdNNkeJBdcUqoKXEdS4V1hEjw7GZF 4+IXYZuPbKA9jepR+OwFXV9QFq2CxRg187+NUmiSqc7PUW9iTDZ5graYc70z8K6Po1Xf iilS4JsBAkJDeYE6ohKRKeqfO4LZlpFZjdbW9t5Co3Uk6TOjT9Pkqep8r9TMBaxHJFrp B8kkeexUK1Aj2o/hrqbJijsPk4+3PYRQvkZ4aw0Tep96VVk+rcR6DkEg7zLtBZnEKbYW ZXgtZG+nKQfyF6YVr5fYSodRbppBSvuJSqdn7n0WhuoGrLO2mpsKXIvrnfBjFtbgXSgd nv/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=rw8NlRyu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n27-20020aa7985b000000b0056d67d820ecsi12678242pfq.258.2022.11.21.22.27.46; Mon, 21 Nov 2022 22:27:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=rw8NlRyu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230468AbiKVGIv (ORCPT + 91 others); Tue, 22 Nov 2022 01:08:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232111AbiKVGIm (ORCPT ); Tue, 22 Nov 2022 01:08:42 -0500 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AF7427FD1 for ; Mon, 21 Nov 2022 22:08:39 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id l15so8720271qtv.4 for ; Mon, 21 Nov 2022 22:08:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=xFskJ0PAbtgFIfn0uL3HVp5AGazR7CNgIuFH1JnZjto=; b=rw8NlRyuGxY6d5ZNpzVhw9cBBb4EMOWfLG8jrdsZw8IjevwHWns1Yz190g+2obWupB Q6BWJCPtrgxPlIujgeEWC7uFYltzkXhkFf+OMGxDrtq4v/jdNVTOiPhbL3TVGieWOS/z CQPER3TvXJVG+gv7LWLDLlbwrKUfENrDxBZM6lnkqrDlloWNrAZy2/QIqDj/82CWf2pl wlbDPw7QAMLTMBG+nsdnsxY5TPlBBcu6WdbGBdWEvxhCD/fY1kB6QfPJH+3bhqb52xY/ 1Wb+NctFMyUrrNuP3SDJ/JUHgILeZt4QeTChICBQl0+Fejm2v9np6m+4X+GMAZ97jCfd 1TNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xFskJ0PAbtgFIfn0uL3HVp5AGazR7CNgIuFH1JnZjto=; b=iDJPUVlku3WB4/YbC/EhrUSVanA+1kGY1hHPgOTau2A8D39icyKp6BNWjiw1H3ExRo gDVoXCjB7ehghezVa3YHE5hZhSEWjZqUZ6rPmzMvu8NwfHQfxlEisj80GkHHVgLb9uza SPzNzJNlv6TL5NvnBBY8OkwXjuN/NRE+AFlpmm4FKS6w+PnbdDjXieEm+ph0/V+tNKox A0e8EFAENga1zQLG9uVO+3gChBPQunXfISP/D/2iajDU7D5yHF7LSzlYFUxmtXBWwJQ3 EAhZmx2opn4DGD+sq0KDZNdRkw1br8M4XPsjnQWn3HUNsv72BPWU2TugC6jnfP/OH/U4 xhEw== X-Gm-Message-State: ANoB5pktk3B4ejcEy3h3H4AeHWrUegiiSBS4ISQKCp+K6vg32qs0TBcY 4MGykmjl/XQ+fu3tKb0P6aMy3Q== X-Received: by 2002:ac8:7447:0:b0:3a5:75dc:ed0a with SMTP id h7-20020ac87447000000b003a575dced0amr2262440qtr.329.1669097318535; Mon, 21 Nov 2022 22:08:38 -0800 (PST) Received: from localhost ([2620:10d:c091:480::1:bc4]) by smtp.gmail.com with ESMTPSA id u12-20020a05620a084c00b006ee949b8051sm9235671qku.51.2022.11.21.22.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 22:08:38 -0800 (PST) Date: Tue, 22 Nov 2022 01:09:03 -0500 From: Johannes Weiner To: Sergey Senozhatsky Cc: Nhat Pham , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, minchan@kernel.org, ngupta@vflare.org, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com Subject: Re: [PATCH v6 6/6] zsmalloc: Implement writeback mechanism for zsmalloc Message-ID: References: <20221119001536.2086599-1-nphamcs@gmail.com> <20221119001536.2086599-7-nphamcs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 22, 2022 at 12:42:20PM +0900, Sergey Senozhatsky wrote: > On (22/11/21 22:12), Johannes Weiner wrote: > > On Tue, Nov 22, 2022 at 11:15:20AM +0900, Sergey Senozhatsky wrote: > > > On (22/11/18 16:15), Nhat Pham wrote: > > > > + > > > > +static int zs_zpool_shrink(void *pool, unsigned int pages, > > > > + unsigned int *reclaimed) > > > > +{ > > > > + unsigned int total = 0; > > > > + int ret = -EINVAL; > > > > + > > > > + while (total < pages) { > > > > + ret = zs_reclaim_page(pool, 8); > > > > + if (ret < 0) > > > > + break; > > > > + total++; > > > > + } > > > > + > > > > + if (reclaimed) > > > > + *reclaimed = total; > > > > + > > > > + return ret; > > > > +} > > > > > > A silly question: why do we need a retry loop in zs_reclaim_page()? > > > > Individual objects in a zspage can be busy (swapped in simultaneously > > for example), which will prevent the zspage from being freed. Zswap > > currently requests reclaim of one backend page at a time (another > > project...), so if we don't retry we're not meeting the reclaim goal > > and cause rejections for new stores. > > What I meant was: if zs_reclaim_page() makes only partial progress > with the current LRU tail zspage and returns -EAGAIN, then we just > don't increment `total` and continue looping in zs_zpool_shrink(). Hm, but it breaks on -EAGAIN, it doesn't continue. This makes sense, IMO. zs_reclaim_page() will try to reclaim one page, but considers up to 8 LRU tail pages until one succeeds. If it does, it continues (total++). But if one of these calls fails, we exit the loop, give up and return failure from zs_zpool_shrink().