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 01D78EB64D9 for ; Mon, 10 Jul 2023 10:41:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BFB76B007B; Mon, 10 Jul 2023 06:41:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76FBE6B007D; Mon, 10 Jul 2023 06:41:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6375F6B007E; Mon, 10 Jul 2023 06:41:23 -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 50F036B007B for ; Mon, 10 Jul 2023 06:41:23 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 25036AFE3B for ; Mon, 10 Jul 2023 10:41:23 +0000 (UTC) X-FDA: 80995360446.05.0150B06 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf28.hostedemail.com (Postfix) with ESMTP id 30564C000F for ; Mon, 10 Jul 2023 10:41:19 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=pPiOe3kz; spf=none (imf28.hostedemail.com: domain of mhocko@suse.com has no SPF policy when checking 195.135.220.29) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688985680; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FnNJMSnMxZmPiG5/FF+cISxUGMV48vxDdq7iSAZ7e3c=; b=XcL9wK7aTA+984anprY8lBisslt0gWvR+gC3VNzEQ60TrJ6KybGBhJ0jtVMfXfFXm6oEMx mCBy9MtccYYGjQn6ByOr8quIqoCP297Z2UjNnBMXtjFii3L9zc2HRu5hVkIB33lyKePiP4 IcCTduWR6Vq0Xzq2hZoNPgr7LUkfV8M= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=pPiOe3kz; spf=none (imf28.hostedemail.com: domain of mhocko@suse.com has no SPF policy when checking 195.135.220.29) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688985680; a=rsa-sha256; cv=none; b=n9eZK+H3QObP/W1CeNtZwzot4eiWDN+HS3fgzDQpWeAQxP0wP8xRTazTHP3MVTzkvbTdIc V0wHCOxq+/Ayo9EsX7gAjzVceYMh8/wS88g/bspxQ3cTordQwLZo8007N1dfjcABY7mqCx UgsPHnPEFf5BwGkzjp0qq0VzVJSoQ7U= 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-Rspamd-Queue-Id: 30564C000F X-Rspam-User: X-Stat-Signature: tjiekmo3ua1qe4roqe5wieawen4e16uj X-Rspamd-Server: rspam01 X-HE-Tag: 1688985679-472667 X-HE-Meta: U2FsdGVkX1/Dm3qx/XGRGbzWPJeINo006WA1KpfU0ILDQS1UMB81EcDqq0GCUoAMSuFhyRqNW9C0tViSkuu62/IeP3JiUPCu3yXkJBVV2SyroDQADbMIElQ02qsxpq1cvhDRzEXoTiERAqcvSysnqZUmLw7VvD7/BrPoNgXDt3SxQr3TpwzAQF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FkRNAqhXp8mTI0QKBXcrxx1uA1y1EibwYnfpNocAvPU7iXLi3CSs+FmlfVwrA0y243RHZvW3knmd7aPXrURYv6rjA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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