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 20F26C25B0E for ; Tue, 16 Aug 2022 22:19:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F7A68D0002; Tue, 16 Aug 2022 18:19:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A84E8D0001; Tue, 16 Aug 2022 18:19:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56F2C8D0002; Tue, 16 Aug 2022 18:19:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 4537E8D0001 for ; Tue, 16 Aug 2022 18:19:28 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1D868160693 for ; Tue, 16 Aug 2022 22:19:28 +0000 (UTC) X-FDA: 79806873216.18.E812048 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf06.hostedemail.com (Postfix) with ESMTP id C3B5418004B for ; Tue, 16 Aug 2022 22:19:27 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id a8so10902555pjg.5 for ; Tue, 16 Aug 2022 15:19:27 -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=/vkwmLHblp61YfsURm3yRKZjj5rnHEuckjDW4SKaq/U=; b=CG5u7n19ZObiTmC7dk1tO/D9YWD/37ZTz/+CG2AKj2mRMJ7g+K0tI75Y94q1xDO5Y7 4w4SSCAa+EBIw4jdbxmMN48GSbq5CYTKKjcTZ1KH0+mWnHzvHme8CMNqCQSxR0K65mTd XejVK86B6WW8ze2ZsTbHXaCl5uml/jHTaVYWIodvfvHLyuvvKS9Z5pJ9I8OGvqLTQ+sW 2fCEJ29AyxSd/mkt2SB4uS/jSOKOMD7dY5tGMZpa/ukEVrGtOlNaQCCnZ9Sqm0Mc4s1G ROC0wwCBHJdXCih8l6GUlivMgBNlsuF45Yl3dbCgJ0sfNnXA6bUQeuhduoaEd19TcaAz +bBA== 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=/vkwmLHblp61YfsURm3yRKZjj5rnHEuckjDW4SKaq/U=; b=sBjwMW/C9iemWdpGiqu/zGbS2u4eAgm7fOPVq1r85rqqh53OTD5F90v87s2nsOwy7j Qdr3LDSh1urwJX5/5GFKvZ1pEnmoYruIO1pjtupLa0RzdbEpPZQxvqe6hGTsj1rmsd2/ cmp2u5WWypC8+A87QlXMFnU7DIk/uu2fC/PjqtWLdmn0bIphKrcd3nNMFeXoQnK2H6DI CIC/iP43P2GW0e/a5RX/UemFsCR8Q13ZV737vFyO26CsEEL4QMztUh2Gm+vgpxPN2DkR TqPhwbPMklhbC4T5fX9NiDAgMVUE2du7lxb5nB8MAmihU7CxkafPrCOkZFeymBELupjY 0bBw== X-Gm-Message-State: ACgBeo06OJE4YtKd5ffkHO/WccKL0I4XfV2jX3suF6A6rSajW73ZcWW+ jVdTdRuRQZ4q2mvlIQk7Hb2IYJs0r2X0cnCHsLOj4g== X-Google-Smtp-Source: AA6agR5xm/QKqhmnvQ9vc2Upkbu/QoWjM24Jk+5D61SjCo+NYDkohaqIA+eaZzqXtVDzY9//+iP4URqvS/ldWpD4yvQ= X-Received: by 2002:a17:902:e750:b0:16f:3f32:6f5c with SMTP id p16-20020a170902e75000b0016f3f326f5cmr23908975plf.106.1660688366627; Tue, 16 Aug 2022 15:19:26 -0700 (PDT) MIME-Version: 1.0 References: <1704B09B-F758-47DF-BDDE-FEA9AB227E12@baidu.com> In-Reply-To: From: Shakeel Butt Date: Tue, 16 Aug 2022 15:19:15 -0700 Message-ID: Subject: Re: [PATCH] mm: correctly charge compressed memory to its memcg To: Yosry Ahmed Cc: Johannes Weiner , "Li,Liguang" , 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=1660688367; a=rsa-sha256; cv=none; b=wskWoAG9jgPPvCLRLc89dGYJYbJSR7vePNpRWiqlPeMQrINYo+/mpiKy66e7UdGt3+iXPJ 2UKZBjyKAzXQuvMKkaRo7ObhRwtVn2x5FxxH5WZ+GfbIUHUFjET0MMgMY/HpDg2nBrXl/E bHJzmsV+qBqS9U/Opb/u4jSET8Iad+c= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=CG5u7n19; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of shakeelb@google.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=shakeelb@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660688367; 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=/vkwmLHblp61YfsURm3yRKZjj5rnHEuckjDW4SKaq/U=; b=UuniSjhTrOM5mwn4B3ZKor67qMnoV7OSGIy8h8TW7g6wHLQDbJJ//v4Dpq8xk/qcsfGjnY BPZE559H1tGoZWC3GgiFA2f9C6/bb4uGTeWYiC4uNwYtxgHAlHIh1SvxnEJh7Q9NwP97kW mwnBevXNu6q3T9NW4BWVZIHwVqUOcCc= X-Stat-Signature: 63cfh4ej9owokjyto7uccfkw7w91crkn X-Rspamd-Queue-Id: C3B5418004B Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=CG5u7n19; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of shakeelb@google.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=shakeelb@google.com X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1660688367-865923 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:56 AM Yosry Ahmed wrote: > > 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. Yup not worth overthinking this. > > > > > 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. Yes, we should deprecate this knob. Last I remember there were users facing zombie issues due to kernel memory for kernels before objcg infrastructure and used this knob to resolve the zombie issue. So, I think this can be deprecated. Though it would be safe to first warn and deprecate in later release.