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 D44F7EB64D9 for ; Thu, 15 Jun 2023 11:16:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2519B8E0001; Thu, 15 Jun 2023 07:16:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D94B6B0074; Thu, 15 Jun 2023 07:16:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 051628E0001; Thu, 15 Jun 2023 07:16:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E67596B0072 for ; Thu, 15 Jun 2023 07:16:02 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B4F4940B9D for ; Thu, 15 Jun 2023 11:16:02 +0000 (UTC) X-FDA: 80904727764.18.C7972D1 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf19.hostedemail.com (Postfix) with ESMTP id 154251A000E for ; Thu, 15 Jun 2023 11:15:59 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Nz9s3Xkr; spf=pass (imf19.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686827760; 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=9lHDb9N6AqLDS19hviwF7XoFhOr7rPI5scCdJmAq+lg=; b=UIPCKErYfPUV7SWu6ZU1vPbXn4VqwSbw1hCQNOAqAeY4y3s07wQ8s2ABFVWuW5Ng74ibZX zgPGxKOnjN45Jetm2gipapdGEaHzXpFI/7SWW8PCy6R5uXa5S3GWEhfc6yqSAX1QDgMfW5 6ROzdkvGzi9oP6IeT7y7ARMs+DYbaFI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686827760; a=rsa-sha256; cv=none; b=JCwqP8eQHqGCuDQ4OJm8+BGVshsvRn+2DQTF4Q23OnUvR7GPWlEwge0k2+QnnZBgt5c4Xy 6fCqj3YsJBe8nWmuV00UZ9srKqfq3PmcNp8K1PizpgTOgnNG9C0ZWyiEfV7zCEWbRZLyR/ isrWiST/rXZo1nXmZ45jqAfOc3bN9Os= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Nz9s3Xkr; spf=pass (imf19.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-25bec2512f3so518404a91.0 for ; Thu, 15 Jun 2023 04:15:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1686827758; x=1689419758; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9lHDb9N6AqLDS19hviwF7XoFhOr7rPI5scCdJmAq+lg=; b=Nz9s3XkrRR1OfrX3RrHf3bz5QAH2h6dYAnB3WEbr9MEVIdiAzlW8ll0J8sVsZURAL2 RPvro9GFSKvXocKF5Rw1CWRSkIel1Oqqucg+NuOw/kaAVR93EM45Xkx+zDJP4HixXGPg FhwID8grhoXsqhVj78OglXxF7xzUo+7sZY1KcG6RJGCYCuyeikrIOAVWVoalIL6QiVEJ MYFurIe14df4W/TXddbMhWLj+M4js4CBMMCz5+QuE8rEQLS7EC/cvCujvscLtZ0hnq+j MK2nbZkIuhdpKp93k0H4lxEm9n0gBzS0pYdbrzCtVnyowFRBVMvVMvyWZqPpMChUlK7S Jx6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686827758; x=1689419758; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9lHDb9N6AqLDS19hviwF7XoFhOr7rPI5scCdJmAq+lg=; b=JCPHr4clD2qK0p8ihPs3sCgi4gbjIZcFIf+rusVZjlgl+u0BRKn9NTG8Vt6U2XKWiP 0eiKkDmppAYVO6Q+VsNaD9G9q2NITj2VBNAvzh8IveiuHR5WL2dMAqtPOLiVeC6SCczC Qt2AoOaCa8EgdqxW6x2ZLp/UDw/CF3o4wAJZmyDxUr0O/hxEb9vxRBu2ennt7Qat+BQv kQzIKiXz+LDVS9O130G0rr6+93HMJ4psuVO5Qx6V8RznvQQnJ2laIko1zqYg5hRu0jPW Hka5agnriFVMYXyIOokKHLSFpGn+99tt6Cd2WML6sopW11BliP07HTOqg/aV1JmkrtHY 0fvg== X-Gm-Message-State: AC+VfDwLrB9yJJsnMM/nVmNZglCZgyLJB8mm9KdSyurkVEN6X0C45a+c Df4q9aIFxtnSvrHwKDhlCNAtTX6/c+4BxcBM9iq65w== X-Google-Smtp-Source: ACHHUZ4hjQuX78MVw9gdpGr7KgKHa7DkozWlw4hgtDHwWzBo8RjjRow2Kv8LIsqJH2Q+0k94Mh+kfdHR1kiwsMXvxRs= X-Received: by 2002:a17:90a:400c:b0:25b:e25e:9bd7 with SMTP id u12-20020a17090a400c00b0025be25e9bd7mr5802625pjc.1.1686827753629; Thu, 15 Jun 2023 04:15:53 -0700 (PDT) MIME-Version: 1.0 References: <20230615034830.1361853-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: =?UTF-8?B?6LS65Lit5Z2k?= Date: Thu, 15 Jun 2023 19:15:41 +0800 Message-ID: Subject: Re: [External] Re: [RFC PATCH 1/3] zram: charge the compressed RAM to the page's memcgroup To: David Hildenbrand Cc: minchan@kernel.org, senozhatsky@chromium.org, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 154251A000E X-Rspam-User: X-Stat-Signature: 9gpyf9h56i1xbbphxdnhfcsxz9bfh77s X-Rspamd-Server: rspam03 X-HE-Tag: 1686827759-751708 X-HE-Meta: U2FsdGVkX1+e2Kpe2GI2XSNUgp0/RE5IqixmRnceUJaPhhshaP75tOXTKBZSzdGsMML9RElq7UDi19C++oemEVIYuGZ3r80lCCgiWQLCHYvvVGdX+Zb1ZIQf0mfGsNIWaCtSQ4xMeV4vTYNulUkRk220/f88jwxmhm7kTRrZqWF9QYEe36rxQtRVUM+0oVXJJhcgCpkSE4SicSdEyta/ItCMExo14jtNRIKIGcygm5JP0RfcHpBda9kNuURlmZdg4xK5yEl1BPSj0gBsrbEjvmWnUzGB8UrPgCBZjC/zsX+AGy4ssVOjGd2VAky+DzOQM12tpJuTxx5u0CgSGLo62EDA/mn9FUo+bocToyNrEM+t6zTiTKQGHjCG+gqswluxvP7rFGolIUoGJe8fWtC4BeCBcALiJV1CCOQ0P67sBcbDw83QELJ7qEvnM/eE8DtJUY5ds6BfhMydW16TBmzbVTBFvtsx9Rto3V+SeipQ7LaYaVF1CNOM+u2zict4bKocXCK6Fva2eZum1gNFdJssVSBP6vUZT1LNbIkyaBKNHfz7X1zmFOUkwfZGkgS9o+EgGGBs6KwKlqz1h6WbpBr8uIznG/IC+OwkTiT7plZeIMpsBorfXMooLdzb0xBLxJiAVUFY7BI/Smh1f+ylCJKjR4tUj+dx0zVRTqQ9H2zwPF76B6jBFcxjrgjDflarMCSZYN8bWHaM6wfD2veJTqs7+yT2msxsPgo19TXJ5y7GItaS6Ab15G7v2aNOE5GeCWvF+ZWNP3+mMJsM3IbcerJV3Ud7ToIgnVHMZTrsVgWGcVBDJCeaHJ8dZssIAsFYMTfVQVdn0HHDYnBiaPyKZRbN+4EcyGnItB7zBRPxBZzA+LkP7oaHjg8QXqEJWWqToCdI/bT0/9MzqEGIo2tsoVKw1eaG1d5RwU2VC9eVIU7KpkJpQz8w0aVuNTPgiwDKVtBbQIFgWN5+KOee8FEn2I/ mfSUcNms NYoJt0e9ekhz58as4+Zo1Zy4vEHsBZT0s91aYYT0Czo0AW/kLLOhHPcVZeyQpoBPQ48/hlO45usbXZ40wrpYVDQMNA1ElSTcmwI5qaDd2TQRagEzwD0FiEt17VOsgDNo6AOWOx7usNK0rBozekk8+OkpbVUC9uzhfOObpLVvq2WC8lCKnXy2ATPgJIA9yLrxto0/aGRNqmExCRZULC5RQOXePy3TU1GPFRt726bPkmFSRYZFyj2D8XdldBU267becpB7169i3V5U2RsdyBoN3mihYhwxxeUox7Gri 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, Jun 15, 2023 at 5:27=E2=80=AFPM 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 begin= ning of zram_bvec_write_partial() and released at the end,but the compressed mem= ory 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 cgrou= p, which is not charged so far.