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 39699EB64D9 for ; Thu, 15 Jun 2023 09:27:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97D468E0001; Thu, 15 Jun 2023 05:27:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92D186B0074; Thu, 15 Jun 2023 05:27:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F4868E0001; Thu, 15 Jun 2023 05:27:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 709B96B0072 for ; Thu, 15 Jun 2023 05:27:10 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1BD441A0B67 for ; Thu, 15 Jun 2023 09:27:09 +0000 (UTC) X-FDA: 80904453420.11.984583D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 49BFD40010 for ; Thu, 15 Jun 2023 09:27:07 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JQnR0T5j; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.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=1686821227; 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=zZrI8MJxkRt96MsBfDiNN0LAkuHZhh0+OjJ9xsZzehk=; b=0zBcTUZL6XZLlbvKeV/J2B4F54OLKZ4GQzScyohYWWxZgOMnQdLTYo61twRuEpxNSrMNIr RFMI5zBkZqEAaZ06BUcEiDpdE5EiXMQaAPdEj7za2QZRj5+edGy/HQXMu7iDxJ45rSfgmM 1KSxIiubWQ+KwO9gPB2CVDgvQXSCO1o= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JQnR0T5j; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.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=1686821227; a=rsa-sha256; cv=none; b=Gobq/y94xBddlfM9vy/qpIK9KgbyVMnc+XXb6E30wzF7/b/grwMCJrxNavCv2hmXKARkCa 7hySVj1+PNvoUVCHMyg2xFD+vn8VxdJQfF2/B+/aMHUBxIoO4Pui4/ZwU4xp69quhjpGbj GUZOVP6WB2efGH8BUDgj2su2XTOr49g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686821226; 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=zZrI8MJxkRt96MsBfDiNN0LAkuHZhh0+OjJ9xsZzehk=; b=JQnR0T5j7UcPFHLxYIhsJ+5OvYpKVvxEnqR9xxpZ77QYwtinzf0bvJmxKhvYXUaRacNN/g eLEfZr5sXxRIbtCoFf0bVjyntPJUaLwPKtmvESJ4tbP4XChN/QSl+KDvSzkntL6nyjCphu 7yMz0mFTSahxRXvK5UmzoFwCtMU6xiQ= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-390-RmcjLfj2Ov-QKtM5LC8KVQ-1; Thu, 15 Jun 2023 05:27:03 -0400 X-MC-Unique: RmcjLfj2Ov-QKtM5LC8KVQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3f7eb415010so2871655e9.0 for ; Thu, 15 Jun 2023 02:27:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686821222; x=1689413222; h=content-transfer-encoding:in-reply-to:subject:organization:from :content-language:references:cc:to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zZrI8MJxkRt96MsBfDiNN0LAkuHZhh0+OjJ9xsZzehk=; b=g2MY4J02u3IGtuZUUpQy5MBVlGqArRlhjocyyDdqJakqlhwjB6Dl11u6LhN9GWDE8l sbewh3hSW66CijE8uokPIq/IF41vtlkwa7SPeZty0Zu6JF3c4xSd9pNB4JanRpTGXIL0 eOyk1rge+oqxoz2WU0IR5KfXiWaAxZutsWXaB+64oyccP0Sq//w1j/Xs6NuPVkdld9Iw HqBC4v8Jq+Ptw6H70kL/m9fH6hD4A2h0O8Dez5vKlpsCpyGV6Kl88ytyLPBuipTQ2g+a KOu+v4MhLH9PFD7OVVEr6Lt8ZAby/4fqFgSg2WAPaXY+n8wmc9CWPOCAgnkYqtEPic4P mR2Q== X-Gm-Message-State: AC+VfDw7Nru/sJEn47ZltrzlRdynw+d0JEihuhReR+IRFsBEF4zxuFJJ yI7XpNngPylk4nm5Ne8zhvpuf9BtSaLqIfaRjRTdPox17Skzd0qYMp8oeXwELj6VQsEwtS9RxgE hUZ8a9Wbj12A= X-Received: by 2002:a05:600c:3659:b0:3f7:aee8:c23a with SMTP id y25-20020a05600c365900b003f7aee8c23amr3601810wmq.19.1686821221902; Thu, 15 Jun 2023 02:27:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ55eTeV6vXal0aLWeGUSfGS3HPQdBY6AlAP1O4LroxAtYmg/toLDFJGndpdgI/4s0l8ovy60g== X-Received: by 2002:a05:600c:3659:b0:3f7:aee8:c23a with SMTP id y25-20020a05600c365900b003f7aee8c23amr3601793wmq.19.1686821221502; Thu, 15 Jun 2023 02:27:01 -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 n18-20020a1c7212000000b003f604793989sm19928270wmc.18.2023.06.15.02.27.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jun 2023 02:27:00 -0700 (PDT) Message-ID: Date: Thu, 15 Jun 2023 11:27:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 To: Zhongkun He , minchan@kernel.org, senozhatsky@chromium.org, mhocko@suse.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20230615034830.1361853-1-hezhongkun.hzk@bytedance.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [RFC PATCH 1/3] zram: charge the compressed RAM to the page's memcgroup In-Reply-To: <20230615034830.1361853-1-hezhongkun.hzk@bytedance.com> 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: 7bit X-Rspamd-Queue-Id: 49BFD40010 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: x94dokomiw8nwwus1gip4ayqjsmc58fj X-HE-Tag: 1686821227-132441 X-HE-Meta: U2FsdGVkX18FxRhM+e+Kno7cu58VvU9YdoZrYUnWe3t9NPIQ8ySvluhODHuSr5BcXxpWnivNbdrpoVEOCRUqNDGJ6zrObtlPzguKOP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L7fzoZ25BO9js3EjCkyc2qkWttLmT/Y44bCTa4sSGfm+g2oNWaA7+GE8pkxh8E5bgSeDJ1Bzcbm/Klz65B5cRda6jIcAs9SIV8AgH+Ss47/CVxGdjy9GAI/s3JkybYYQLAikVhNMVrshijVSL+jvRbK4y3pX/vwe37oyzwErlii2aYaebCyoIvteTQwiM+SkZMnUHYYcpk9BMiez+ePnM1q3A== 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 05:48, Zhongkun He wrote: > The compressed RAM is currently charged to kernel, not to > any memory cgroup, which is not satisfy our usage scenario. > if the memory of a task is limited by memcgroup, it will > swap out the memory to zram swap device when the memory > is insufficient. In that case, the memory limit will have > no effect. > > So, it should makes sense to charge the compressed RAM to > the page's memory cgroup. 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