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 9ABC1EB64DB for ; Thu, 15 Jun 2023 12:16:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF8138E0001; Thu, 15 Jun 2023 08:16:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA8036B0074; Thu, 15 Jun 2023 08:16:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6FC58E0001; Thu, 15 Jun 2023 08:16:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B58176B0072 for ; Thu, 15 Jun 2023 08:16:55 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7FD011208E8 for ; Thu, 15 Jun 2023 12:16:55 +0000 (UTC) X-FDA: 80904881190.22.8DAFF19 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf08.hostedemail.com (Postfix) with ESMTP id 8A1A116002C for ; Thu, 15 Jun 2023 12:16:53 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=mTBdbL6o; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf08.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686831413; 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=86pO/5pX8I+6NSA3fZs+/KcyWC6lgb7caHW7+qPc8ko=; b=z4c/ZHiw7Lhk44t+b0wbgOWpzIX6TML82PnZAcmTlV7wmxMgBtVYNXHNe2+paIV22z4HGI qzjo302Lz34HE8iYlz/efQWXxS3mtRal0z1SfW0MMJDVSVg9HR+GfNhSNsI8eJvew2ALMR gvjTG4esAROVDUt6T+98IM42Kt1kNlo= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=mTBdbL6o; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf08.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686831413; a=rsa-sha256; cv=none; b=C2fF3uvNEvbvglUEr6lPDdNt5+w2oOoG5Oezy889QbA9F1c/JBnjsIFNtnq0TJRXre+ARL rNeB33K+O5h8L+Mwbsbyre2HzJO61Q0w5uqb4PuCD6diiqT4+Q7sub38wQWOY0NkAhFNqB hsbeFLiL5yvkgDVTOAd6Pw/3UQpXC3E= 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 A05051FE0D; Thu, 15 Jun 2023 12:16:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1686831411; 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=86pO/5pX8I+6NSA3fZs+/KcyWC6lgb7caHW7+qPc8ko=; b=mTBdbL6oQEScJdyCDi72UHa9I2GLbRNJ5ZjBPYHndoipUG71Z4Xxu63EC27CX6SqH+vo9X FY6pdkkt8YRTcB27ib4YCNhwkeC/1pM5HqDnfft8LjxWV887AzC6Q1dGJNX59BghoFDaUU YdVK15054ieCTAdkL/LC09lbkfUFbLM= 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 8F73013A47; Thu, 15 Jun 2023 12:16:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id xmtlIjMBi2ScLQAAMHmgww (envelope-from ); Thu, 15 Jun 2023 12:16:51 +0000 Date: Thu, 15 Jun 2023 14:16:51 +0200 From: Michal Hocko To: =?utf-8?B?6LS65Lit5Z2k?= Cc: minchan@kernel.org, senozhatsky@chromium.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [External] Re: [RFC PATCH 1/3] zram: charge the compressed RAM to the page's memcgroup Message-ID: References: <20230615034830.1361853-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-Server: rspam09 X-Rspamd-Queue-Id: 8A1A116002C X-Stat-Signature: 56inynd7xrtq7otscxxozqjr5h1h8h9q X-Rspam-User: X-HE-Tag: 1686831413-777303 X-HE-Meta: U2FsdGVkX18a8Fg8l1O8knz8XKNPNs/H66WcSSitpxQHyrojuC4bjiGtdhC5eMBc49LVpzg8Ta2jwyAyQ+X5gSraYgNzGG1zM2ONWwL+0iB/l3tmFsXmJKRPa7vWfIo1LL/NOgbOlJSuaxkSMijFgL4jcvAxTKgjOZnE+OH4ZAGtJmvLf8HSoPcA6bHKhYXIuB29Du5SVn+okOhye05quITsldnt76P5LUXtqThUo3XiYlrTEaPz27FdxUrsyciX1y8XwTGk5l/Vxua8Ae4RYQ0BHQGrssH4kreJeJByv1SMj/2aNdBnbb8wiPdytNmS7TeCj4pCBOB3PAQ7BGYRPGYfkU+C+0qR3535iPflK7FknhE2zwQ5vIoQvAXIGyS7s9wxWfNlFJ+FBs+G/vEwEy6u3XsP5M0rh9JMa5AdMRmEQ/r7go9ZwU05WTCBrGOlD5IduekTJxWdIE7SPtQoIF1JQp3Yu8IFpbUO59Dk6iNvSJB8P1LG/y3DqT21kW7LFb3DM1g06P6gXqMXVx7C6VKl3cLXx2XzD9+fFXx0QAiVrBA9glUY5oOu7xYVrqnwElyKOZSrY3K81xiRwQUnKiLaH19p5dvzj1oI2TbMQtS3ngDCiIM9+W1k/ZqOZ55g5EJk/w321d1l2ii7V7sNpbr/E2Hud/CK4bT3xJl17mJifc80PSGVz19pnZB8Qvnhc54n5hT3nP+PlJZF1ppNZucTJmGuK2WdD3B8cYoL4MBLs6uL3PWiOyQTp5VJABJ1F2G2Yr1/bWK7wnEJS54g7tDbiimpF7+lnC+vIlZhLGEXK6QDokpnLaRhNI19GE/gjRNlgKRA+b1gpECBSmydmwBQuokmbhx03CygQwrVparFpuVQXDAFk/JI9XqMKFJgTHE4bA3arP372+hL2S1R/9UBykjEke9Ijodv1JM2eHyrdhZbeaNVIkTiQlpjiVPy3yJu6VsP1wrYgV6yGT3 5ZJsh0Ji sffNZ6o1OHaNMxJZoylH4RD+1j1Zfr42Rl3zoiD74dD6m75z0wE+HTLqUGRzfa6BTlnwDsXhIDpsOlIii/35ysv8kSZN5FQkErmpUXz4DqJU7N5J5U73tLZrnX+frGpZV3nedhB6vkCuBSySDL9eB7mnd8A== 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 Thu 15-06-23 19:58:37, 贺中坤 wrote: > Hi michal, glad to hear from you. > > > I am not really deeply familiar with zram implementation nor usage but > > how is the above allocation going to be charged without __GFP_ACCOUNT in > > the gfp mask? > > Yes,zs_malloc() did not charge compressed memory, even if we add this gfp. > so we need to implement this function in this patchset. But this flag should be > used to enable this feature. Let me check I understand. This patch on its own doesn't really do anything. You need the zs_malloc support implemented in patch 3 for this to have any effect. Even with that in place the zs_malloc doesn't follow the __GFP_ACCOUNT scheme we use for allocation tracking. Correct? > > Also what exactly is going to happen for the swap backed by the zram > > device? Your memcg might be hitting the hard limit and therefore > > swapping out. Wouldn't zs_malloc fail very likely under that condition > > making the swap effectively unusable? > > This is the key point, as i said above, zs_malloc() did not charge > compressed memory, > so zs_malloc will not fail under that condition. if the zram swap is > large enough, zs_malloc > never fails unless system OOM. so memory.max will be invalidated. I do not think this is answering my question. Or maybe I just misunderstand. Let me try again. Say you have a memcg under hard limit pressure so any further charge is going to fail. How can you reasonably implement zram back swapout if the memory is charged? -- Michal Hocko SUSE Labs