Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4968160rdh; Wed, 29 Nov 2023 16:48:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdMtwzfKdANJCzUItKgKcEzZL9HOcebv35EyTbfgfrhoCl2UnBRv0VzqxQuasU0+8JJD0F X-Received: by 2002:a17:902:ead2:b0:1cf:63bb:82a6 with SMTP id p18-20020a170902ead200b001cf63bb82a6mr18428555pld.65.1701305285383; Wed, 29 Nov 2023 16:48:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701305285; cv=none; d=google.com; s=arc-20160816; b=bIPhxMBM8NcYR5jT7m6ZhxEiAsDipeg5E/DB5BYXuoFrtAauTHqJ+EhxKc28O4LVOW ZXxEmtHWfFy0jlRGJEnGEHu5KoadfmpJJ4gs6rURoPwxBdQDW1eu1Dm/kQSJvpym1cI9 2aHbailYgjdC3XgLe32MVAwmAj3wRQPNX9rTz7de2y+Ia/p3pELxvjIpXe8igAdbfj8c jQ4QJrM4DF6lx0i3g6rfSkU2DMqKXbwmjUcNC/mrNTfDp5TkerEBNUWfzv04//P6BQdu zEx+nrlOps2OaxXtGbC5V2mtq6W2uUXOs6Hz3PyO7E55u+l0qOX9CwxA1FEeJGS3GSWR rOxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=px7lu5nOqajxdLEanLNBtXA+0BLm4pP2tpUPChWnjUo=; fh=6TYj4/MOoSXvKzAdL1sfncuAa6JtwAcP893Cd6QctbA=; b=FjnhFLMqaJ/dUkuEi32jgzI8RBkmlRETubh+CstJ2aXKOcaWv695r+Fc5Gf/a6wQXv ktCu2IyWw6kLvjrEiZohkAnr8sV5rqib2PJXXmPV7HjgTx2bULElBlEPGHtlyMqKKPv5 ohR26QciYpoSfnvMvXVlTiipFwJm/bnu1sRP16ielMXdeHUtUnOO+ljIiVM9F+TP7fp2 EELgce6MThhBgJLCNB+9p3nBk9Kty4sUbOduavahuKpDjNDdvF1GZEE2UyzPlomkvXjJ cgJNnmWSyhlXRtaw46iM4TlPp5/H30nVDEhv6UBFvBWwefm76drsdj1CSqPBaUt4LpFl cOtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Q3gDyxeg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id jf7-20020a170903268700b001cf97206e86si13534837plb.75.2023.11.29.16.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 16:48:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Q3gDyxeg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2D230802C6B6; Wed, 29 Nov 2023 16:48:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343870AbjK3Arx (ORCPT + 99 others); Wed, 29 Nov 2023 19:47:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjK3Arw (ORCPT ); Wed, 29 Nov 2023 19:47:52 -0500 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33AF1C9; Wed, 29 Nov 2023 16:47:59 -0800 (PST) Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-1f9e0e44fecso169052fac.3; Wed, 29 Nov 2023 16:47:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701305278; x=1701910078; darn=vger.kernel.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=px7lu5nOqajxdLEanLNBtXA+0BLm4pP2tpUPChWnjUo=; b=Q3gDyxegKcTCM22dYyiIS3FhVJKlB3JlX5pEtwKlifYACjCod8X2Nzp7Shbm1wUjqZ 3VQUTWS3p44xgvuKDB+Q5PQ0btMjf62LpnI0+xEi7TMx8oDXolmqF3GzRrPzwhaEQ/EZ ELGYT7s/ptGFZMyqO6LiXbECKOe2pp+xrTC4q+17k+tz43kt5payZXz1H76bbzNHtsro nCLOrtuAIm3SmWHmBqbBmO/vwAlhPcBLLKWhbiWZWRNGGURUNwfiGP59gnejquWjjFcV 7aXEJ0C8UMJNTkBtV0NqhlSdZBi3z8WIoh73nJOJzPCdGbG8nePM3naVI+zMK301IyhW 4veg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701305278; x=1701910078; 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=px7lu5nOqajxdLEanLNBtXA+0BLm4pP2tpUPChWnjUo=; b=tJfANXCNtGck1rwWNvT7R4p8sYSNBnu2q0vATepHof9pn1lxNkeK+U7UFL7TuzIDAe +PV+XtmL8I/y4RDqP0fM9ws1t+1O/wyVK5E8egpFFt7H0CdVqFFv3on0Yov5dKa49V0Q umcDORQYk/FMlo2XHDK1AZ8MoNKzka2R/ihAxeqm0Tpdk3wKKvTLcT8mHknBD9o+ecxW WAMF8Cf6+u5AxhI80t9nuBJNrtYSz5yIjCFjkx8UmCMdzW+JYHKCBNpA5GS58ae7/5wC V6tW/iTAkSKM+DSm0y3pYSoWP6lArul5rM8meYPHU2URrWd9K4/5UPTjuaDFH6rbr7Yi A/2A== X-Gm-Message-State: AOJu0YwHfCb7qQwHQzcg3pjb3/aDcQcDVUi11MXoPluctd4NXFchffut JqpMCnx+pRWgDMumLt5c9qz9GpCot8y3CywG0Po= X-Received: by 2002:a05:6870:eca2:b0:1f9:5081:f287 with SMTP id eo34-20020a056870eca200b001f95081f287mr26311523oab.27.1701305278396; Wed, 29 Nov 2023 16:47:58 -0800 (PST) MIME-Version: 1.0 References: <20231127193703.1980089-1-nphamcs@gmail.com> <20231127193703.1980089-3-nphamcs@gmail.com> In-Reply-To: From: Nhat Pham Date: Wed, 29 Nov 2023 16:47:47 -0800 Message-ID: Subject: Re: [PATCH v6 2/6] memcontrol: allows mem_cgroup_iter() to check for onlineness To: Michal Hocko Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, cerasuolodomenico@gmail.com, yosryahmed@google.com, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, chrisl@kernel.org, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 16:48:03 -0800 (PST) On Wed, Nov 29, 2023 at 1:18=E2=80=AFAM Michal Hocko wrot= e: > > On Tue 28-11-23 08:53:56, Nhat Pham wrote: > > On Tue, Nov 28, 2023 at 1:38=E2=80=AFAM Michal Hocko = wrote: > > > > > > On Mon 27-11-23 11:36:59, Nhat Pham wrote: > > > > The new zswap writeback scheme requires an online-only memcg hierar= chy > > > > traversal. Add a new parameter to mem_cgroup_iter() to check for > > > > onlineness before returning. > > > > > > Why is this needed? > > > > For context, in patch 3 of this series, Domenico and I are adding > > cgroup-aware LRU to zswap, so that we can perform workload-specific > > zswap writeback. When the reclaim happens due to the global zswap > > limit being hit, a cgroup is selected by the mem_cgroup_iter(), and > > the last one selected is saved in the zswap pool (so that the > > iteration can follow from there next time the limit is hit). > > > > However, one problem with this scheme is we will be pinning the > > reference to that saved memcg until the next global reclaim attempt, > > which could prevent it from being killed for quite some time after it > > has been offlined. Johannes, Yosry, and I discussed a couple of > > approaches for a while, and decided to add a callback that would > > release the reference held by the zswap pool when the memcg is > > offlined, and the zswap pool will obtain the reference to the next > > online memcg in the traversal (or at least one that has not had the > > zswap-memcg-release-callback run on it yet). > > This should be a part of the changelog along with an explanation why > this cannot be handled on the caller level? You have a pin on the memcg, > you can check it is online and scratch it if not, right? Why do we need > to make a rather convoluted iterator interface more complex when most > users simply do not require that? Ah that's a good point. Hmm then I'll just do an extra online check in the zswap reclaim callsite - cleaner and less invasive. Thanks for the suggestion! > > -- > Michal Hocko > SUSE Labs