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 06F79EB64D7 for ; Fri, 16 Jun 2023 07:57:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 933988E0001; Fri, 16 Jun 2023 03:57:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E4516B0080; Fri, 16 Jun 2023 03:57:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 784C48E0001; Fri, 16 Jun 2023 03:57:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 63B6F6B007E for ; Fri, 16 Jun 2023 03:57:26 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 376BE140B36 for ; Fri, 16 Jun 2023 07:57:26 +0000 (UTC) X-FDA: 80907856092.14.F6E805E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 03896120003 for ; Fri, 16 Jun 2023 07:57:23 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=C7yySTQQ; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686902244; 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=UmWx/AJ3S4UDmLUBVcPWvaOILz2i/efbrRdbV4jSGuI=; b=jFUHKWoaLYmT1csAFtA2r3sRh6b4ym1jUQBll5MQOssEvoQibCEI59cE/sqbJYSNgjgtco aO02qEjrAhCiIyLKY6WqaZMOszFjOOjzYyLwkUi7hdfpKCh3S94TKHrcJHEhkENxgt09fS aUsh2JtRCyO/0AoPWffBRtBf4zPMYYA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686902244; a=rsa-sha256; cv=none; b=HR0pmJvvljQc2bFE8p4Eve8Rbd6wLUyDsudmj41MkmFDsZMS4E3pTtX8iOOGdJhls2e4Iy tXgZ/omq0NT/Dx9aEihKqCmzhhqS91T1I8XoMoGOGuvHRYyP1SBR3WmH9K2CWfVmsGSTBS 63/3PDP+qYhlnV3yXVGlciZz8FkGMp8= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=C7yySTQQ; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686902243; 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=UmWx/AJ3S4UDmLUBVcPWvaOILz2i/efbrRdbV4jSGuI=; b=C7yySTQQvurxrmcu7M1pc/XRYsXsQ04wOURCzb1e7ewVsWXbTTgCP9mUEWHDCCV7epEIuX 5bSetCiTZh3gEmI+GIZ+XqjEMdq6VqRXNy41dop5M+b7hF4Ob1Ppybl3aAZvXynn0ny0ME j9Bkoi+xteiI3aKRTWyZaEjBfq51WZk= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-275-vxqrhGF4Nqu2XpmcfwTPOA-1; Fri, 16 Jun 2023 03:57:22 -0400 X-MC-Unique: vxqrhGF4Nqu2XpmcfwTPOA-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-30e4d11a413so726730f8f.1 for ; Fri, 16 Jun 2023 00:57:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686902241; x=1689494241; 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=UmWx/AJ3S4UDmLUBVcPWvaOILz2i/efbrRdbV4jSGuI=; b=i2nvtX4cXkRhAU89Zc5hea2HodHlFtTSFUchOrXqNlm1ZY2tAg4EwlxHxnoXsthFSj aU0zB3sFBeT7uCmE+odKXE4FAxl3PLzs3iOlgQItTVkiBeZbhZDzUDZioBpp+wsO9w0k LijVR9tID6RhfokXKNuyg+QvKSVWQ90BjO8z3Y0/UvTuJy85BpUzD/s6i6fDaJjYfGTH vOLZxufY1ILbVO26VRA1DAqozb9ArtHB6EbxuGePU3nTRARgV1cP+VYB9W5iRwM0NVTU 9jT3B4wsqUzI+EhASNfwsXaHuT4c7hye0gF0remYnJU0GuOteGfDK7tgMvGxxmHnYlXG 5XzA== X-Gm-Message-State: AC+VfDz3PXxDqrhUUiGlJtWwsWBbTT87QEC9yaHIOcBgHBaV8qzNK6gh DCS5hPWRxEaMLfJq9p7EP9wpnHZCMHHYiYW8TssuaNjKaCZ2TILB4nhiZzxTId5dGLuGgNWg9pL FKCJVMM92Vgs= X-Received: by 2002:adf:f2cf:0:b0:30f:c4a7:8754 with SMTP id d15-20020adff2cf000000b0030fc4a78754mr5752990wrp.5.1686902240874; Fri, 16 Jun 2023 00:57:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6d2AQLhsWO/3+dulLJxjLTJZMzdzmShBDo16xLLUx8cfuwi9Vw0TzqPvzhjMH0eEQQ1PY1Pw== X-Received: by 2002:adf:f2cf:0:b0:30f:c4a7:8754 with SMTP id d15-20020adff2cf000000b0030fc4a78754mr5752977wrp.5.1686902240460; Fri, 16 Jun 2023 00:57:20 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:9800:59ba:1006:9052:fb40? (p200300cbc707980059ba10069052fb40.dip0.t-ipconnect.de. [2003:cb:c707:9800:59ba:1006:9052:fb40]) by smtp.gmail.com with ESMTPSA id 3-20020a05600c230300b003f7ea771b5dsm1487358wmo.1.2023.06.16.00.57.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Jun 2023 00:57:20 -0700 (PDT) Message-ID: <576b7ba6-4dcd-48c9-3917-4e2a25aaa823@redhat.com> Date: Fri, 16 Jun 2023 09:57:19 +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: Yosry Ahmed , =?UTF-8?B?6LS65Lit5Z2k?= Cc: Yu Zhao , minchan@kernel.org, senozhatsky@chromium.org, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrea Arcangeli , Fabian Deutsch 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-Rspamd-Queue-Id: 03896120003 X-Rspam-User: X-Stat-Signature: dqmisstj5fmjbggqotwg4dijwf7fyenm X-Rspamd-Server: rspam03 X-HE-Tag: 1686902243-717130 X-HE-Meta: U2Fs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z76DT+fSv9zO11tZ9uqMyuWRaJTvRJbsePEfnJAVU/pUD+rDsRZolihdIafGQ1Xa7qOHKPmIf5CK15HGec48cCZdkStnVf+Y16fd8dXxIXdZx99e8zKiPPm6gNSoiTEnI9rdirU2iYZsIXe/c9Ko1zbMzkNPevMc2AMXmq3+f9zjdDkPSrnYkJaIemUjItzXodUPq53R+z36AhOLw967TvBTATNmOfubBrchX0M56c2Uzb1Gn9mfeXrr8nv86NRM677/pW0f2563akHQGkoKVY4GcMFarMR89fFYf+AIE0S0VBSvJpAYmmDb41an0z0OhFLCcetDV/OyZORbjvJMU7vo1 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 16.06.23 09:37, Yosry Ahmed wrote: > On Thu, Jun 15, 2023 at 9:41 PM 贺中坤 wrote: >> >>> Thanks Fabian for tagging me. >>> >>> I am not familiar with #1, so I will speak to #2. Zhongkun, There are >>> a few parts that I do not understand -- hopefully you can help me out >>> here: >>> >>> (1) If I understand correctly in this patch we set the active memcg >>> trying to charge any pages allocated in a zspage to the current memcg, >>> yet that zspage will contain multiple compressed object slots, not >>> just the one used by this memcg. Aren't we overcharging the memcg? >>> Basically the first memcg that happens to allocate the zspage will pay >>> for all the objects in this zspage, even after it stops using the >>> zspage completely? >> >> It will not overcharge. As you said below, we are not using >> __GFP_ACCOUNT and charging the compressed slots to the memcgs. >> >>> >>> (2) Patch 3 seems to be charging the compressed slots to the memcgs, >>> yet this patch is trying to charge the entire zspage. Aren't we double >>> charging the zspage? I am guessing this isn't happening because (as >>> Michal pointed out) we are not using __GFP_ACCOUNT here anyway, so >>> this patch may be NOP, and the actual charging is coming from patch 3 >>> only. >> >> YES, the actual charging is coming from patch 3. This patch just >> delivers the BIO page's memcg to the current task which is not the >> consumer. >> >>> >>> (3) Zswap recently implemented per-memcg charging of compressed >>> objects in a much simpler way. If your main interest is #2 (which is >>> what I understand from the commit log), it seems like zswap might be >>> providing this already? Why can't you use zswap? Is it the fact that >>> zswap requires a backing swapfile? >> >> Thanks for your reply and review. Yes, the zswap requires a backing >> swapfile. The I/O path is very complex, sometimes it will throttle the >> whole system if some resources are short , so we hope to use zram. > > Is the only problem with zswap for you the requirement of a backing swapfile? > > If yes, I am in the early stages of developing a solution to make > zswap work without a backing swapfile. This was discussed in LSF/MM > [1]. Would this make zswap usable in for your use case? Out of curiosity, are there any other known pros/cons when using zswap-without-swap instead of zram? I know that zram requires sizing (size of the virtual block device) and consumes metadata, zswap doesn't. -- Cheers, David / dhildenb