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 D9373C4167B for ; Wed, 29 Nov 2023 09:18:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 713006B0376; Wed, 29 Nov 2023 04:18:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C3016B0377; Wed, 29 Nov 2023 04:18:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 58ABF6B0379; Wed, 29 Nov 2023 04:18:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 496516B0376 for ; Wed, 29 Nov 2023 04:18:59 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 129A41404D9 for ; Wed, 29 Nov 2023 09:18:59 +0000 (UTC) X-FDA: 81510442398.26.5DA3ADD Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf19.hostedemail.com (Postfix) with ESMTP id D37E11A000A for ; Wed, 29 Nov 2023 09:18:56 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="Ysd/KVdq"; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf19.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.131 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701249537; 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=gFnuBA9yIUylMwMyyAsH56skdpfLwIzJlMW0SKtsi6g=; b=ps4R1PXYWYIMOgsWYELvmQHKqGoxCuS5LfnypF2AHgXokhw9OYL3IqgCXFQ/3ILX8Gm9P9 eONUa5xtzXmnglWITUQC4lHJLQFYutb5VMHmnzzRvcH6Wt6Ec/Y1WrEWPZTgnFhdX7txYs LWN53ZxHjDgUwAq1xCa8np13nfrmEy8= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="Ysd/KVdq"; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf19.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.131 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701249537; a=rsa-sha256; cv=none; b=eJuTUdJVTI5fneeyJhgO/aYK5ppT1KHGXxE6b8O/6hUwJ9HywRwmDzJAcH7ud3cS0spvhr 4nO2WYi3jSlQ63LUgOT2KvcV9mbYpxVAs9Bydunmrn8uUbUCrRmj2ztptLMvWjmaBLFew4 XQKj+kVCabQg5IcHS0s7LPBsn+6Omcs= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 41A881F898; Wed, 29 Nov 2023 09:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1701249535; h=from:from:reply-to: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; bh=gFnuBA9yIUylMwMyyAsH56skdpfLwIzJlMW0SKtsi6g=; b=Ysd/KVdqX42jUhsPekseKBmF8aHmcw1IWa4erQtjmW8eLxS/MvhD4vacDqBv9Hd1uLPKj4 3Ff7DbSPNnpMvKZiqauXOW7vLPZppySJ1Su5QAOrUUD0Ii0TzM6i+CGQmleFMJxejCLFom 3cpR0HNQwxD3VRNnLO8KhoctTZJV/MM= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1533A13637; Wed, 29 Nov 2023 09:18:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 53ZsAv8BZ2XkcgAAD6G6ig (envelope-from ); Wed, 29 Nov 2023 09:18:55 +0000 Date: Wed, 29 Nov 2023 10:18:54 +0100 From: Michal Hocko To: Nhat Pham 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 Subject: Re: [PATCH v6 2/6] memcontrol: allows mem_cgroup_iter() to check for onlineness Message-ID: References: <20231127193703.1980089-1-nphamcs@gmail.com> <20231127193703.1980089-3-nphamcs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: D37E11A000A X-Stat-Signature: cypi36kmeme68myk8xjnekcujwz46n9o X-Rspam-User: X-HE-Tag: 1701249536-738766 X-HE-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DLS3v2FORc5bWhA2lOFCVZKbRusStxm0Ia1WCXIOAlSZGEbFzOmt+J9pCpbA/FJfv7OuEj/4y8raa5HvA8N3Wv4nLEwaOLmmOBPSOTLGwSHVGsFWxHacp1v7yxUSyzm5+JzpN4QTR8t+TWkvvxTqUhXmZc84ec4ceDHIuSaZdkO44IzjnNDeuj/rkC+iZinOqG79U/sr/enCCu47uzBmVXrojpGu0Oz1Y3v5riiTj05gZpdZ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue 28-11-23 08:53:56, Nhat Pham wrote: > On Tue, Nov 28, 2023 at 1:38 AM Michal Hocko wrote: > > > > On Mon 27-11-23 11:36:59, Nhat Pham wrote: > > > The new zswap writeback scheme requires an online-only memcg hierarchy > > > 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? -- Michal Hocko SUSE Labs