From patchwork Thu Jan 12 15:53:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13098268 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 A2171C54EBC for ; Thu, 12 Jan 2023 15:53:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3796A8E0006; Thu, 12 Jan 2023 10:53:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B4928E0001; Thu, 12 Jan 2023 10:53:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B84C8E0006; Thu, 12 Jan 2023 10:53:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E00018E0001 for ; Thu, 12 Jan 2023 10:53:39 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BD9A81A0276 for ; Thu, 12 Jan 2023 15:53:39 +0000 (UTC) X-FDA: 80346592158.09.443C2A0 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by imf03.hostedemail.com (Postfix) with ESMTP id 2FC8020015 for ; Thu, 12 Jan 2023 15:53:38 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ALz+sfZN; spf=pass (imf03.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.160.179 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673538818; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mVUzU5Lm9v4TwCr8MR19Sbma13E60mByaOAa7yrtf24=; b=688NJjWP16YvegOf5HrtGlhbrfBhydtuyo/xBnZMRdXiG8AUfxAoo2GHY6pv2ppRLEzAI3 ehoJsB3IcUrSWjKMxC+Bl2idtst1Y/H2dw2O779jAmH1CCE+tJalONqz11O+fY93rjvpg4 ZwLhlQzQ/6UTeMVP93POaiY3VVQh6mg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ALz+sfZN; spf=pass (imf03.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.160.179 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673538818; a=rsa-sha256; cv=none; b=p1ggCaxMZV3DAPPdbHYea2qWX/JVmghqv7Hlf7ujm3rVLR9D/BIG0L8pM9OGxWhXR0YpXr EpSFkZCdfPbOS9Q05hXw8CX606I6MyBcyuub7zw5LkDjJTAPVONrPmMsP0Ujh4hJKdz/OP ZZ556omZbNPhpy7VKIeWiKdNkYboJZU= Received: by mail-qt1-f179.google.com with SMTP id h21so16647020qta.12 for ; Thu, 12 Jan 2023 07:53:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mVUzU5Lm9v4TwCr8MR19Sbma13E60mByaOAa7yrtf24=; b=ALz+sfZNfS4qifRdKVjJ8liTZOnDRU+va/zE0oxhTHHmiy4uVJp/MTYMO3s8HKBBX7 kfY7l06ClrnXzuJ7SwOeoV5XP8m4rE/PpAwk2M/ze8SKWK3++rl0/fpfL9a1+7NncPo/ SsTYC3AIuXIEEPnYcGdNOIgGgXh6MnLjg7cFUrFJw3+s5Pzcdcwez0u3SEm8SWfVa8SI lV3T8Y6TP2pAb72E04aXg+cxHgxvtBaUv2MNbXhHDcG968NZCThz/0JKKSqupM5LkS5s bzBoNfaoCpdlDpOHwABYaSzg706CqymnvMJ07sqq4vcd/D+PIpKMKMaWwx7WypE2pfis NrUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mVUzU5Lm9v4TwCr8MR19Sbma13E60mByaOAa7yrtf24=; b=JO966VsE0mkgsL9EdehFnqDcCVTgBJTtNrcIhd+G1rBz43q0uHwA6+w8ccuoObPdv+ eV4L6RYbyfr27yFoe6Hf5L3sXqDRcrWRK+DqkJtWrvN54pOeigtGb7Ryyr3ufElle2Z9 R+b/KXturnD1Xcfri1biCxaXM+b9XrC3jJikOD5BUdiaepfT2AtM0efc0ahAwCrreHc6 n1B9PZmS86+lHPjjIWSrkAWpgSQiJBz5pKc9l3Xw846mXzajcqxFDVvuI3w0wecSGoDh wMuB1ijmD9fjwjZePFLEE0rZ11NN72vYfpoGJ0Micu041oxM9GFjSYWwzVQa9KcWJhlH y8eQ== X-Gm-Message-State: AFqh2kpituNoLvsMtForchyRQCcuDDkX4VyqAHfBU+Mz0Y1Q0qF//X8W 3Oc5qaUXDcFXhj8xQNEGij0= X-Google-Smtp-Source: AMrXdXsF0qX10TMukl4qhalYqOJc8cvWNp4i4Otvd5G6MW0t1u1Ue6UiuE5Z2o4FUsT/NSZGV/wCPQ== X-Received: by 2002:ac8:6c7:0:b0:3a7:f424:d1bb with SMTP id j7-20020ac806c7000000b003a7f424d1bbmr14664614qth.21.1673538817402; Thu, 12 Jan 2023 07:53:37 -0800 (PST) Received: from vultr.guest ([173.199.122.241]) by smtp.gmail.com with ESMTPSA id l17-20020ac848d1000000b003ab43dabfb1sm9280836qtr.55.2023.01.12.07.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 07:53:36 -0800 (PST) From: Yafang Shao To: 42.hyeyoo@gmail.com, vbabka@suse.cz, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, tj@kernel.org, dennis@kernel.org, cl@linux.com, akpm@linux-foundation.org, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, roman.gushchin@linux.dev Cc: linux-mm@kvack.org, bpf@vger.kernel.org, Yafang Shao Subject: [RFC PATCH bpf-next v2 03/11] mm: slab: rename obj_full_size() Date: Thu, 12 Jan 2023 15:53:18 +0000 Message-Id: <20230112155326.26902-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230112155326.26902-1-laoar.shao@gmail.com> References: <20230112155326.26902-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Stat-Signature: 7qzsmmrex5m5r4ej9ai87mzeuxi41sf9 X-Rspam-User: X-Rspamd-Queue-Id: 2FC8020015 X-Rspamd-Server: rspam06 X-HE-Tag: 1673538818-663883 X-HE-Meta: U2FsdGVkX1+RyHTLlQ5/cBakdIe7Mu0WQk697Wl8ha1v8A7aKtCbo3Qdw2ykdbLHzKjWEsBL2zllON8SIghhcxEB1EZiL+n4n0k2CZ53ILLlG6ArjNRlQSTPyhMVrlPIVDapaqJV6hdmCURKFxlaH4bN4XsW8zzMkY1n+xmNXoSV3eNkP5LKotWeto6kp9ggoL5ovN937O4YIgQA8uguSThabtHzTGXGFWLepkViwSKcZLrSFKpCcSlupgKUGAbdlvU5i11MznF2MksHX8Fag+QQRiJyz+pX1iCy+ZxJC/iw6fH5DpA3rzKKWIIV4krpJ7EQyPL4A47yhgLZ6+TuuSR4ZGmIODldOwjGU9dOJLGOtSu7BQMBIpn72UN/Rmi2B6zcQKb2t4YDIBK14TmeDPEEhynko+jTkHL2Jalo9D2PNsUBW3G7hstL+MQ0ZbeQBfllByDhhpEkOOWIuFYeM0JR1gy2zs697n59niTuBrv5B1UFcttCA+iv948Qw3TtlZmVa3WDU1e2Hb1Dy+J4D+5MnxlDMtIKStQ5AAHZyPYK2JRMGo40pFj9CvTrwCz6HsOC9v7QnxPGFm4alx5NJ2SqiGMhVbauICvKHFaWl6Rm7GrZ8WEUEL8VsddXGZdgChP/zusp6Sed2QilTnFQjC5NTzuheDRml6GA6rt+wZkD1BKnRURLXD3S5ME/haYfHQSADXIkqkyGR8huIxPkgkY5GW+BXjj95ZTVg3tH6xGZjI30Jk2YjFFnlCNTbXsV3bBx56bz/kqU9xcyf2PIdoUL0JuctJaAcYz8h2YunD5LG+S5XqNshNk5NhCCRq9l6P8OZygIprN+tQnUm6KXDgBv7Jar35RF7egPr+zHPq2uX8bwnGBrvmJD+AY63g3ei7OyZgRKs0ogeXZxbwYs5NiRsevHFnp4k+KxlkQFvOPefR2d3ytncgjMv6HHhrOtZJfbVUQ33dFquiEcsfB iTMRUuMd 5PzrbtYy9HJaDDp5hdsPiKfQhyiySmWy3A3oktH3100SoiXGSgCJLmqEu63h+NITf2nahHricDNF0+diNf4QrhZBp4R01VviXOPPgAbpkeMoxLER5sYh1c8U5sdHIiFGo8BKcVgCAmlnx5kaLC+m5tnE3qmKG9xVJcYkklCkEgbSs8LeI8ojyhXD0KVBEhc1ZWj5MoFamltVM03R0HMVo9BSrQVHA7gYh6yOz61Cf2dz5qEc3/hmt4rRj+thFUAxHEI9gFMjnlDRziw2KfLosBq4o0q9fl4mi92NP 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: The helper obj_full_size() is a little misleading, because it is only valid when kmemcg is enabled. Meanwhile it is only used when kmemcg is enabled currently, so we just need to rename it to a more meaningful name. Signed-off-by: Yafang Shao Cc: Roman Gushchin --- mm/slab.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index 7cc4329..35e0b3b 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -467,7 +467,10 @@ static inline void memcg_free_slab_cgroups(struct slab *slab) slab->memcg_data = 0; } -static inline size_t obj_full_size(struct kmem_cache *s) +/* + * This helper is only valid when kmemcg isn't disabled. + */ +static inline size_t obj_kmemcg_size(struct kmem_cache *s) { /* * For each accounted object there is an extra space which is used @@ -508,7 +511,7 @@ static inline bool memcg_slab_pre_alloc_hook(struct kmem_cache *s, goto out; } - if (obj_cgroup_charge(objcg, flags, objects * obj_full_size(s))) + if (obj_cgroup_charge(objcg, flags, objects * obj_kmemcg_size(s))) goto out; *objcgp = objcg; @@ -537,7 +540,7 @@ static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s, if (!slab_objcgs(slab) && memcg_alloc_slab_cgroups(slab, s, flags, false)) { - obj_cgroup_uncharge(objcg, obj_full_size(s)); + obj_cgroup_uncharge(objcg, obj_kmemcg_size(s)); continue; } @@ -545,9 +548,9 @@ static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s, obj_cgroup_get(objcg); slab_objcgs(slab)[off] = objcg; mod_objcg_state(objcg, slab_pgdat(slab), - cache_vmstat_idx(s), obj_full_size(s)); + cache_vmstat_idx(s), obj_kmemcg_size(s)); } else { - obj_cgroup_uncharge(objcg, obj_full_size(s)); + obj_cgroup_uncharge(objcg, obj_kmemcg_size(s)); } } obj_cgroup_put(objcg); @@ -576,9 +579,9 @@ static inline void memcg_slab_free_hook(struct kmem_cache *s, struct slab *slab, continue; objcgs[off] = NULL; - obj_cgroup_uncharge(objcg, obj_full_size(s)); + obj_cgroup_uncharge(objcg, obj_kmemcg_size(s)); mod_objcg_state(objcg, slab_pgdat(slab), cache_vmstat_idx(s), - -obj_full_size(s)); + -obj_kmemcg_size(s)); obj_cgroup_put(objcg); } }