Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp839892rwd; Thu, 15 Jun 2023 02:49:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6lA3zIyrwNsaLcxN/SxeeA+ZhlmDQ/uvCT4kjuc87SquoOt/oAFhXK7h0BrNmK3IMqtohn X-Received: by 2002:a17:90a:5792:b0:25b:f396:c3bc with SMTP id g18-20020a17090a579200b0025bf396c3bcmr2729011pji.48.1686822582098; Thu, 15 Jun 2023 02:49:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686822582; cv=none; d=google.com; s=arc-20160816; b=NjVQoHRqZwBMe4mtfZTGDXw9WnFSsrv1+/oSL20nF6adFC07gsKIRFCLiiyKE3Yd8J TPEmY/f/DGTJPDQ3P186vvrytuJcIb4NN7U7WcYe3th8fLC1MQ/OAgs7pi/38dMzImZI YsxkxTGJTEasM4N4vQfD4B14/7QPlpKWRLOAXU6371JM6/p6o4iXXsGuevY5HO4l6FcL yIwlPDLQtbPLYWXS9/VOxoZD7Ew3itGopcCbazqOcRXzywxBNQ/swdAbsJD7mheluyAj CErbtq5zamcYlyE7hbjNrR8nQ04YFG0EPvaeMmTOLXCmWL/yvSi8ZROwlEftVUlexDIz +dqA== 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=By+qTcV00Wxy2aMxnryfOK5l7c3RlTf1drDswP2UWb8=; b=LT4BCDg1I9k8XdyfZPKKx0uZcAf2Jfj+7D1w6Vf0e8BJuG8DVBPCpzTcgTcRnZJ+bN z28F7T9BLFBoJG4RXd23wM62zu+NVjS7lwjJJGjcM0Dpx5KFQAx+HplSzmwPUn1GOAau d7n9JptEJ2pM90MljY17j1/neULSZajOUZ0DN4/KuWtNTWHWQNgv9sswj+d7zTzZd4YO HcWVyzJLyIMyG62v+LcUV+ZkhSEeV0lxoTbDMMdmG61GKLtv3g7yUa68htQrH9g1I5zw fsAR3djNPb+JJljK4uB57s2uwNBMpRgiTHyEfTpKroZxQVIoszNBq7xYnfHAp329ZKPl KjTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hByuYn2j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19-20020a17090a199300b002476be78cd2si14268644pji.121.2023.06.15.02.49.30; Thu, 15 Jun 2023 02:49:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hByuYn2j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245735AbjFOJgC (ORCPT + 99 others); Thu, 15 Jun 2023 05:36:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245580AbjFOJeV (ORCPT ); Thu, 15 Jun 2023 05:34:21 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42D9E273F for ; Thu, 15 Jun 2023 02:33:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686821590; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=By+qTcV00Wxy2aMxnryfOK5l7c3RlTf1drDswP2UWb8=; b=hByuYn2j1Yo7fIKVAav8sR4AvuvFJ1yF/azt7oW8mJoyaVBzbbqjziKeO+cO6XAOfZWlH4 lkGkAIW3be51Frfg1BXwTyUSzUWABO5Tbwl2F0Gl40KBcKvIHJ9WZHEqpiu/MevTGYLZ1f BlCmIsm7VBPawCF5xBmkUKOEC3UG11E= Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-122-pd2jSf8zOl-LhVxEOe-c2g-1; Thu, 15 Jun 2023 05:33:08 -0400 X-MC-Unique: pd2jSf8zOl-LhVxEOe-c2g-1 Received: by mail-yb1-f198.google.com with SMTP id 3f1490d57ef6-bc9483b506fso1724121276.0 for ; Thu, 15 Jun 2023 02:33:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686821587; x=1689413587; 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=By+qTcV00Wxy2aMxnryfOK5l7c3RlTf1drDswP2UWb8=; b=WTpPDJ6WISgCBrnQyQ3DhjqWOZumKxn0K7pMl44BCqdCjMJDltennny60bw8TVx7bp vz21grhnu52hYDxAkeacbwuJSz4GswfzWGWFwdwy9dJWlPEC7FUcDn+f5ERu3pZA3E9V 8Cu0hs7WRtpnBulJbJG9HBlqQsyglJiyWciG6FXIkXrAlwxnovN1eFep7xIf/UF484gQ BESf7Xu/kEAMMqji5UKzaIg8lTavIL2Nc9dN4l/Xn1ExNFvhy3bNCaB3P6S0ynRDrST3 04zjnrqAztxBqYPQjUOYRS6J6YvYNUJrtVLhNiw/tFEa3qs3WlHzcX9IHoyO5O7wXpuL ouOA== X-Gm-Message-State: AC+VfDy+abGqUzxJ9rMdGkTd+0yym41zzZUArxs14WynR9Y0+Szx21bA vaGhakopVgqZRy+RuW0KrNK1+IrDN19vYSb4nkbemL5LfxZkKliLDLE5sSckHorbPM7WHDgFTrs scA3L/NE9hR8a9/soVESIzLDLzTv4h0X9felHj49S X-Received: by 2002:a25:c5d3:0:b0:bc9:1019:541 with SMTP id v202-20020a25c5d3000000b00bc910190541mr4511769ybe.8.1686821587595; Thu, 15 Jun 2023 02:33:07 -0700 (PDT) X-Received: by 2002:a25:c5d3:0:b0:bc9:1019:541 with SMTP id v202-20020a25c5d3000000b00bc910190541mr4511761ybe.8.1686821587344; Thu, 15 Jun 2023 02:33:07 -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 11:32:50 +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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/ >