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 46051C3DA63 for ; Tue, 23 Jul 2024 16:44:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86CD66B00E1; Tue, 23 Jul 2024 12:44:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 81C096B00E2; Tue, 23 Jul 2024 12:44:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E2F06B00E3; Tue, 23 Jul 2024 12:44:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5043F6B00E1 for ; Tue, 23 Jul 2024 12:44:58 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D0E02A029F for ; Tue, 23 Jul 2024 16:44:57 +0000 (UTC) X-FDA: 82371591834.13.A14150D Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) by imf06.hostedemail.com (Postfix) with ESMTP id 0DFC318000B for ; Tue, 23 Jul 2024 16:44:55 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IoMa38mD; spf=pass (imf06.hostedemail.com: domain of flintglass@gmail.com designates 209.85.219.173 as permitted sender) smtp.mailfrom=flintglass@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721753072; a=rsa-sha256; cv=none; b=QtWlRoHa6PBaee0tlG6VpKrOokdN93Fjf4zVG+W/4vjOBjCDxnymapZHfOfkrzVB/MPsmy uYXHq8xXPb2vCu+bvozI9RfE16130g5QPZKOSaGD+2PRkzzaLuKM8KpSe45K78NIySvBmn CBWVpmdyQzwyJGuaRXkorEZFd87Sgx8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IoMa38mD; spf=pass (imf06.hostedemail.com: domain of flintglass@gmail.com designates 209.85.219.173 as permitted sender) smtp.mailfrom=flintglass@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721753072; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PuWmgIHPZDsK15BuOy78U3m2lb9tQNShwei52QgqB8o=; b=1f1eol4keRZc/v/NtpTrzBs+0u0u6a7x53cKFnA84pc3RCFFcRbqYZ587uMr9jhOnxDFo5 ZmxGWokelMdgKepPDKMR9/zmrRc2qaHfcTuhfICHtfxEa+IQIhUM5X0Zb5YuJ4CcgnpDBP /P4NnQc6HOB6W7qREy/5TGgaUA1iUP4= Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-e0875f1e9edso3130299276.1 for ; Tue, 23 Jul 2024 09:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721753095; x=1722357895; darn=kvack.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=PuWmgIHPZDsK15BuOy78U3m2lb9tQNShwei52QgqB8o=; b=IoMa38mDzmyT7BAeKuNFe2WYYlohveXgMf8b1fSB24C+bFPulgzAAIW+ou2DQazknS 7xa4Sb9DZOhnx4v3VFAxgcI5eRcZSroWLnsQSwwPKplWc3PzfNwTFPivxLuOb5HwuwrH fyVqGUgNyq34XhOG/64gUwaffNlSxxY1zzZNiylThsJcLJDTaIq6QcL5PYLJ2cuEXU3j sFzstvvsMuLVRJoaKL3skXaJM0PGtYLDxmnbPBy9kGDw/KtP87JJWc1allc/W0/qWBl4 RzEyplL7U6bC6F7FOVzPHRcI9PUsKoy7Jk9MJTJHPBd9guMxatDQXrHjlxpVUiN7W0pP zJuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721753095; x=1722357895; 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=PuWmgIHPZDsK15BuOy78U3m2lb9tQNShwei52QgqB8o=; b=sj2w+RUlAe3jxo/N/Zcsu7BA3jO+zb8uHvWTe3ODgEQqtEXEbO5s3foqQgIId53sZi l19MgoAwdOXordmVMIhM0FQskseGpXkxIwwguG58wt0k5V8HSKPGOzjyMrHFY4KB33g7 HtNBuwcxJUjQXEP8RE61Uv/Nc+bmPjZcn3qA0MbSkHDKu7nlxoOn76IKswoRFA76o/mg tntwiwA3mkde4O4bss9ZFl2huLHhEJ3Qyu+lyH+mnm9mRYFg7sLWPvHlugawcUUT+5Cf CQrRuoaILU56ZJ/aqi1S0vios46+fIDEM8N3XPMnha2oTkrO+sEPjJcFeRFv26gHkmA5 echw== X-Forwarded-Encrypted: i=1; AJvYcCWpU/a98skTD+B53U0EOk2e9R/4rf7q1PlUIHWH1a/zL576I56HGlucB0MiJzJuduCXUpxpXB8QAzfrhwjIZ4DWxas= X-Gm-Message-State: AOJu0YwnF2tnyh2V7PP7Z6fnkY7xEpqczCrDSEI32I+RcFGSkEKs+RbE BbjJXolyWyL7dO0BaU5MQtQB1tyDPWElzjUHbqc1+i7tC4/tugC77OqWCeNbXJlD9ynCfgzcvhR k2/yoAyePUzx5RUbOAp6t5OzAEHs= X-Google-Smtp-Source: AGHT+IE+LG/KOyQucZr3AjVxnzA0WaThXyO3Mfyu1xXcvXnr5BgGcOfOxWqa2fjDt1cVGCebVOrUD3TyxUNcpUHahXw= X-Received: by 2002:a05:6902:1b88:b0:e08:918d:7f9b with SMTP id 3f1490d57ef6-e08918d8221mr8389731276.50.1721753094994; Tue, 23 Jul 2024 09:44:54 -0700 (PDT) MIME-Version: 1.0 References: <20240720044127.508042-1-flintglass@gmail.com> <20240720044127.508042-3-flintglass@gmail.com> In-Reply-To: From: Takero Funaki Date: Wed, 24 Jul 2024 01:44:44 +0900 Message-ID: Subject: Re: [PATCH v3 2/2] mm: zswap: fix global shrinker error handling logic To: Nhat Pham Cc: Johannes Weiner , Yosry Ahmed , Chengming Zhou , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: okhgbykr5breq16m79idmm4jai4coqxo X-Rspamd-Queue-Id: 0DFC318000B X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1721753095-895735 X-HE-Meta: U2FsdGVkX18bgmTWLkZ5uRmJxM8g89jzVIxPzsnE3a/YWorNOzRvUqLdiX0YsKq2/tv+xa33nDqDaa1w438iVKV72tqaBRpkatbanMukU/6uVuJWjm97jz4m82qQ3kNnBmRBK4PwzRIA3zODtqA+k/ZQlx118WtdyIyXyDqM79ELjXy5dhX/8YbqHd9dG88tJTTh78KWOE5GArdp9r1WXKt3OmrF4Nan20dnTMX8Up6rHf0UCJNSDk+9Lb4bSl+dM86u/ccq8qkZ+I4CDdEx3643uBs59e3QLB2BdQ6LdSOs1Pnc8mWjSSgBma5AgU95erWupPJFUd9mcIpYLIxKyRxAwPKnhGg6xfMENfQmmMr4+bO0x78wzd6AOUfECUn2C8AKGQUlzt7R7h/X4myqW8JOUl46CF+pwY855T+l5zb4ssc3gUY4xVkuKVB+qS59hJ+M+H2Uv4txiw65cuGAtozJ5SomgMT3IWdAXPfImAXUhYASzkJ+59g5vjYtmEMN3VXuGHli9KEgeqKQ2mUuxWHLvSxNuAzwEBhvvJdoEL9QIA7Iy4LwnvDdRv+UzNAiQ8w3yJRol8QibP84HTnXZeDr2CkoZWoh/8gPQQjgAPu6/9Y9USBDdEsbH886JH/OiuLU9bNPp+xVZuq8YlDcGPFTKBD4WeaL8EWx37EjjarZKrlO53i2VSXlChgceioEQcARJb9x7J8OXBGx4cLo7Ie58Fwyq2IMLJdOlw3pjUDtY8LAhkF25u4VkGVRT/5bNwpPOtCvGswZqODKMrxoaRpOiBXwSwaETa+tPeTTbFQmwaxfZPzje0guwgcxnMS6A9uwtYdniMaRYHmevFzgIJmA46XOBRjqwOHsPZBYx8lWvx70d74izFZzpUoO13LaeUJ4cD5WWB3OPl0iR9ZkMgoXn6VOYVrqukKOWbGtWA5uLctj0exbOfupmmZtjd9WRuK0+UeCikYnlQa21F5 YSW3FoMA 6TcnrnTvHkOVi4AgUXuCRvTjaEE8e+ppv7sCD3e2YCcFo78Z6ublXZRnPGJsLbNlM7WijtQJXrXIYf1+Htz/6neW81tSpjubv8rKP9GTqkP9Zh+CSuGRjD/Z2cgCOTLZgbzJVGYoix2TJlCxR1N1cxrWanwOQhagkIUDBM5wRpIEXtDrS+OXsSPDW/dafouZttCLkHDA+1glTxmNQQi1GlPFCxzHLJUQNnpBHwvMduRz5TAOIWsh3EEJ74nV1yJDERS3zms8RJVqG1r8TBr9199meLqHHQg4ce9UwGdocvAjAdOGy2TY4ZhE2ZwnZP63sFwpV X-Bogosity: Ham, tests=bogofilter, spamicity=0.000028, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 2024=E5=B9=B47=E6=9C=8823=E6=97=A5(=E7=81=AB) 6:51 Nhat Pham : > > On Fri, Jul 19, 2024 at 9:41=E2=80=AFPM Takero Funaki wrote: > > > > This patch fixes zswap global shrinker that did not shrink zpool as > > expected. > > > > The issue it addresses is that `shrink_worker()` did not distinguish > > between unexpected errors and expected error codes that should be > > skipped, such as when there is no stored page in a memcg. This led to > > the shrinking process being aborted on the expected error codes. > > The code itself seems reasonable to me, but may I ask you to document > (as a comment) all the expected v.s unexpected cases? i.e when do we > increment (or not increment) the failure counter? > In addition to changes in the commit log suggested by Yosry, adding some comments specifying what memcg is (not) candidates for writeback, and what should be a failure. - /* global reclaim will select cgroup in a round-robin fashion. + /* + * Global reclaim will select cgroup in a round-robin fashion from = all + * online memcgs, but memcgs that have no pages in zswap and + * writeback-disabled memcgs (memory.zswap.writeback=3D0) are not + * candidates for shrinking. + * + * Shrinking will be aborted if we encounter the following + * MAX_RECLAIM_RETRIES times: + * - No writeback-candidate memcgs found in a memcg tree walk. + * - Shrinking a writeback-candidate memcg failed. * * We save iteration cursor memcg into zswap_next_shrink, * which can be modified by the offline memcg cleaner and, the reasons to (not) increment the progress: @@ -1387,10 +1407,20 @@ static void shrink_worker(struct work_struct *w) /* drop the extra reference */ mem_cgroup_put(memcg); - if (ret =3D=3D -EINVAL) - break; + /* + * There are no writeback-candidate pages in the memcg. + * This is not an issue as long as we can find another memc= g + * with pages in zswap. Skip this without incrementing prog= ress + * and failures. + */ + if (ret =3D=3D -ENOENT) + continue; + if (ret && ++failures =3D=3D MAX_RECLAIM_RETRIES) break; + + /* completed writeback or incremented failures */ + ++progress; resched: > My understanding is, we only increment the failure counter if we fail > to reclaim from a selected memcg that is non-empty and > writeback-enabled, or if we go a full tree walk without making any > progress. Is this correct? > Yes, that's the expected behavior. Please let me know if there is more appropriate wording. Thanks.