Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3989145rdh; Tue, 28 Nov 2023 08:54:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IExb38mNU1TuOj3gcmFCSI0K8qxKz4YdSbcPN9nOJ0+DV8MG4hOGb2UdhcPGdLtdIc+xpe4 X-Received: by 2002:a17:90a:1a17:b0:280:1d6c:a6a8 with SMTP id 23-20020a17090a1a1700b002801d6ca6a8mr15112356pjk.23.1701190459749; Tue, 28 Nov 2023 08:54:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701190459; cv=none; d=google.com; s=arc-20160816; b=K4Aqhi34XxnBwValDyiQnb4xpB7Z8eUcwu6SPX+WOE2BlakVJZvleSYP0dDD+KaeQ7 jbpUHSZK6FLpa8TCaDbKQu4EyENSmu+sxeIjAGq5yQd9MbOUf9dPwwzoMT+Hb9vaOSbw BdLRdra/IHBep4crVSi7DXt0huRAwJBMpA7cElV/mzdBTmFQH5hCl/FXrkSybCgQKNDB T8lWqbvi9WOSqCTUTs8kPooRuRqHMTTdFRw/dIRLvsQOWxXmN/Rnu/vVHxZxOhmU6o3G esXWqNBO9RqHJ8Vz1tcpOFfI8n7ZQXiHkAO1p1oOZ65uo7HAi0xg6UXix7OAzeGfJm3S i8EQ== 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=r85ydUJh41VHrUAuuHTOjnQ7J8TNkgJ1y7qjmCMSTu8=; fh=6TYj4/MOoSXvKzAdL1sfncuAa6JtwAcP893Cd6QctbA=; b=AejEdXyEIJ/DBzuPIgfEytNbAGKvZ24l4r1VTTL7iHvvXu6YMBgh6Z2Drt3V11y1ni I/uyEa0tdJaZaf5RKCoqJ8TOrXOtrPMaJEYwYSa7EphkWBfhLcBht6KqEHxqDhMW961T ff5X34tdyx78WVqTqgr94eAuQd0L4sBKzeeJh0p2iiH9RYTVhk6qGTPRMd2RIw9G/QnS up6e7oXMY/blobBDkU9tcsl7PGHKshpUenOshlLmFlbJtidnHHexzxgD5R1w+XW6TtH7 dLz60U2zjznMgXYdSpySjBoE2FjKqZ/p5zaT506kFXWG2xEOAvezC0vi1s59J2LQF94r qyfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=c1csWw9Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id pq9-20020a17090b3d8900b00285c4fd2ff0si5747962pjb.116.2023.11.28.08.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:54:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=c1csWw9Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id E34FD8136BC3; Tue, 28 Nov 2023 08:54:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344838AbjK1QyD (ORCPT + 99 others); Tue, 28 Nov 2023 11:54:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234730AbjK1QyC (ORCPT ); Tue, 28 Nov 2023 11:54:02 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15033D51; Tue, 28 Nov 2023 08:54:08 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-7b389399dfdso133526339f.2; Tue, 28 Nov 2023 08:54:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701190447; x=1701795247; 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=r85ydUJh41VHrUAuuHTOjnQ7J8TNkgJ1y7qjmCMSTu8=; b=c1csWw9ZHwTNRyZ1Cf739uEAA/rE3GFkeHYDXFBlk+AMOgvY+IRBV6q8bb8eSYhwD2 RCIQEZf/PcKj/0SdILO4J1eMZqW42d9kDY0P5PP5JgKbVmZm8gq7DIhYS0Iyo1E0SjMY i3pu7ouHtbMyb5C4wvqtkRUEMCRWifL9QAxYQB9gmmCeua1VarKvcjoyo4j4dhhdaLez 2PMhFQrAAYjXtAGc+xWAlCQcyyLPCAvRRtNHQ73mbNbjFK+wpi/6oimer+tesQUqsqoD Gi8Fxl6q+u/QZidszp8MeNhY6OZHTt7NXnmISm4n42RB+X4hY4YQ1kltZ0BgCY5/m/bP 6m0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701190447; x=1701795247; 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=r85ydUJh41VHrUAuuHTOjnQ7J8TNkgJ1y7qjmCMSTu8=; b=VtaD63cLFaC+uZNGdh81O2iDArlzTsQ4Up7lEVA1g8EkNNgbCNzUQcBb7YiMrwkVJM 8xn+uvC2bcJFAvfVbqJ12D1HaWRqsoqORwcgbZXdF9sMgnJcKFL1CtJgDDXV4s1I1Oqn MTdSt/cqkLUow/sfEEZORJgpLEnCxyPA0K5fnQsLWwj79J6P42G3eOIv2grUbVMGomqw qXQT4GBTGL6cJdX2HmbiMnl7cEUuUg2Vee9OmPHgGj9C2bFw86pqf/HYIGZa5Q4S3mw5 WaKyxduVB6CpxYlbfA4YfGCkiOEu27X53RtganEMOhCBGWBzJ8KTbyTSKrPdut7h1UNm n3Pg== X-Gm-Message-State: AOJu0YyajVmdDgAlCd2+XNjTEbEsANaO6WviLqlLjBXDdefFwyMrXoho N/PV/8fgwk+8N23t2LOnKSNu7G8HRc3nocd4PoU= X-Received: by 2002:a6b:3fc3:0:b0:79f:96db:f33d with SMTP id m186-20020a6b3fc3000000b0079f96dbf33dmr12580697ioa.9.1701190447244; Tue, 28 Nov 2023 08:54:07 -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: Tue, 28 Nov 2023 08:53:56 -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=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 28 Nov 2023 08:54:17 -0800 (PST) On Tue, Nov 28, 2023 at 1:38=E2=80=AFAM Michal Hocko wrot= e: > > 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). > -- > Michal Hocko > SUSE Labs