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 3833BC00140 for ; Mon, 15 Aug 2022 17:56:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 936846B0075; Mon, 15 Aug 2022 13:56:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A0D18D0002; Mon, 15 Aug 2022 13:56:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75D3E8D0001; Mon, 15 Aug 2022 13:56:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 681716B0075 for ; Mon, 15 Aug 2022 13:56:35 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 12853C0C3C for ; Mon, 15 Aug 2022 17:56:35 +0000 (UTC) X-FDA: 79802581950.20.0DC583A Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by imf15.hostedemail.com (Postfix) with ESMTP id ACCB0A01C6 for ; Mon, 15 Aug 2022 17:56:34 +0000 (UTC) Received: by mail-wr1-f54.google.com with SMTP id j1so9920416wrw.1 for ; Mon, 15 Aug 2022 10:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=XCzC1k5JaSs6DVSxuA2P3WfUqr4hU66sPfesxZu2dUs=; b=HOKkfB0gFcImmm8qD1rRnAB9O6Np3Uxgn5FoWtQm+SA9NiFobkW0mDb2PoQNBqFCng rH29D9fdqxBaHiwjgUmtaIX/II1UBXNecm+GG8Ju6AhJ4C9Z4a3mSrvGuS2jknZrJnJJ Y+s4yHlSemcD8+ZH1KXhaV9VDkJhmSW8qqweYrSjyNMAU1yNiLAruehBOBq0XweJOm/U rMUCZOu+cPA7fbW45VyT3mZS2uFRmJ4DpFjwxZZqKBCuFCxZ5yQ80+p7UuFjI7zMtJK7 GSQ+PZ4jdWGWBy81yVXZwkuuPDAUNKug6Xr0M3VdqDav61SotURKhAgAPrJ4hwea/Tfw loCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=XCzC1k5JaSs6DVSxuA2P3WfUqr4hU66sPfesxZu2dUs=; b=pKzsbnrp1ROsTw7mFOeFdEIkb9usbnLwI1ilZxZYi1ay9HGrKW16VmNhXyp7feyXNE c2Pw+uwKFlnb+bKvEpjfBTWyz0TJrml2f/5SMsHZSyZW8R238u4JZppYZ4sA5VnX9V27 wChDV6kkvDGKbictOz672tHQZWcyZu1G4J3ll8eaJVhSDQaLxTEpO9ZsOx3T0SMFQBM0 2z4MzOli8r4/nomSWjqQJFDVeVXtrSdxtmh5wapachn5EzbE6knBvVvkOM+mN5FjP8sY HdNbjHXvDs/HqtHDFj0WPN4lroYCUAkntrMLd6GlTpyotXNK7+1cN9C3GCQtarv1IAxq Zhvg== X-Gm-Message-State: ACgBeo0rnWDmjvkrzrWNSTiaqD8Hc4Hn0tGMQN3XM/Fbx6tdJXCd/56J 5a0iTCSrzYfTUYmimlv+sK1YUXHurLhYA6GIFW94LA== X-Google-Smtp-Source: AA6agR5WxDpkq7lUDE4ES4zBp3sfSgorTNgHBU/js0SQqHPAdx+jUSoC7kbBk7VnWIagobmgCUBBptw8Fx1p/oVEJFA= X-Received: by 2002:a05:6000:1379:b0:21f:c4d:957a with SMTP id q25-20020a056000137900b0021f0c4d957amr9538354wrz.210.1660586193170; Mon, 15 Aug 2022 10:56:33 -0700 (PDT) MIME-Version: 1.0 References: <1704B09B-F758-47DF-BDDE-FEA9AB227E12@baidu.com> In-Reply-To: From: Yosry Ahmed Date: Mon, 15 Aug 2022 10:55:56 -0700 Message-ID: Subject: Re: [PATCH] mm: correctly charge compressed memory to its memcg To: Johannes Weiner Cc: "Li,Liguang" , Shakeel Butt , Andrew Morton , Linux-MM , Cgroups , Michal Hocko , Muchun Song , Roman Gushchin Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660586194; a=rsa-sha256; cv=none; b=3V321dGQ2H7hTZLnsSEjXQV3E3jAaxCQPfP5okacodPxX0jdFl8/bxQVgPIQ7AiFvSupfZ MmREtD4w+ZQnqjWxeoxK2iKr8XQIDwyXro+AgcnJPOeLlfRTm8IEy7RC8oaigrhTdXQV3t uq3AKtlCgTZqGfr3+jmsYCDm98E9Ng4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=HOKkfB0g; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of yosryahmed@google.com designates 209.85.221.54 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660586194; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XCzC1k5JaSs6DVSxuA2P3WfUqr4hU66sPfesxZu2dUs=; b=fs/YAY0G3Kbc5nsO3KHrdldi75hN1ZMv3zLzVZga2m5ORaxWtj2jsIkbKryOM36moF8ce+ qUg4URRCHWUB9z2JyUazQesvFOh5zacNYmQotcPuvSoTYAzH8YrZGiAaleIxVZnNiFh9qS Ittx+QKdgDQen75QerKPdCSvtDGOJlk= X-Stat-Signature: s5gp3mmzxshf3x6wrdnajawqru3fdxur X-Rspamd-Queue-Id: ACCB0A01C6 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=HOKkfB0g; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of yosryahmed@google.com designates 209.85.221.54 as permitted sender) smtp.mailfrom=yosryahmed@google.com X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1660586194-681224 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 Mon, Aug 15, 2022 at 10:47 AM Johannes Weiner wrote: > > On Mon, Aug 15, 2022 at 09:16:08AM -0700, Yosry Ahmed wrote: > > On Mon, Aug 15, 2022 at 8:42 AM Yosry Ahmed wrote: > > > > > > On Mon, Aug 15, 2022 at 8:31 AM Johannes Weiner wrote: > > > > > > > > On Mon, Aug 15, 2022 at 06:46:46AM -0700, Yosry Ahmed wrote: > > > > > Yeah I understand this much, what I don't understand is why we charge > > > > > the zswap memory through objcg (thus tying it to memcg kmem charging) > > > > > rather than directly through memcg. > > > > > > > > The charged quantities are smaller than a page, so we have to use the > > > > byte interface. > > > > > > > > The byte interface (objcg) was written for slab originally, hence the > > > > link to the kmem option. But note that CONFIG_MEMCG_KMEM is no longer > > > > a user-visible option, and for all intents and purposes a fixed part > > > > of CONFIG_MEMCG. > > > > > > > > (There is the SLOB quirk. But I'm not sure anybody uses slob, let > > > > alone slob + memcg.) > > > > > > Thanks for the clarification, it makes sense to use the byte interface > > > here for this, and thanks for pointing out that CONFIC_MEMCG_KMEM is > > > not part of CONFIG_MEMCG. > > > > > > One more question :) memcg kmem charging can still be disabled even > > > with !CONFIG_MEMCG_KMEM, right? In this case zswap charging will also > > > be off, which seems like an unintended side effect, right? > > > > memcg kmem charging can still be disabled even > > with CONFIG_MEMCG_KMEM*** > > Yes, indeed, if the host is booted with the nokmem flag. Doing so will > turn off slab, percpu, and (as of recently) zswap. > > The zswap backing storage *is* kernel memory, so that seems like the > correct semantics for the flag. I honestly didn't consider it first as kernel memory, as the memory is coming from LRU pages. It can be confusing to think about, given that it is memory that the kernel allocates and manages, but it has user data. Anyway, maybe it's not worth overthinking this, since it can be considered as kernel memory. > > That said, the distinction between kernel and user memory is becoming > increasingly odd. The more kernel memory we track, the more ridiculous > the size of the hole you punch into resource control by disabling it. > > Maybe we should just deprecate that knob altogether. Yeah a lot of used memory will just go unaccounted even with memcg enabled if the knob is disabled (which is what memcg is all about). This is even more significant now with zswap in the picture.