Received: by 2002:a05:7412:d002:b0:f9:9049:d2ea with SMTP id bd2csp12544rdb; Wed, 20 Dec 2023 02:24:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFWWZMWexlIy/OMs7AHnd6QHTdY24SlN1YThEX+j5wGjC1kvp6es31HkKlVQpciSbN8RU0R X-Received: by 2002:a05:622a:170c:b0:425:9b7d:668b with SMTP id h12-20020a05622a170c00b004259b7d668bmr27822907qtk.132.1703067887980; Wed, 20 Dec 2023 02:24:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703067887; cv=none; d=google.com; s=arc-20160816; b=N8wzifMg/umKB54oEAI+IekifhRafBiPmlArjEc+miDh3bvekM0JRVZdQmDEWrCi9A r17QEoIDavL3guIuZGKOerjYliuJinWfM9jjorNYGvjAFJ1kh91/0S7CTJHfdkrd7fuD +cUjZA4+UzuwA2RBzXkhoaCDdCt4vWoeF5zOwk9b5kt2f39mxDsEfZe/srkId5OC/lHN omtxZHXLV5jYj28LB7Zh4FvTJXd+hSuHPDCnMA7ZtBbPdp90nR1oQ9M8knhUWCtdJOGu U82J7voXLRJixBCTUT57w77ZDhZPcXGwwaI1UUKlRhUotIWmk6PQSEo/iZDacEAcfhMl FVFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=oRmWXSIwM0XGZafsEN4uRYb9SZntd9nJS61bvL/+JvY=; fh=jIgwOfepMqG4IJRvxG6xF31mdqRkG/1Xx4K2/Tx97Dc=; b=Jor3B5/5klCMncAas+avTWYvgZUZooKPV/D+8gX3VQhC0qQYwTJ/dqOR2vowi2/xSc cgvZSoj8ZQ6+q5ABJHJa9l1jdSyt3e6q0p6JIRLqyzYRL4234vDbg9/+t1QFMMNNlfWS pFeUYWz/7el+XToqAD6WyzESiEwSe/0EyzwtTc70/8EBEli4+uBaslooyR88tQHLB1qn 0rU3Ju5sYr66qNwXA9+RzyviThcha0VnltQMlKPqTJJqffHOS5v5DLawCHegTsLqSiai MsujO8qJ63JHqFgWecnIthkS728JpEV39kwh/ydTkgQXAfkv4K5adAMB2+QhZkrOAZsj q/Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CCNyA3Bc; spf=pass (google.com: domain of linux-kernel+bounces-6736-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6736-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b20-20020ac85bd4000000b0042775bb6607si3531599qtb.774.2023.12.20.02.24.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 02:24:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6736-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CCNyA3Bc; spf=pass (google.com: domain of linux-kernel+bounces-6736-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6736-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3652E1C21819 for ; Wed, 20 Dec 2023 10:24:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F09E21108; Wed, 20 Dec 2023 10:22:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CCNyA3Bc" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0C46210F6; Wed, 20 Dec 2023 10:22:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2cc95f1102eso515821fa.1; Wed, 20 Dec 2023 02:22:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703067756; x=1703672556; 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=oRmWXSIwM0XGZafsEN4uRYb9SZntd9nJS61bvL/+JvY=; b=CCNyA3BcpcUohdD59/0McAAK1boyzBPoN77VXIX5eRSqE60EXw4jh7JsQIDz0ON06M qL4t2XkchH4vY3a3h9zLBr3fYJeQMVaJ9NRA87cu9Gtb0oUcUu1LuBqW8kYSf+8KjmF9 NVVcIMfClTZbKBjnD5Mqz2QoeEGjGXTjJ8/eLYL70RGSnjjUuUhIPhv2SLeh09JH2tDx +WiCDVnC/WczKw0y7GdRFyCHY2LTZgUzL43tV+4oGeGMSa5QXgJMSU1+2mR+Me4+UzU0 j4st2DFIkFvkB7NXswKe53ygdpb0fV61nio4695CH1J46LWRYwC/P24GOLC3EpMYP2uc wT7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703067756; x=1703672556; 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=oRmWXSIwM0XGZafsEN4uRYb9SZntd9nJS61bvL/+JvY=; b=EACEIbF+kXZ6zu6XQ8EYjSv4LRgdHqsoA5rt4DuRsggzaBjaS6kSxAF+2L1wuwEONN HJ3Buc6XljZVzhjqwJ863wfDQZnmGdAiN0u4g3Tj2ldFk0anRyb1bcCaVkJtSwVbNacL /NGr8fhcuKYyTGlvQe7YrQBca2KL7z3if/fTpbZ9LuvHBv/4z6i9thA0Y8D3EYGyTJz8 q97rGddrlFxchiZG7QKATJ1IzW1/QTKxk0n8MfLfyFmu/MYdDT5mQ/Ln4as4QsjeIUnG cZQ1iiu3OsNppdaIkMvWnSFKxZ9sYZgFUrZqCI1CLsRDkhycoKwxK2NSMt1syyzq1Hmt p69A== X-Gm-Message-State: AOJu0YypJfmKyMCYfecd0h7oA6tH9IQeazD9OtdxIWIkdfyrzniqhQop VFyccw+zA8be2w2ZAEqEMV3G1YRB3Rhiuk26Vb8= X-Received: by 2002:a2e:9683:0:b0:2cc:68c6:305 with SMTP id q3-20020a2e9683000000b002cc68c60305mr2078790lji.81.1703067755538; Wed, 20 Dec 2023 02:22:35 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231207192406.3809579-1-nphamcs@gmail.com> <20231209034229.GA1001962@cmpxchg.org> In-Reply-To: From: Kairui Song Date: Wed, 20 Dec 2023 18:22:17 +0800 Message-ID: Subject: Re: [PATCH v6] zswap: memcontrol: implement zswap writeback disabling To: Chris Li Cc: Minchan Kim , Johannes Weiner , Nhat Pham , akpm@linux-foundation.org, tj@kernel.org, lizefan.x@bytedance.com, cerasuolodomenico@gmail.com, yosryahmed@google.com, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, hughd@google.com, corbet@lwn.net, konrad.wilk@oracle.com, senozhatsky@chromium.org, rppt@kernel.org, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, david@ixit.cz, Zhongkun He Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Chris Li =E4=BA=8E2023=E5=B9=B412=E6=9C=8813=E6=97=A5= =E5=91=A8=E4=B8=89 07:58=E5=86=99=E9=81=93=EF=BC=9A > > Hi Minchan, > > On Mon, Dec 11, 2023 at 2:55=E2=80=AFPM Minchan Kim = wrote: > > > > > 3) Android has some fancy swap ideas led by those patches. > > > > https://lore.kernel.org/linux-mm/20230710221659.2473460-1-minchan@k= ernel.org/ > > > > It got shot down due to removal of frontswap. But the usage case an= d > > > > product requirement is there. > > > > +Minchan > > > > > > This looks like an optimization for zram to bypass the block layer an= d > > > hook directly into the swap code. Correct me if I'm wrong, but this > > > doesn't appear to have anything to do with per-cgroup backend control= . > > > > Hi Johannes, > > > > I haven't been following the thread closely, but I noticed the discussi= on > > about potential use cases for zram with memcg. > > > > One interesting idea I have is to implement a swap controller per cgrou= p. > > This would allow us to tailor the zram swap behavior to the specific ne= eds of > > different groups. > > > > For example, Group A, which is sensitive to swap latency, could use zra= m swap > > with a fast compression setting, even if it sacrifices some compression= ratio. > > This would prioritize quick access to swapped data, even if it takes up= more space. > > > > On the other hand, Group B, which can tolerate higher swap latency, cou= ld benefit > > from a slower compression setting that achieves a higher compression ra= tio. > > This would maximize memory efficiency at the cost of slightly slower da= ta access. > > That is a very solid usage case. Thanks for sharing this swap backend > usage story. It goes beyond my original memory.swap.teires idea as > well. > > We can have some zram specific knobs to control what compression > setting is using. Moving data between different compression settings > would be an interesting topic. It might fit the swap.tiers usage model > as well. I am just thinking it out loud. Maybe define different > compression settings as different tiers and then allow the cgroup to > enroll into one of the tiers list. > This is very similar to our usage, easy to implement too. Actually, now ZRAM already supports multiple compression streams, so if each memcg just provides an extra knob to record the compression level (1-4), ZRAM can decide which compression stream to use when the page reaches ZRAM, just by checking pages memcg. It's limited to 4 levels but enough for most cases.