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 796BEC433FE for ; Tue, 22 Nov 2022 03:11:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 173596B0074; Mon, 21 Nov 2022 22:11:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1230A6B0075; Mon, 21 Nov 2022 22:11:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F2C858E0001; Mon, 21 Nov 2022 22:11:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D80986B0074 for ; Mon, 21 Nov 2022 22:11:47 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9CD82C06B2 for ; Tue, 22 Nov 2022 03:11:47 +0000 (UTC) X-FDA: 80159603454.09.EEB00D7 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by imf13.hostedemail.com (Postfix) with ESMTP id 111F920008 for ; Tue, 22 Nov 2022 03:11:46 +0000 (UTC) Received: by mail-qk1-f170.google.com with SMTP id j26so2300180qki.10 for ; Mon, 21 Nov 2022 19:11:46 -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=iHasZ5TNTFIcV1aNmBRElyhro7wai0QgU4JwVxsADWE=; b=fNxFFhXMdghSK2qF0UWo1QJ05yD5iNRjEj5tmtEOUsBbFxaj1tXcMaEuvQzYCkAabq l/eVSkCAAhOq5Gp1rOesNBaEAW3r6Rm/rDtgQf7kyy4Mmu/+MrkrBfTFEPFkjcHoysnt f6Qi7Iz6YxEJKwPB7pp2vYU/3pwC1j5nnb5XTBvfBGYYKvlzYqbx1ie8xQMroZ40zXIn 80yeJdJJRdRoYoBfnQYV2ilfe6PCw1Hk/Z9e/UjnNpLmGmuZMY3br/z06V+xgaI6TsDj pchkgHFP+IVZWhx3Wx/Mn54Td41K3iEQm4NLQCojX+fGuAK5bAPDAbwLOBth21jCZ4XJ Aoyg== 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=iHasZ5TNTFIcV1aNmBRElyhro7wai0QgU4JwVxsADWE=; b=N0bvkksx+EulyZsAy2AB8W73PTYlOt0nkw7+HxLWN3HBj3R/m5USfPaevnfn/Y4TgX 4HVXRHbRrgH9zoIGRvpWjw5g6vKRcAbV0knIJTi8pnY4qBMI42IKrPOqHt5B4OiL002l HRkrO+em3RL2xp2FjgwtPGmRw9rI6vC1hc/2XOY5Mz4JaDicaO1e1l5dCb+hCgHPyR2H hToC5Q3FtISqeqZp+PGyHgrTrkJD9sGUeIbZst9rxpKhJBWCvUinWLqGYKBwibWpM9Gd pA4QnUkR/YH5Aw+5k0NJIPrIevZF4MyNGfd9+WdO1CvkhuhAhIKT7FJjbpYb1dfj8B0R IVAQ== X-Gm-Message-State: ANoB5pkR5WLjStDUu21rJzTQ74+dxVqXZDOSrIblCqmxKSKfh6nwz1LM UCMtH1Dk6POklKUrbvyWf0nbEQ== X-Google-Smtp-Source: AA0mqf5Z2Vozl4gOnaKFDsiHthpk/cDNUJ2Q5EzCmvnce66G41XXifggMdqlH7hkJSgqnY9dxVNu0g== X-Received: by 2002:ae9:e714:0:b0:6fb:60da:96d0 with SMTP id m20-20020ae9e714000000b006fb60da96d0mr7214312qka.273.1669086706227; Mon, 21 Nov 2022 19:11:46 -0800 (PST) Received: from localhost ([2620:10d:c091:480::1:bc4]) by smtp.gmail.com with ESMTPSA id h4-20020a05620a284400b006f9e103260dsm9313929qkp.91.2022.11.21.19.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 19:11:45 -0800 (PST) Date: Mon, 21 Nov 2022 22:12:11 -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=1669086707; a=rsa-sha256; cv=none; b=G1ext0Jv65qB0GTjg1Fcw/e4b5qZnWyx3B1JgcbzDLUvHaF8ak5JWMns8C8AdMouz8r9Qv Ex1690cgpkCxtxL7ptdMcYgW5wTmId94/T5ilI3Ys9OWxOWvrVDyHiH3A6ptXhNRQGZhfG KFLiJu5IQkuloHIUAE6EX/VPNqc7v70= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=fNxFFhXM; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf13.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.170 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=1669086707; 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=iHasZ5TNTFIcV1aNmBRElyhro7wai0QgU4JwVxsADWE=; b=Z7l2JVwvD00db8/I0tvUGQs6p7WU/+57/6FsTuodIERE798Ri+4rv2fjBuruXxSCa+c7xB zc+EgmYNPPnEDH4TvVpJugHUSRf7hlX7P9tqkMxLxhcfoC3IN1oRWGmtXTMR8sHlsgeL0l 9nPOjL64a3BpkPnUt0ZG+gMaLX9dCa0= X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 111F920008 X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=fNxFFhXM; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf13.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.170 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org X-Stat-Signature: y5xspdj3ka1wsh1uyj5foh9yxb8anw9x X-HE-Tag: 1669086706-335741 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 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. Rejections are worse than moving on to the adjacent LRU item, because a rejected page, which should be at the head of the LRU, bypasses the list and goes straight to swap. The number 8 is cribbed from zbud and z3fold. It works well in practice, but is as arbitrary as MAX_RECLAIM_RETRIES used all over MM. We may want to revisit it at some point, but we should probably do it for all backends then.