Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5995334rwb; Mon, 14 Nov 2022 12:36:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf5+UimAaUhWgQjOZPL766CHkrVZG7Yd9feUe8ZjCyG7/8gX85mOHBfOLma3IP4zYYq5MjWK X-Received: by 2002:a17:902:e782:b0:17f:7ed1:7da5 with SMTP id cp2-20020a170902e78200b0017f7ed17da5mr885283plb.101.1668458190590; Mon, 14 Nov 2022 12:36:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668458190; cv=none; d=google.com; s=arc-20160816; b=Aeap/ezWLyN5XBfQxn+truyWC2MT9DJn8S1Mriodb2DKT7sNK8uF6tb60EpiwcZDJH IGb7pP0/Y3uH1YeVQib42HL0gWOWL3sq/8Ay8ZinW3hj5j6RkFVJ8uEGyMoNTL4Tq6NA nRavAkX/vbCCN7y6LX+96LKgdAeHOxa6s8hSvbd9+nHIXBKJ6XIAD0O8m6mwShD0Y/AY NvZ8gWyIz/KRrFkqM3mosbHMme55X0makTuTw1XTZVk+Nkw3QeSFIzPJpxG23SXulnBS KpWNV3iquIAsb2i5YK/fjNU50oxa3y4pqD1GY/FGk1g+IIhyfbiP52/N+r4eAS+4QQAk srnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=omJyx+p3MZnXmMetOfD+Vb81mPQBWZRFtKehGT/esV0=; b=ALRnj/FFPGFyhUewz6BoJTIBL6K+t7f0+q6Qjy1bpdfOwqFJb3zRqODdNDGSfAt+1r qSIbJxLbPqGt2N2v2rtMC/3a0WxS9e2Kd4rjBtnqzV39awXvgV787TIFxXZEupXeiL08 hhws8ujZ+gqRNrvhNKJrIkwcsFYmOwrWOIWUpXBdVNeBk+T7XWuOmiBB0s+QCSvarthF SIKLmiAx9Pqu9g9USctzkMtn1P6p6DPDxqA9h8lFpYRxLJrlVUYesvZ9tRaf9EmSbkXO iwxZ1z3ZAAzbNxjdFPBkCzETi/Zj9izoV0O8wEjt4hSE61ZzPuKUeAsUgmRpkxQ6oy36 X91g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=oPRUVWpt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 189-20020a6306c6000000b0044fb332e9c2si10325250pgg.560.2022.11.14.12.36.18; Mon, 14 Nov 2022 12:36:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=oPRUVWpt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230520AbiKNTtM (ORCPT + 89 others); Mon, 14 Nov 2022 14:49:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237447AbiKNTss (ORCPT ); Mon, 14 Nov 2022 14:48:48 -0500 Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF1BB2A705 for ; Mon, 14 Nov 2022 11:48:14 -0800 (PST) Received: by mail-qv1-xf2f.google.com with SMTP id j6so8409345qvn.12 for ; Mon, 14 Nov 2022 11:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=omJyx+p3MZnXmMetOfD+Vb81mPQBWZRFtKehGT/esV0=; b=oPRUVWptCQQmFoRVOuC0Bg4LNaPVc12ejrt634brCi0WT/hC+s0sQDVTF10pFjtxTY 2yzL0yNRUHUd1oX17N/BxcyF/qmvW3QhZXrPtNzOoYFRIF5RqMINMd8PvVISkRHPY2nu 68op9yrb34dqOW+3Y/FmdRZGxNalulMhlZOhIWvbmehB0CgB/lnmP/jC1uO6+q+bozBP R2kGUT3x9G/BALjKomL4YolNC6TRbHvc0sb4+upz0vx0CduE+3gfG/V/K3kVbe2xce5l UexYq0kHvri6fpktU2NgA+FKrK4tHRhL88cyTTD/yRn0z7X5yBdQ4jbRxt0ut+v9nLt0 MaLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=omJyx+p3MZnXmMetOfD+Vb81mPQBWZRFtKehGT/esV0=; b=TzqD55s+8jiD9lot+SVPgF2VV0iNjRw6PcdqMFUtksvKJIFMJvBcj30cKCQKAR5ISq 2JHV+EQfXmlltRdjf0e5kVHAWUv3tVugJ7m2wS3WPhwoDk1Cr2IL14CdrbAQLzn5JcIQ ZG7JmdnA3EHGV7aUDH2ZxYLusfE7QgSo3Qowm1rBkQxwak1b0UJmdH8xAXcteReoQwYm f/fqTkk85c8WxjeT9Ab18peXQOA/mNiFLfK+w48uD4pBLR8kanG6c3IfD+97rTLVSnCn GoIxKNGHWWzs+ps5Ke4ANn8hvu+WdLbzKUjl25dzP0+OoBY6YzZRwaSQQgCKjaCgqrYv zNgw== X-Gm-Message-State: ANoB5pmQ8xffTIVdIbqYduP6TqIhrfnYqxKC9bE5saxyvArkQ0ZK0/bP 7v+oCAZCiAs6N64FF785qnXVYw== X-Received: by 2002:a05:6214:2b9c:b0:4bb:684e:c94f with SMTP id kr28-20020a0562142b9c00b004bb684ec94fmr13996725qvb.52.1668455287880; Mon, 14 Nov 2022 11:48:07 -0800 (PST) Received: from localhost ([2620:10d:c091:480::1:e032]) by smtp.gmail.com with ESMTPSA id s36-20020a05622a1aa400b0039cc944ebdasm6121471qtc.54.2022.11.14.11.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 11:48:07 -0800 (PST) From: Johannes Weiner To: Andrew Morton Cc: linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Li Liguang , stable@vger.kernel.org, Shakeel Butt , Muchun Song Subject: [PATCH] mm: correctly charge compressed memory to its memcg Date: Mon, 14 Nov 2022 14:48:28 -0500 Message-Id: <20221114194828.100822-1-hannes@cmpxchg.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Li Liguang Kswapd will reclaim memory when memory pressure is high, the annonymous memory will be compressed and stored in the zpool if zswap is enabled. The memcg_kmem_bypass() in get_obj_cgroup_from_page() will bypass the kernel thread and cause the compressed memory not charged to its memory cgroup. Remove the memcg_kmem_bypass() and properly charge compressed memory to its corresponding memory cgroup. Link: https://lore.kernel.org/linux-mm/CALvZod4nnn8BHYqAM4xtcR0Ddo2-Wr8uKm9h_CHWUaXw7g_DCg@mail.gmail.com/ Fixes: f4840ccfca25 ("zswap: memcg accounting") Cc: stable@vger.kernel.org # 5.19+ Acked-by: Shakeel Butt Acked-by: Shakeel Butt Reviewed-by: Muchun Song Signed-off-by: Li Liguang Signed-off-by: Johannes Weiner --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) This fell through the cracks in summer as it didn't make it to the right mailing lists. Resending. I know it's close to 6.1-final, but the fix should be safe to put in. It's straight-forward and obvious code-wise. We also have large parts of production running on it without problems. diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2d8549ae1b30..a1a35c12635e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3026,7 +3026,7 @@ struct obj_cgroup *get_obj_cgroup_from_page(struct page *page) { struct obj_cgroup *objcg; - if (!memcg_kmem_enabled() || memcg_kmem_bypass()) + if (!memcg_kmem_enabled()) return NULL; if (PageMemcgKmem(page)) { -- 2.38.1