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 A0F7BEB64DD for ; Thu, 15 Jun 2023 11:19:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 338D68E0002; Thu, 15 Jun 2023 07:19:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E9CB6B0078; Thu, 15 Jun 2023 07:19:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1891A8E0002; Thu, 15 Jun 2023 07:19:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0A92A6B0074 for ; Thu, 15 Jun 2023 07:19:29 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CCB5CB062B for ; Thu, 15 Jun 2023 11:19:28 +0000 (UTC) X-FDA: 80904736416.04.C696D05 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 97D584001B for ; Thu, 15 Jun 2023 11:19:26 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X7bg+H84; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686827966; a=rsa-sha256; cv=none; b=xUfY2SV27iIF08fwZZFLB72t12Rm0vQxwpXqRH3FZrlgWETVRFm1AL8i31tn5q3Pdufxns j/eSTm1N8IERT9He6qt6+JT2JbrqEgmKnc1TAQuD5vZJsHfJwgMyIEBvI+woQRBswdlbJm 57OeS6iSYIcXmUiFj1k69hJvdQUCXME= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X7bg+H84; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686827966; 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=xym/1KPuJqoFWHnNyHhIyr51SyseepnNY2jGfeKFh0s=; b=gpX0vl7XZLgXzTYhWjWIHa/ikefYpcYLzC0VnybExBYR/1SHE5iLl9VMpBEhD/an+OoU1N WDYbRCNDE7BuiCv59wVen72eOUwDI+0Q7d+lUZ84aP3SOohPWn9N9rMsqoK18lCYeoRibz yH/McTl4pXwSNQgSg8i91Di3bBZDYbk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686827965; 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=xym/1KPuJqoFWHnNyHhIyr51SyseepnNY2jGfeKFh0s=; b=X7bg+H84ZcMVcqTC7HaiBQITO3OBRQbCtOWbuTUXhKR6cAD0n9vAiW9JW9Ghcl1He3aXN1 7M1200Q9dGuh354zCzth+YENrZRm1+LD5nz3qnxq+yT/8tVYCbmoSIucCZKklo1K12U/z/ dRESVQJ/27iee/tTeFG5BFn+PU1r6Nw= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-580-qzMMcCOZOVeb5VSaF0UhFA-1; Thu, 15 Jun 2023 07:19:24 -0400 X-MC-Unique: qzMMcCOZOVeb5VSaF0UhFA-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-4f256ddef3aso5951862e87.2 for ; Thu, 15 Jun 2023 04:19:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686827963; x=1689419963; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xym/1KPuJqoFWHnNyHhIyr51SyseepnNY2jGfeKFh0s=; b=l/RcfzAp8SUgyNCPO6+u/famVXhKhpN70dA6N7A6Xw6aMe9nNCXWkSD/klm/b+q7Zi xQY5g3J0+4gCD1YEPuJ0GGrupbplXeLwBNvl6D5ZOrzuZcXzNOqLPtiWpF504I22zwxo F4c1JgrwqlOz4v9OWX/FQDL4CwnXWeicIJ58Qi7l5WTOLa9tse5Pn86kWCg2/wswMYBm I31wKyKVAHBIgb7xQ7AQ+5SknonHjZaIP8UdaSjozDDdQv2tPXBugljz+I29EjhZFVk4 ETcDTzXxPVs7ZliXEH7pLPFiYFya7mpRy58G7yM8gkgRhajUOBHVrmOmfCZWrNAifG2Q FCvg== X-Gm-Message-State: AC+VfDxncRTGgHJ4PExbIT8MB/euD0LiDAwxQTj/O0mOsPKaO2BkfPb8 GKDHJ8O30gd8VD9jvqu03B4Jlrm/g0H0ZJD762Ya+bc1Iw+CMwm+PcPziP6LDb8xOdjYTtBUYPO EFhHqiPfIIEo= X-Received: by 2002:a19:f20c:0:b0:4f6:1b45:e8aa with SMTP id q12-20020a19f20c000000b004f61b45e8aamr9235092lfh.50.1686827963245; Thu, 15 Jun 2023 04:19:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qWeX/amvQzhTPUWXOdoa3rXAdgKaQPfYsUdAyPa9DKINYSgNmcshdNBbidleI45XccnCzZA== X-Received: by 2002:a19:f20c:0:b0:4f6:1b45:e8aa with SMTP id q12-20020a19f20c000000b004f61b45e8aamr9235059lfh.50.1686827962250; Thu, 15 Jun 2023 04:19:22 -0700 (PDT) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id v5-20020a05600c214500b003f819faff25sm12911187wml.13.2023.06.15.04.19.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jun 2023 04:19:21 -0700 (PDT) Message-ID: <3f54542e-235b-8456-f13f-786d21c6c14f@redhat.com> Date: Thu, 15 Jun 2023 13:19:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [External] Re: [RFC PATCH 1/3] zram: charge the compressed RAM to the page's memcgroup To: =?UTF-8?B?6LS65Lit5Z2k?= Cc: minchan@kernel.org, senozhatsky@chromium.org, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20230615034830.1361853-1-hezhongkun.hzk@bytedance.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 97D584001B X-Stat-Signature: ucr7dzrgu8pyjypzk7zu98zh18sq14z7 X-HE-Tag: 1686827966-930575 X-HE-Meta: U2FsdGVkX1/8RFRUIh/E4ygQgAEMB6u4tvpHNOzH2vOr2HicA3il77T8gfvCE97YGUDbgaIZuXZRCokalwUWTzy/kcQ5Wrz22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5ohu4OHsPx0VqY42o74bjR8h2PMqK9IPTgdIwBFU+T6FSUMgWpRnauJeU8PvaLMNo4+dwtfM8F3IVSbAGh/m6udCNH8Yds8hVeTcuU0DOMP/w1dUqwq9biZWDM1F9nCoyApT4Mh/WexXd0y6CL0/Nndjknv8cWxDCaLcwdGyMO46gLwfVeGwCSvn/gClUhtDyKx0KOWSNP7t0AVSMKgFhOKi96X6x0YPWIY/c0ZALjMeuIE6oSn5s= 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 15.06.23 13:15, 贺中坤 wrote: > On Thu, Jun 15, 2023 at 5:27 PM David Hildenbrand wrote: >> >> Interesting. When looking at possible ways to achieve that in a clean >> way, my understanding was that the page might not always be accounted to >> a memcg (e.g., simply some buffer?). Besides the swap->zram case I was >> thinking about other fs->zram case, or just a straight read/write to the >> zram device. >> >> The easiest way to see where that goes wrong I think is >> zram_bvec_write_partial(), where we simply allocate a temporary page. >> >> Either I am missing something important, or this only works in some >> special cases. >> >> I came to the conclusion that the only reasonable way is to assign a >> complete zram device to a single cgroup and have all memory accounted to >> that cgroup. Does also not solve all use cases (especially the >> swap->zram case that might be better offjust using zswap?) but at least >> the memory gets accounted in a more predictable way. >> >> Happy to learn more. >> >> -- >> Cheers, >> >> David / dhildenb >> > > Hi david, thanks for your reply. This should be my mistake, I didn't > describe the > problem clearly. > > The reason for the problem is not the temporary page allocated at the beginning > of zram_bvec_write_partial() and released at the end,but the compressed memory > allocated by zs_malloc() in zram_write_page(). > > So, it may not meet the need to assign a complete zram device to a > single cgroup. > we need to charge the compressed memory to the original page's memory cgroup, > which is not charged so far. > Yes, but my point is that there are cases where the pages you get are not charged. zram_bvec_write_partial() is just one such example that highlights the issue. -- Cheers, David / dhildenb