From patchwork Thu Jul 18 09:18:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 13736274 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 3E6CCC3DA49 for ; Thu, 18 Jul 2024 09:19:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C6A1B6B0083; Thu, 18 Jul 2024 05:19:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C17C06B0088; Thu, 18 Jul 2024 05:19:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A92716B0089; Thu, 18 Jul 2024 05:19:40 -0400 (EDT) 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 872226B0083 for ; Thu, 18 Jul 2024 05:19:40 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 37A5F1A1A3D for ; Thu, 18 Jul 2024 09:19:40 +0000 (UTC) X-FDA: 82352325720.02.A5EDEF9 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf28.hostedemail.com (Postfix) with ESMTP id B73E1C0018 for ; Thu, 18 Jul 2024 09:19:37 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Sod8DDx6; spf=pass (imf28.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=songmuchun@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=1721294337; 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:references:dkim-signature; bh=nU8sLB6vIuteXJgQPw++2LFGLgdg5qqMxhtbiU9nCuo=; b=HC/GVvaIiMfmDc7DP50PqLQ0LxbwWXD2LJmNoaK+yJ8ZOZePctcNMl3dWWf/lwCmrRCuTb KDck356SepQd0HGx+wd/p8hnadgjq/vHsl2bEH8H7VpAgWsHua5QWay4bX1vfcDIbveoM/ 05jf8kFefnwq/m+yE42O/DRmvSi8fiw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721294337; a=rsa-sha256; cv=none; b=r29C3IH49kbrCbNKK6EzsfeCT4HeKRa8MGAmRai3Bha+kv21tZqSbAG4Qcm8TxjJwSk/cZ 72/zRCx3FiPldE+0Wzytujd9JDcf1iI28i+OxIvB7Nm8SlqnnGpdafdgEM8SxHBCbuUq4J DAlSLVFQdgPKLaT3kArtpvAvJEIqXwk= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Sod8DDx6; spf=pass (imf28.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-70af81e8439so434609b3a.0 for ; Thu, 18 Jul 2024 02:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1721294376; x=1721899176; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nU8sLB6vIuteXJgQPw++2LFGLgdg5qqMxhtbiU9nCuo=; b=Sod8DDx6G/BCJCI+RycKh1usQkW7zyuFSc2ckrShj2bPGQySZZCYB5+KC4FC7KdhqR XHgWL+cVFwcMT1BEUgzTOzhhloCqamhuUzkvg7vrmSZkjcRejVuRn53sGXul5moJDTUf mirZ+4QoN4ewozC/NtCmooDEunQr+fnZSH2pKQaLrEhMtxha1pOypDFrbtKr70dCw5d+ NGM5UMixWdSWsgtLSixAGYa3d3aRENp7IaxSsR1tPu+YSd5WMxZHtg1zpbameti3zYxm H8EDtPo8xQIkUyUqpYSlKOtuA2Re7JfvGzGSXpE/PeVCcyJ/tiK15ciUwu03WHtiJoR8 Zd/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721294376; x=1721899176; 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=nU8sLB6vIuteXJgQPw++2LFGLgdg5qqMxhtbiU9nCuo=; b=EXoMwlCMxhh86dashulEmRsnbXEZ0RLSgEFeHIMo2IyLmDV/c4HSsNg4GGrR0mdGLG KG69/oA5bRTMTXeM9s8rwMQBxyu9XqINnUy1YUwEAfXzlWAdvTIofBJRpiyx/1L+wDyR aeuZuZ5a73LADgf30WaLCxwgfA8OJJgo+vXv7ZHH4+3MZ+7P8BhDTxM7gbDWMoceIxBx 9D5UhEz2LdLtqJAcr1PQ1y7DRA74Pa6DJSe79CFlgtOy1LQDRpv9q5H33n4mRATCOHy6 zHAFHU/9xvl8dqla4Cqt5bFwKQVM0KWff+Lodeb/DhBHewbQR9MiL1c7r64BAOyQyEd7 aScg== X-Forwarded-Encrypted: i=1; AJvYcCVbkIahW4zpG8pell8CLL/Xg1VUeWlmlYrahbGhvvv6McmtfyjLWBXEusH0MT2tPAK7gBrHDrTBuicXOLMXtIglgBs= X-Gm-Message-State: AOJu0YwJIy9QBVWFngBJFZl7rZYArp7y/8dHtfYZYrcHupgSE8Sclxjj mVeu7V3anSddsvRlOsBRrHNUisKsTBVLlM4xWE9nzASSta8QwJi81cvyP9XG0+g= X-Google-Smtp-Source: AGHT+IGOaTVMJyS7kT7lM0bn1HJi6pUMyC1NCcBFyE3paLzEIwtWXl/YIIWAEle3euPKuYGHJElEaQ== X-Received: by 2002:a05:6a00:3d0a:b0:705:6a0a:de14 with SMTP id d2e1a72fcca58-70ce4f47fd3mr4979886b3a.1.1721294376045; Thu, 18 Jul 2024 02:19:36 -0700 (PDT) Received: from PXLDJ45XCM.bytedance.net ([61.213.176.12]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca8c01sm9830421b3a.172.2024.07.18.02.19.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 18 Jul 2024 02:19:35 -0700 (PDT) From: Muchun Song To: hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, akpm@linux-foundation.org Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song Subject: [PATCH] mm: kmem: remove mem_cgroup_from_obj() Date: Thu, 18 Jul 2024 17:18:21 +0800 Message-Id: <20240718091821.44740-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B73E1C0018 X-Stat-Signature: ee4xhjkinb4f61mapucmeoca6i1iwjhb X-HE-Tag: 1721294377-9299 X-HE-Meta: U2FsdGVkX1/LAQl7GjLH6oogDGlSTauo6mCuZZeFeALmVZme/GHUMQiDzddBa33zuo5qYI01SZVK45cspPhO0bXJfAXOF9ZFpVKJAUVq+oG4hdlqG6oaMNWS5XjsStGrHNTuzgCeM53yjX1lzjr7jqSKAAFrZdbBRvv42wiRJnGKmF9DXjedry0udGLPsOSj6jD7lB8AMTu6/uGTg3JUQZizwyhbuSyu+bLY8VVT0ZrIM0qobexNHnSy3MzA3R9yBdTvJNqf7O8pjcplKrR7svBW3D7nz4z7LuDgsyRylscakCyBJLeznMa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ity: 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: List-Subscribe: List-Unsubscribe: There is no user of mem_cgroup_from_obj(), remove it. Signed-off-by: Muchun Song Acked-by: Shakeel Butt Acked-by: Roman Gushchin --- include/linux/memcontrol.h | 6 ------ mm/memcontrol.c | 32 +------------------------------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 394fd0a887ae7..461313307ec23 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1862,7 +1862,6 @@ static inline int memcg_kmem_id(struct mem_cgroup *memcg) return memcg ? memcg->kmemcg_id : -1; } -struct mem_cgroup *mem_cgroup_from_obj(void *p); struct mem_cgroup *mem_cgroup_from_slab_obj(void *p); static inline void count_objcg_event(struct obj_cgroup *objcg, @@ -1925,11 +1924,6 @@ static inline int memcg_kmem_id(struct mem_cgroup *memcg) return -1; } -static inline struct mem_cgroup *mem_cgroup_from_obj(void *p) -{ - return NULL; -} - static inline struct mem_cgroup *mem_cgroup_from_slab_obj(void *p) { return NULL; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index fabce2b50c695..d04fb1ae870e9 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3076,37 +3076,7 @@ struct mem_cgroup *mem_cgroup_from_obj_folio(struct folio *folio, void *p) /* * Returns a pointer to the memory cgroup to which the kernel object is charged. - * - * A passed kernel object can be a slab object, vmalloc object or a generic - * kernel page, so different mechanisms for getting the memory cgroup pointer - * should be used. - * - * In certain cases (e.g. kernel stacks or large kmallocs with SLUB) the caller - * can not know for sure how the kernel object is implemented. - * mem_cgroup_from_obj() can be safely used in such cases. - * - * The caller must ensure the memcg lifetime, e.g. by taking rcu_read_lock(), - * cgroup_mutex, etc. - */ -struct mem_cgroup *mem_cgroup_from_obj(void *p) -{ - struct folio *folio; - - if (mem_cgroup_disabled()) - return NULL; - - if (unlikely(is_vmalloc_addr(p))) - folio = page_folio(vmalloc_to_page(p)); - else - folio = virt_to_folio(p); - - return mem_cgroup_from_obj_folio(folio, p); -} - -/* - * Returns a pointer to the memory cgroup to which the kernel object is charged. - * Similar to mem_cgroup_from_obj(), but faster and not suitable for objects, - * allocated using vmalloc(). + * It is not suitable for objects allocated using vmalloc(). * * A passed kernel object must be a slab object or a generic kernel page. *