Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35195263rwd; Mon, 10 Jul 2023 04:09:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlHDJ6P1ETUtDFqwcpmfzfVVkRgdhELW3AjpcERbN0t197MPcK33O/pkjT5A5cwTGUovL0YG X-Received: by 2002:a2e:a40b:0:b0:2b6:a5df:c7fb with SMTP id p11-20020a2ea40b000000b002b6a5dfc7fbmr9215419ljn.26.1688987363256; Mon, 10 Jul 2023 04:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688987363; cv=none; d=google.com; s=arc-20160816; b=Zm87OCj/aaNj+fbSEgeqr/XWV97ZQJgvCDipf2c05cK3sK8j8JexxcG5ciz9Gkb3R6 YhToQuBf07fY/p/tyL1cjUJ4vxY6GIc50rVnQpvugPNABv42Z8pse59y4SHEKlOb/Inh jjHZDWd7xSDZU2DZMjFVqBJaRtUs03PHqZkKHmHOIswlTI2HSMvcizbwbVFenqs3Ur0U tfsrWRYK9oRDQ8LbvKhUM5RmkUzniRIBue1wUu9fAK3sI0CwUkribt19P7/Friw3RiAD R68VM+I2VXvvsRCHF1JTkiTrI7oy4rBo487uifGe7zZIYdyd7xGYqQvZ/G7c5feKwaLl 5YDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FnNJMSnMxZmPiG5/FF+cISxUGMV48vxDdq7iSAZ7e3c=; fh=IvUCxt2qnsflPVdWp/hKHCUy+4hzCZL5pdqmkKnfcFw=; b=R1Lq40Q6IqH+1rlD2K9wemm64/4L2RI60yEe3AX+m2/aYr+DAEexFANdbonfKd3JEQ Fka6rW0FAPHkAsYrZJFqSuPqrDJA7bBMsPmFpSO/Svuk4XgREX1/1UXpzV+8uyoqw3Ge XWJraAdOPk8O6lH3ArQ4Jk0wAOiPva2oHK2pcxMZVrzC8OLu6pidWhVH7zLPT+DDN6Hq KgU9cw8i7aqSXRVAITZzhEHvx/ov5Y96G8gVLBWpSibeRLupTHTiXMMqtdx4hzUhwEJV q34j6VwkoBUAUUp4t3bhQYGjJof/fxaUc/9sXVJ4GV6oGyUiwzIOZeml0uAHZu++FH0V pbQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=pPiOe3kz; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id os13-20020a170906af6d00b00988a7f7cd11si9535032ejb.515.2023.07.10.04.08.59; Mon, 10 Jul 2023 04:09:23 -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=@suse.com header.s=susede1 header.b=pPiOe3kz; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231238AbjGJKlc (ORCPT + 99 others); Mon, 10 Jul 2023 06:41:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233076AbjGJKlV (ORCPT ); Mon, 10 Jul 2023 06:41:21 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D612BF for ; Mon, 10 Jul 2023 03:41:20 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BEF4E1FE9A; Mon, 10 Jul 2023 10:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1688985678; h=from:from:reply-to: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=FnNJMSnMxZmPiG5/FF+cISxUGMV48vxDdq7iSAZ7e3c=; b=pPiOe3kzc+MV1B4ej4dtqFT+rwMiHrGKr8HrphAj7MQ9hz6EI5KV3w6yjzaYQ8f9bTdIc7 ljIVf3mN8QkCd3o4kpFdbMYlJs+L855NrerzwRjEMK/8JRsDTMXLrGwAidh3DqTvKp5Kqr lDRFn4qxVIjX2UOlv6zTZXWlvunXBE8= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9FCFC13A05; Mon, 10 Jul 2023 10:41:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 9N+/JE7gq2RfSgAAMHmgww (envelope-from ); Mon, 10 Jul 2023 10:41:18 +0000 Date: Mon, 10 Jul 2023 12:41:17 +0200 From: Michal Hocko To: =?utf-8?B?6LS65Lit5Z2k?= Cc: minchan@kernel.org, senozhatsky@chromium.org, david@redhat.com, yosryahmed@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [External] Re: [RFC PATCH 0/2] zram: objects charge to mem_cgroup Message-ID: References: <20230707044613.1169103-1-hezhongkun.hzk@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 Mon 10-07-23 17:35:07, 贺中坤 wrote: > On Fri, Jul 7, 2023 at 10:44 PM Michal Hocko wrote: > > > > Why do we want/need that? > > Applications can currently escape their cgroup memory containment when > zram is enabled regardless of indirect(swapfile) or direct usage(disk) . > This patch adds memcg accounting to fix it. > > Zram and zswap have the same problem,please refer to the patch > corresponding to zswap[1]. > > [1] https://lore.kernel.org/all/20220510152847.230957-7-hannes@cmpxchg.org/ > > > > > > summarize the previous discussion: > > > [1] As I can see, Michal's concern is that the charges are going to fail > > > and swapout would fail. > > > > > > The indirect use of zram is in the context of PF_MEMALLOC, so > > > the charge must be successful. > > > > No, this was not my concern. Please read through that more carefully. My > > concern was that the hard limit reclaim would fail. PF_MEMALLOC will not > > help in that case as this is not a global reclaim path. > > > > Sorry for my expression. I mean the hard limit reclaim would fail. > As i can see, the PF_MEMALLOC is not only used in global reclaim path > but the mem_cgroup reclaim. > > try_charge_memcg > try_to_free_mem_cgroup_pages > noreclaim_flag = memalloc_noreclaim_save(); > nr_reclaimed = do_try_to_free_pages(zonelist, &sc); > memalloc_noreclaim_restore(noreclaim_flag); My bad, I have overlooked this. I forgot about 89a2848381b5f. > > Also let's assume you allow swapout charges to succeed similar to > > PF_MEMALLOC. That would mean breaching the limit in an unbounded way, > > no? > > -- > > Chage compressed page once, mean a page will be freed. the size of compressed > page is less than or equal to the page to be freed. So not an unbounded way. OK, this is an important detail to mention. Also have tried to get some numbers of how much excess is happening for a mixed bag of compressible memory? -- Michal Hocko SUSE Labs