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 03DDAEB64D9 for ; Thu, 15 Jun 2023 08:57:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93A096B0072; Thu, 15 Jun 2023 04:57:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E97F6B0074; Thu, 15 Jun 2023 04:57:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B1836B0078; Thu, 15 Jun 2023 04:57:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6B3136B0072 for ; Thu, 15 Jun 2023 04:57:41 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2730140AE3 for ; Thu, 15 Jun 2023 08:57:41 +0000 (UTC) X-FDA: 80904379122.24.C13716B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 389E9C0002 for ; Thu, 15 Jun 2023 08:57:38 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=N26loEVY; spf=pass (imf10.hostedemail.com: domain of fdeutsch@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=fdeutsch@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686819458; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qrr8t1kOkKOxl/KVbaO/uVd3ssq16jHBi9TAWr1HBhk=; b=5ViiXnJSex9rLNkatW6+g6OKhs53p4e5ro1e6J8qEeh3O5JeRFcgpN26B1Stm+IBB2fAFv xF1nEuT3hkJFw4C7qcbIafW5WnrUlujVERpwKrhHTE398QOroPFzNhEnnwIyLembiORuaE Rsek66ah4pB/iZrbXk3bhdwYfKw5c6M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686819458; a=rsa-sha256; cv=none; b=sBG37a60IuqyBs6CerG08WKiGJvKlv2vVBSHRp/l5lEk/Ns71aXBxKhvkuvTB43N2V8GXM uNtWrY/eHAXoIwS8FIcDYkLjkbUbDwHH7NFz8wq3tIBgvcXm8GcttlkUmtICruGsrDToUg cf26nscrBhn1Si+hQr4Lq60ZMKOIsRU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=N26loEVY; spf=pass (imf10.hostedemail.com: domain of fdeutsch@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=fdeutsch@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686819457; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qrr8t1kOkKOxl/KVbaO/uVd3ssq16jHBi9TAWr1HBhk=; b=N26loEVYtig1h1oAcFJeUFKHWfJL69C0llXfoTd9liHptnQUP93hA8gNJZ100N1yyOYsKk /5QZAJ5bIYizrhvz5020/ucQ3k/cFQUaEuWv/ajYR7YepHy1PkbbHDmYmoYrw1iYrR47Hm T9fZZSy8WUxHWhM5DiEAIP4i4Yc1nu4= Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-135-7jNpCPkIPCC18v5JiB9Quw-1; Thu, 15 Jun 2023 04:57:36 -0400 X-MC-Unique: 7jNpCPkIPCC18v5JiB9Quw-1 Received: by mail-yb1-f200.google.com with SMTP id 3f1490d57ef6-bc7267224adso1289561276.0 for ; Thu, 15 Jun 2023 01:57:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686819455; x=1689411455; h=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=qrr8t1kOkKOxl/KVbaO/uVd3ssq16jHBi9TAWr1HBhk=; b=U3ZEdVkEy4iAJ7slic3kTuMiM22QnmCdwsIss9lvg5kw2E2rIPFL+YKQdp7n4OFIpB qxdoqc1vEbpVCIxSr8WUDQIZpBLB0Ygdm4fd4Y7PcF5DXUKSVMzz8gZb3yv5UfKox0Gw xhTdfuSr30NmR8VjH3kE1ZtUqzuMgfekw7jg1oGqabc6pf6C1WDEyX8u9dx1F/3J3YwB dBBZbPWnaxKrt0Ts4/zJ0g4Sm3uaZihodiZGvtGTCrMao0Ck2R2T/8fcJFvHzr9o+g0N WwbZL/nhY/D/mv+sAY50Q5aZAMxWk4LaOGw+683nj/L6V9eVCWYzB6a/+GZXqC+B9x7f reNQ== X-Gm-Message-State: AC+VfDzaw723m+RC2zFYcW79kB+1CWbBG7YNG8unLuwTNpazY11B+Rro jEA8SeLl2WgM4N/CJ6VdFKuwr+5fiFvXPRROase8L/EMPQ3xZN0kEdxs7fgB55oX9JtVGhB4fVA HCXSU3sRZZEissEL+xjgkPLE2j2U= X-Received: by 2002:a25:e711:0:b0:ba8:4ab0:3b7a with SMTP id e17-20020a25e711000000b00ba84ab03b7amr4770130ybh.2.1686819455623; Thu, 15 Jun 2023 01:57:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ55ua2vrcAK3VZ1OA4Q8Vtv6kt+g3LkWvR1JHce2e/c8RfQ57d7gsL1res/RngicPCjE8sQ5oDb1gYDv88Dgow= X-Received: by 2002:a25:e711:0:b0:ba8:4ab0:3b7a with SMTP id e17-20020a25e711000000b00ba84ab03b7amr4770117ybh.2.1686819455303; Thu, 15 Jun 2023 01:57:35 -0700 (PDT) MIME-Version: 1.0 References: <20230615034830.1361853-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: Fabian Deutsch Date: Thu, 15 Jun 2023 10:57:19 +0200 Message-ID: Subject: Re: [RFC PATCH 1/3] zram: charge the compressed RAM to the page's memcgroup To: Yu Zhao Cc: Zhongkun He , minchan@kernel.org, senozhatsky@chromium.org, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrea Arcangeli , David Hildenbrand , Yosry Ahmed X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="0000000000006f1f8d05fe27426f" X-Stat-Signature: 3bcrwno6ksosecsqti9zhzxtxunx595j X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 389E9C0002 X-Rspam-User: X-HE-Tag: 1686819458-960930 X-HE-Meta: U2FsdGVkX18ZsaeZlnXs3bHGNG6MOPFy/W8OFthU0cb0wMitBwyyrY1hCI4K7nCfjIOF6MDfzsMZ1efBVWNXy8Gb2WfR9t/COP1X0TRGASzTf2KXBMNXoplwlPPKBnjVxYjbiuIKHw68SlbeK9K1XmilUYhFtVrog/GODG41SdBR6e2DFUqPXh22B1xKJL5pcpB+5oeYlMYNQu278B7A60ObsXtebiIhDeX7B7mJaPs2BfgpLPnJFUeOAh/aIesB3zbv1U/m1nvDTVFL6fAaq7+Inf6fCCplQ5w/psbuarXmyFLs+9qB4k0f8QgeectaH1XuA6Zx8ZcxDtgc9nUjTESTmkA6dFL0IjMH0Oxt3bSYXIpkGx2T44o4gXSB2/uJtT9KgFBLePzxFowsas9sR4q1O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owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --0000000000006f1f8d05fe27426f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jun 15, 2023 at 6:59=E2=80=AFAM Yu Zhao wrote: > On Wed, Jun 14, 2023 at 9:48=E2=80=AFPM Zhongkun He > wrote: > > > > The compressed RAM is currently charged to kernel, not to > > any memory cgroup, which is not satisfy our usage scenario. > > if the memory of a task is limited by memcgroup, it will > > swap out the memory to zram swap device when the memory > > is insufficient. In that case, the memory limit will have > > no effect. > > > > So, it should makes sense to charge the compressed RAM to > > the page's memory cgroup. > While looking at this in the past weeks, I believe that there are two distinct problems: 1. Direct zram usage by process within a cg ie. a process writing to a zram device 2. Indirect zram usage by a process within a cg via swap (described above) Both of them probably require different solutions. In order to fix #1, accounting a zram device should be accounted towards a cgroup. IMHO this is something that should be fixed. Yu Zhao and Yosry are probably much more familiar with the solution to #2. WRT per-cgrou-swapfile, to me this is addressing #2, but I agree with Yu Zhao, that there are probably better solutions to this. Lastly, this patchset, while it will possibly not address the swap issue (#2) completely, is it satisfying the needs of #1? - fabian > We used to do this a long time ago, but we had per-memcg swapfiles [1[ > to prevent compressed pages from different memcgs from sharing the > same zspage. > > Does this patchset alone suffer from the same problem, i.e., memcgs > sharing zspages? > > [1] https://lwn.net/Articles/592923/ > > --0000000000006f1f8d05fe27426f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Thu, Jun 15, 2023 at 6:59=E2=80=AFAM Yu Zhao <yuzhao@google.com> wrote:=
On Wed, Jun 14,= 2023 at 9:48=E2=80=AFPM Zhongkun He
<hezho= ngkun.hzk@bytedance.com> wrote:
>
> The compressed RAM is currently charged to kernel, not to
> any memory cgroup, which is not satisfy our usage scenario.
> if the memory of a task is limited by memcgroup, it will
> swap out the memory to zram swap device when the memory
> is insufficient. In that case, the memory limit will have
> no effect.
>
> So, it should makes sense to charge the compressed RAM to
> the page's memory cgroup.

Whil= e looking at this in the past weeks, I believe that there are two distinct = problems:
1. Direct zram usage by process within a cg ie. a proce= ss writing to a zram device
2. Indirect zram usage by a proce= ss within a cg via swap (described above)

Both of = them probably require different solutions.
In order to fix #1, ac= counting a zram device should be accounted towards a cgroup. IMHO this is s= omething that should be fixed.

Yu Zhao and Yosry a= re probably much more familiar with the solution to #2.
WRT per-c= grou-swapfile, to me this is addressing #2, but I agree with Yu Zhao, that = there are probably better solutions to this.=C2=A0

Lastly, this patchset, while it will possibly not address the swap is= sue (#2) completely, is it satisfying the needs of #1?

=
- fabian


We used to do this a long time ago, but we had per-memcg swapfiles [1[
to prevent compressed pages from different memcgs from sharing the
same zspage.

Does this patchset alone suffer from the same problem, i.e., memcgs
sharing zspages?

[1] https://lwn.net/Articles/592923/

--0000000000006f1f8d05fe27426f--