From patchwork Thu Sep 16 13:47:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12499119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B97A3C433F5 for ; Thu, 16 Sep 2021 13:52:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3A88D6103B for ; Thu, 16 Sep 2021 13:52:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3A88D6103B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id D65E36B0073; Thu, 16 Sep 2021 09:52:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D157C6B0074; Thu, 16 Sep 2021 09:52:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDC8D6B0075; Thu, 16 Sep 2021 09:52:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0034.hostedemail.com [216.40.44.34]) by kanga.kvack.org (Postfix) with ESMTP id AF9556B0073 for ; Thu, 16 Sep 2021 09:52:15 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6A4432DD67 for ; Thu, 16 Sep 2021 13:52:15 +0000 (UTC) X-FDA: 78593575830.15.96BA67A Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by imf26.hostedemail.com (Postfix) with ESMTP id 2FA5B20019D3 for ; Thu, 16 Sep 2021 13:52:15 +0000 (UTC) Received: by mail-pg1-f182.google.com with SMTP id n18so6181637pgm.12 for ; Thu, 16 Sep 2021 06:52:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=emzGgoQOnssPsBkzbuXL55Ev35q8xqQFOv8WuqwIjZE=; b=UUepn9rHGU0nXbviWK71cXLbiy3WYzBnnpHawMSiaeJZAk0nHTcl/tMUxPuf7W4E0c ZW7Cit53xZBc8ov3qoWPaCC5bRFmCBSL3OIOmd3J7eu4QAwoGVMLu42oOKo6TBRUgmzY Ve3GxknG7fDJ94IZdCDPeZ8GxuOAp+B8k6IsUUZPNwWOgZX6lsQIqMdA+qsHyAJl1w9q AK3pZ9xr+wKMiQ53oyLEGcof87i+LWxB7hqReWzY7ak/3tsZhAkC6hWHOIijfq5d2USK 8Ii8mDcqAw/pdQN9LsEkpFTSPLRtmrMb9q58fxgR5BIWfh6LI70/mdEnDlqLZriMF0vb TXOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=emzGgoQOnssPsBkzbuXL55Ev35q8xqQFOv8WuqwIjZE=; b=OwnYpIlCLHmQbGa9cRuxSuAugGFfBCGC5wPJff1Wr0qTPovSpmPtZA+Q6+3pfbT31B 27TgrViCHfi02vJjlDXeUK7E0BxBuGkVcHhrr5tEgK13LgUVKQzSsN1Ew8Xk0VF4pAVY 2oVvBGoq6OnFDonM6tLhzsQM0eVhPgiFa1g0IXBNFR7ctTn4bJlhvZl2cf5+uoXxz26V i7kjrzvEbR1KZ/dQQfcAAKCoCIs5dLVYWzbqnR0QCUqSls4tZ6PTuHqS0tm0Kb962zlE Wu97qJqY63dD0g5OGUn5cU8ISuRmxefmmilFWvRY4sK1Hqrcj01gd4TcjjssoCISDW/0 54fQ== X-Gm-Message-State: AOAM530qlNM9FI6p6yI/ZU/lr7lW6TuL12nKuv1n3MS/vvjAhdje4EkR NqcKr3IdKLn1TPuZtYsXmC4Mtw== X-Google-Smtp-Source: ABdhPJz+/bQHjro14FEEsTQjuOXbu6Tbg3dK0yLwJP7VQvx5HnZiCjNaoIlN/+bo9hEBsCrcPR5xIA== X-Received: by 2002:a62:ae13:0:b0:440:385c:2ee9 with SMTP id q19-20020a62ae13000000b00440385c2ee9mr5637538pff.39.1631800334233; Thu, 16 Sep 2021 06:52:14 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.226]) by smtp.gmail.com with ESMTPSA id o9sm3617443pfh.217.2021.09.16.06.52.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Sep 2021 06:52:13 -0700 (PDT) From: Muchun Song To: guro@fb.com, hannes@cmpxchg.org, mhocko@kernel.org, akpm@linux-foundation.org, shakeelb@google.com, vdavydov.dev@gmail.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, fam.zheng@bytedance.com, bsingharora@gmail.com, shy828301@gmail.com, alexs@kernel.org, smuchun@gmail.com, zhengqi.arch@bytedance.com, Muchun Song Subject: [PATCH v2 01/13] mm: move mem_cgroup_kmem_disabled() to memcontrol.h Date: Thu, 16 Sep 2021 21:47:36 +0800 Message-Id: <20210916134748.67712-2-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210916134748.67712-1-songmuchun@bytedance.com> References: <20210916134748.67712-1-songmuchun@bytedance.com> MIME-Version: 1.0 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=UUepn9rH; spf=pass (imf26.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.215.182 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Stat-Signature: 8expzipm6zu3uqqj69oc4dgg1mip49nq X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 2FA5B20019D3 X-HE-Tag: 1631800335-325176 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 cgroup_memory_nokmem is already a global variable, it is unnecessary to define a global function of mem_cgroup_kmem_disabled(). Just move it to memcontrol.h and mark inline on it. slab_common.c already includes memcontrol.h, replace cgroup_memory_nokmem with mem_cgroup_kmem_disabled(). Signed-off-by: Muchun Song --- include/linux/memcontrol.h | 8 +++++++- mm/internal.h | 5 ----- mm/memcontrol.c | 5 ----- mm/slab_common.c | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 3096c9a0ee01..e194d90aff56 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1639,7 +1639,13 @@ static inline void set_shrinker_bit(struct mem_cgroup *memcg, #endif #ifdef CONFIG_MEMCG_KMEM -bool mem_cgroup_kmem_disabled(void); +extern bool cgroup_memory_nokmem; + +static inline bool mem_cgroup_kmem_disabled(void) +{ + return cgroup_memory_nokmem; +} + int __memcg_kmem_charge_page(struct page *page, gfp_t gfp, int order); void __memcg_kmem_uncharge_page(struct page *page, int order); diff --git a/mm/internal.h b/mm/internal.h index cf3cb933eba3..649684e20fe4 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -116,11 +116,6 @@ extern void putback_lru_page(struct page *page); extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address); /* - * in mm/memcontrol.c: - */ -extern bool cgroup_memory_nokmem; - -/* * in mm/page_alloc.c */ diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b762215d73eb..528b134ca50c 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -264,11 +264,6 @@ struct mem_cgroup *vmpressure_to_memcg(struct vmpressure *vmpr) #ifdef CONFIG_MEMCG_KMEM extern spinlock_t css_set_lock; -bool mem_cgroup_kmem_disabled(void) -{ - return cgroup_memory_nokmem; -} - static void obj_cgroup_uncharge_pages(struct obj_cgroup *objcg, unsigned int nr_pages); diff --git a/mm/slab_common.c b/mm/slab_common.c index ec2bb0beed75..4c0549e0f349 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -857,7 +857,7 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags) if (type == KMALLOC_RECLAIM) { flags |= SLAB_RECLAIM_ACCOUNT; } else if (IS_ENABLED(CONFIG_MEMCG_KMEM) && (type == KMALLOC_CGROUP)) { - if (cgroup_memory_nokmem) { + if (mem_cgroup_kmem_disabled()) { kmalloc_caches[type][idx] = kmalloc_caches[KMALLOC_NORMAL][idx]; return; }