Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2236897rwd; Fri, 16 Jun 2023 00:47:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73HZf49q7eP7tZo09wnMlwQTnuljCUK/vykIDYf6GM9Zul0Kbow+vRiCEzBOJSRqMgUPlZ X-Received: by 2002:a17:902:f541:b0:1b2:5689:8686 with SMTP id h1-20020a170902f54100b001b256898686mr1071523plf.63.1686901674347; Fri, 16 Jun 2023 00:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686901674; cv=none; d=google.com; s=arc-20160816; b=SgUcBGSq/Dl1adR6iG0TeKVbBsQImuUQo0Xd1NHhG52WX2cgXvHtx0KjrFy9/fVpIX ZRSaIOuJ23UyGqTlcohXK6hKdgQZL9v2w6m9j68qdQVGD6ysy8OIIi3VKF0fefPaThyU yTGYQ5u+rVmUqx88AkE7rzSIoprnf7FgTj9ICqSctnTR5+5IMZP3iadff8+HHtcrqfI7 4StJlE7Qw030uyWEbYVDP+919MDluuAkq5ah3whckp2AlxesT9STeiKxRALpcdZUXgPV fNTwOVZAYa07lRTeLEVt/8exBi4/C3yIGuTIIP9XL8k4FmTX0uCgBDCbMVsqFhSdDAEE aNPg== 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=j9HtoWwqGbgtEf/5EsF/+Q8jXO/MVPbsLyMQC67iLCk=; b=u4X7HCDev4qRAqoDmSWxJVk7D+NRpkQdCd9hN8ZeQNrPXsrQqcFoHhthY42VW1GPeN d7EK7XF7S88JF6KSasrH/nKPfDrohdtsGY1RQwOps7PeOBBJ3me/A2sQQEfKNaHnk1Xv L7WiGYWvI32yn1/8XPbIULo/wyAIv8ujGILvbQRMrd+7B+vBfWvvu2+Saj0xIkEaA1DC FuoKlGiWegENTiD4iA0P+/Zvqk6tLixyxg+bMMgU75YDAdKSZGYFROvSKF2SqR8tSosj B2jUQVyLVTjgkHyEwgBWTICrJN9ft/J0+MZ5+iqBhQwoDaApCsXQmGmVhHzFR8I/5FQz lAJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=raHYCTMx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o9-20020a170902d4c900b001a63d8efabasi9712171plg.445.2023.06.16.00.47.26; Fri, 16 Jun 2023 00:47:54 -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=@google.com header.s=20221208 header.b=raHYCTMx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240822AbjFPHib (ORCPT + 99 others); Fri, 16 Jun 2023 03:38:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231671AbjFPHia (ORCPT ); Fri, 16 Jun 2023 03:38:30 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11DF81FF7 for ; Fri, 16 Jun 2023 00:38:29 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-51878f8e541so435164a12.3 for ; Fri, 16 Jun 2023 00:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686901107; x=1689493107; 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=j9HtoWwqGbgtEf/5EsF/+Q8jXO/MVPbsLyMQC67iLCk=; b=raHYCTMxMkgdF/Ic0WyVRzoA5Z3PZJ8J3oPfOEr5JJr3VIZROzo39uTK/MhsjXI9rv o0j4Ho7dzbjbj6WLakxNQZOwSWTY/nBf9KUsKsOfJcnKCXW9LkMMbJP7k4hTz7+i6Csl 1TNBBLMM4U7orsg9HxATqGLaFS/4NH2HyJiTap2oLgf4nSpkPKC3X3QaZAChSz1BECU8 oCPpa98bKmNgEADhgCArajuAQnaCZ0kmiEF6mCCA/9v+Tt01VZSYUh7rbp1X6AGhbi0M r9h+IEpwWXUBX1XfXGKbh4rQ4c5PfoD5BOzOI7Hv4VRgVDQrUWcChC7Ay70AvBknH2bm MctA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686901107; x=1689493107; 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=j9HtoWwqGbgtEf/5EsF/+Q8jXO/MVPbsLyMQC67iLCk=; b=NUO/vS96/5kvpIsOtAkGX9zrAho5hXAlhpI+qwlqsv6lmOqqxEN0184yYNaPJknT48 A3vRz2FNEFBu54P6btBOLiSL2zhcQaY8ZYHNmTOj+B1EFKBLTnuw+DqvHhcSuWrOmkWh NgPsH6K9h/eNDsafzT4GCig59koarcELpzJJZo/MJXZRWlNFIBuVYKLkge/t59k5zOmK TTInLQQ0sb01+p/UIAUKGKv1WhiJavzNTeeZXUfFPsOqFYTlBcqnysRFaQbpGsyM+sSJ neYA93LF6D+k+2ZVZXJtWcKAEOIlVlKbqRlo+QkW2iPGIm50Kulb7LPdrui5uyAtH8jS wQ/A== X-Gm-Message-State: AC+VfDy/wa6Va8crSbeSZ3S/h/8Wp+FSnzXUN+oK8uo/6GVTH8/Kw4Ps 6I2tVY0Ge21eaSaofxiGqcgoFenkhVtPvQrmOmuo+Q== X-Received: by 2002:a17:906:f250:b0:978:6e73:e841 with SMTP id gy16-20020a170906f25000b009786e73e841mr771948ejb.35.1686901107361; Fri, 16 Jun 2023 00:38:27 -0700 (PDT) MIME-Version: 1.0 References: <20230615034830.1361853-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: Yosry Ahmed Date: Fri, 16 Jun 2023 00:37:50 -0700 Message-ID: Subject: Re: [External] Re: [RFC PATCH 1/3] zram: charge the compressed RAM to the page's memcgroup To: =?UTF-8?B?6LS65Lit5Z2k?= Cc: Yu Zhao , minchan@kernel.org, senozhatsky@chromium.org, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrea Arcangeli , David Hildenbrand , Fabian Deutsch Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 9:41=E2=80=AFPM =E8=B4=BA=E4=B8=AD=E5=9D=A4 wrote: > > > Thanks Fabian for tagging me. > > > > I am not familiar with #1, so I will speak to #2. Zhongkun, There are > > a few parts that I do not understand -- hopefully you can help me out > > here: > > > > (1) If I understand correctly in this patch we set the active memcg > > trying to charge any pages allocated in a zspage to the current memcg, > > yet that zspage will contain multiple compressed object slots, not > > just the one used by this memcg. Aren't we overcharging the memcg? > > Basically the first memcg that happens to allocate the zspage will pay > > for all the objects in this zspage, even after it stops using the > > zspage completely? > > It will not overcharge. As you said below, we are not using > __GFP_ACCOUNT and charging the compressed slots to the memcgs. > > > > > (2) Patch 3 seems to be charging the compressed slots to the memcgs, > > yet this patch is trying to charge the entire zspage. Aren't we double > > charging the zspage? I am guessing this isn't happening because (as > > Michal pointed out) we are not using __GFP_ACCOUNT here anyway, so > > this patch may be NOP, and the actual charging is coming from patch 3 > > only. > > YES=EF=BC=8C the actual charging is coming from patch 3. This patch just > delivers the BIO page's memcg to the current task which is not the > consumer. > > > > > (3) Zswap recently implemented per-memcg charging of compressed > > objects in a much simpler way. If your main interest is #2 (which is > > what I understand from the commit log), it seems like zswap might be > > providing this already? Why can't you use zswap? Is it the fact that > > zswap requires a backing swapfile? > > Thanks for your reply and review. Yes, the zswap requires a backing > swapfile. The I/O path is very complex, sometimes it will throttle the > whole system if some resources are short , so we hope to use zram. Is the only problem with zswap for you the requirement of a backing swapfil= e? If yes, I am in the early stages of developing a solution to make zswap work without a backing swapfile. This was discussed in LSF/MM [1]. Would this make zswap usable in for your use case? [1]https://lore.kernel.org/linux-mm/CAJD7tkYb_sGN8mfGVjr2JxdB8Pz8Td=3Dyj9_s= BCMrmsKQo56vTg@mail.gmail.com/ > > > > > Thanks! > >