Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5274049rwb; Mon, 21 Nov 2022 19:58:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf4ZYt3SuttTBj+WoUao92jzpNczkL/Yz6hhFfWw5/7v+D3dwZLqvrRnbz7noLbLxv7XdBHR X-Received: by 2002:a05:6402:3707:b0:467:6847:83d3 with SMTP id ek7-20020a056402370700b00467684783d3mr18956066edb.247.1669089521548; Mon, 21 Nov 2022 19:58:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669089521; cv=none; d=google.com; s=arc-20160816; b=WQvPX8/prYelYi6p2d5Usoay9fP4CV3GIQ1NXLH2bIWUTcgWLL69kFd6e6jicEO1bA 7vBX8Zt/y4KcIFSUgUiNLIlV5nqCq+OcXjaIukgDQuWKwnlZNyTPG1+kFqqEChooySrL ZlAvVfAtiZPwzqF6F6iquiLas0L2nQIP5k5YROw9dSwaUj6OdzF+wK3M/pQH+D4QNQGY a35adICvtKnq3Q13FlJT56LZlGAO86QwNT88fcD27yMp5gK89aVEjbB91ZApvSN9pAOj mGwFuvXQz7GtBTBqz7h++4xJfxgw2TrLdNb0qE+o7jB8JwFbJ24cuCEYggyk1/u5mhIf NuxA== 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=AptSfaygHWZ6DJuwqcME0BS6j60WJD3D2GSMZmjS0iI=; b=YaLADkD4fgHGuVuu/7js1gedPPn1DExFD/iI0AND9SoorVMJXQxc52GXSISa37yjUx ZqqTx1zIMjynjjjH4UF5BOCmgAWDr1EQ0RRcdhBje3woEUhQAcYED5ZJns0dntLDMuKa LVNlFiQG/aWelm4+9OlzZN4AbDEaHk6utWFUDlHymDBsLl5y5A1Z9zApJUAxzU+lElnC +cRDr0mi8mcPeIioq9tBO71k0oXWN7oNnw2twyQHMLZB0WYeOAx4A5tyHpjLbhNYFKYO ctdyMhdKu/qooU4Fjx+MM5yzi1tkbPDt1+AwXySKMxQwWpa6E1jOn38oEj3P7v/1lbI4 5ryw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DpSgZ5Mm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs31-20020a1709073e9f00b0078e27ef9501si10513243ejc.750.2022.11.21.19.58.19; Mon, 21 Nov 2022 19:58:41 -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=@chromium.org header.s=google header.b=DpSgZ5Mm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231954AbiKVDma (ORCPT + 91 others); Mon, 21 Nov 2022 22:42:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232187AbiKVDm2 (ORCPT ); Mon, 21 Nov 2022 22:42:28 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65213D93 for ; Mon, 21 Nov 2022 19:42:26 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id d192so13227313pfd.0 for ; Mon, 21 Nov 2022 19:42:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=AptSfaygHWZ6DJuwqcME0BS6j60WJD3D2GSMZmjS0iI=; b=DpSgZ5Mms4nVtop5BPuClMCwDJZqnFZrxxGyEjuUGMUeayLoFaOrapYYFcDWKUV7W+ LH8VlUgWhA/u/nF6uiIixkqv1+i6rp9E54GPOHhM7h3uuZ+fpV2qb+q6luUSeyBl3cgF KvgqZMk9WQa6fk8SluhrHqtcvxxRBY4ObaOoE= 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=AptSfaygHWZ6DJuwqcME0BS6j60WJD3D2GSMZmjS0iI=; b=lD6ea8c1ya66uNfe7ba6O7EiMk9DYmI13x2WCStSqNgTfpEbrZsDZI10zzHwkb1YZC 1fYQzUrflZvm/k8vGDcpZt0C0teXBYYFEBv6mg5PXQKLTRBZYLtra/se6uagBeigy3ii eQ14LY5QsNYke2rYWjIm+D9FoG/hNhHVqN8IS14BqlO21TaPO69CpXA5+6/AMzyFUhb4 Y/32+DwsnjCFaGnrF/rsVEoKDtnkldhaBUU4tZorS5cJPTmPlsk4SE+oxDFiH5gAxcbX k3KMTS+OdiaUcrlsrQG9t4uv0OJawXQGyMQP12VAhV2G+VEaey8sFJn5K9BhLn/bk/fm 6JAw== X-Gm-Message-State: ANoB5pmY9KBdBxVcvYx2PhmvaTwQHHz5Ou6fb4qZQONEPiTPGwB74a67 EAb5zRpuSnsSUp44i/K5q0P0FQ== X-Received: by 2002:a05:6a00:338c:b0:56b:a319:7b52 with SMTP id cm12-20020a056a00338c00b0056ba3197b52mr3135785pfb.21.1669088545928; Mon, 21 Nov 2022 19:42:25 -0800 (PST) Received: from google.com ([240f:75:7537:3187:e258:71ac:37b7:2d52]) by smtp.gmail.com with ESMTPSA id d12-20020a170902654c00b0017f5ba1fffasm6051055pln.297.2022.11.21.19.42.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 19:42:25 -0800 (PST) Date: Tue, 22 Nov 2022 12:42:20 +0900 From: Sergey Senozhatsky To: Johannes Weiner Cc: Sergey Senozhatsky , 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=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 (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(). On each iteration zs_reclaim_page() picks the new LRU tail (if any) and tries to write it back. > The number 8 is cribbed from zbud and z3fold. OK.