From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A62B4C4332F for ; Tue, 22 Nov 2022 06:08:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F3276B0071; Tue, 22 Nov 2022 01:08:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A31E6B0073; Tue, 22 Nov 2022 01:08:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 291D98E0001; Tue, 22 Nov 2022 01:08:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1D2936B0071 for ; Tue, 22 Nov 2022 01:08:40 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E1A08160D79 for ; Tue, 22 Nov 2022 06:08:39 +0000 (UTC) X-FDA: 80160049158.22.87590D4 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by imf10.hostedemail.com (Postfix) with ESMTP id 62B31C000A for ; Tue, 22 Nov 2022 06:08:39 +0000 (UTC) Received: by mail-qt1-f182.google.com with SMTP id cg5so8688075qtb.12 for ; Mon, 21 Nov 2022 22:08:38 -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=nvtCDUP6rJnaDAgvc9+5iA8LPz7fRjc1UY1GDYmZSu0bYjOgbOuGLcWJ0DGhKuXz0G Z0PCw0DtoftIpR8UbZvKJ+nxRfLeh3RWmuc2d1Gmmr9qo3Ac6QqlG/hXg9tCFnLOh7kv w2U59DhlQFYuk4FNqBU3zrsjc6ZT1xfzkliA+sGzHv0gtBmM/j6L3x0MEroWZU/kcrWM ZiMnAz1QGh2vhBTY9N/lVcC9eSKJF8sysHz5EA+ycf3Oh3jhjQ3Nod8yWjjJSSQwrLf8 CGNXyLs1HwMNgf4XBwVn/qpg4rMOcn05TvVqqmDezd0Qj5936lzyqIZRhAoTXXL+XE7+ 8nUA== X-Gm-Message-State: ANoB5pkdLbMDeU3IZGwi6Gt/N/b8bzmOKQjIWQegCGELq31+pIkYcrjX yeZA5BEdS0ogVr8ujfqfKgm1vw== X-Google-Smtp-Source: AA0mqf4MZyaRJuzNrsDcm7X9RlEVW6mYtPTQ5B8PULH/VPf6LbOJnZurhwxZDwAYGl+JeG7R7LfThQ== 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: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669097319; a=rsa-sha256; cv=none; b=bQJcPWhYvAffHzvqts2VgaysWPmXuvGOOIFiQXUpqMp0M/8w5X1rVAIohbndxHlBxroms8 cdwCZOU7iWIb6eSpZObqrfuYNfKGbzTzCPp/gNLeDdthnQME0CU8dEmXFYV4D68UFEzPIu QHkihGlCuW4FqKoBUM7wOTesPECr4W0= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=rw8NlRyu; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf10.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.182 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669097319; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xFskJ0PAbtgFIfn0uL3HVp5AGazR7CNgIuFH1JnZjto=; b=jmhNFJeYjVVt4LsVV8I33hZI2PylPwxbnzSu8ruFu7FvW00REF/TWjN2SZjFfWfgZas8Ql ss/nUyiTNmq8ar89yHkFTZ9rYnV3HlotYUx3RqgGBXuWlZHdabU1c6fxDKwHsEh96RqSgB T28zuZEGHeM3EmCuA8aYiUeIMRC9n28= X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 62B31C000A X-Rspam-User: Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=rw8NlRyu; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf10.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.182 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org X-Stat-Signature: ga4gk58dbdypc4sgsaqss34m5zgbp4ct X-HE-Tag: 1669097319-317138 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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().