Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4440263rdh; Wed, 29 Nov 2023 01:19:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+pg+knBytchEeJu8M7mZGu604LygAWCp3QlUgAKz/RDtg7bX8nPRq2FbYDPd3yHt9GGor X-Received: by 2002:a05:6a20:8e17:b0:18c:4d89:6e86 with SMTP id y23-20020a056a208e1700b0018c4d896e86mr12272467pzj.7.1701249552224; Wed, 29 Nov 2023 01:19:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701249552; cv=none; d=google.com; s=arc-20160816; b=nHq2ue22OYybZj7TLv4X/OkrwDqMtFgFkHzFvglp5b2bMBLMJbNw28XHB+nqNTPue7 eYPeFCtAQUhd2Pd/Xte1dhkRk+uqbjzgPigY1JWPaHG7vRXrfvuSSP4qRQjopDnv7ljE bqRyIGb28FuFq6YpEHIncQ8Rit5tXoEPDccU3EnQQBC8DU5JQ5+TIvL15AL/VQMs/JtE YPMXaWscnXQ3va9letclnT7Hl1ZWLXqvokuMqhk3fWjb0nANnpEDIYQwM6LuLGryXJi0 8ZY6bXmsaU/h8SDkR5yOpgFPQ51T5kK8w8wqwEfaTW0XRVpGd08aZ7NPaKbummAbpOUR 4Xzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gFnuBA9yIUylMwMyyAsH56skdpfLwIzJlMW0SKtsi6g=; fh=rPMi8sJdK0AmEAoB9tDFuXt9Fr6fed5QUNqK80Y+mf4=; b=L69O+8aJz0gjqoUd9u+h+LBdImN+mfWh4Tfe1w7vSfYHsftk0PQ3KfNEA2sdhQjK5B yNKyjgwK25vJwCV7P4p8y3uTZA+5NPQupaqvCvdNfhXsOSnZmQkzhfjqmtxiHKxb2pof xxQUAd+VpKfvlPoBH9lrWVCsHpw7dvOMNuEnfnCYjAlchV0s7Z4By3t5nliRqjqvdtiF NNG145t1pnIO0xRy1h5ujFGkJLInr6NDbJb0D8QscxtUNQW39mL0EqGBBO/9nInREzQK jHhLId6kjSHZ/GT7rN+78bHjo3b2kkqoRODb0inYtL8m39ocQ9uootV5v/6CgMyurilx de4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="Ysd/KVdq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id y10-20020a170902b48a00b001cf54c7adb7si11647048plr.20.2023.11.29.01.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:19:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="Ysd/KVdq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id C9142804197D; Wed, 29 Nov 2023 01:19:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229488AbjK2JSy (ORCPT + 99 others); Wed, 29 Nov 2023 04:18:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbjK2JSu (ORCPT ); Wed, 29 Nov 2023 04:18:50 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCB951BC2; Wed, 29 Nov 2023 01:18:56 -0800 (PST) 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: Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spamd-Result: default: False [-0.80 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.00)[34.72%]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_TWELVE(0.00)[19]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; MID_RHS_NOT_FQDN(0.50)[]; FREEMAIL_CC(0.00)[linux-foundation.org,cmpxchg.org,gmail.com,google.com,redhat.com,ieee.org,konsulko.com,linux.dev,kernel.org,kvack.org,meta.com,vger.kernel.org]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -0.80 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Wed, 29 Nov 2023 01:19:09 -0800 (PST) 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