Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1155313pxa; Thu, 13 Aug 2020 01:51:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPilbWG848OyikbmTxNdizwOrsIv6LvomLGCmitHN1zcNVkQ/GDeMAkxQklkacnnYX+CuH X-Received: by 2002:a50:f396:: with SMTP id g22mr3755493edm.220.1597308698572; Thu, 13 Aug 2020 01:51:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597308698; cv=none; d=google.com; s=arc-20160816; b=QubD2B5MhgHbcbnMbPW1wi9mwhKj81ONG4fENqnt2g6CaFqdgJ0fWOhwsjpjBLg51W ct5osrS2Ozmrm0D9D8/hJNGQwTI006CFQKuMpE1O5cgtwm0j8UYTrppWrMj5faDo6y7g Si2nbBsnF+7PifBJBobVWSkwRyAdiJbAHuCNFJugwbF32pXg6d8hnAvvU627U9ea07Bk 9bnTzwGqzgrRsL1IIixf71Fwa0Md+JUw/zVkKhCWgabvBEg05vwrZL75ePnE3KdRXx06 z5E2aCeg2PjSYrALp1CvFohlLIt501vJvDDCf7ypi0JJazkIhWwnwx1DNc+F4y1Q8XGp +trA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=L5WWSnDgCyhkOxuPKK96yLR0yxaBVf2jR/VI2aXf1tg=; b=ZqBzinckTa+EUoQtknwnUEBywUppOMwSENf5+yDw0rNaNJug0aURQbadxAiXUog7ZV zxa4erdAqRuHDPorpMPZ5/34ZIq307YrJX9qyJIE5iVlR27WaqNCcziz/QPb0IheQPWD xQWEtUMSiJZEDnDYbEnzTXF+/8YcGCN0tr/RkxQyowkQ8y4+WCeF16LMl6T24+ddLBqW O4w40CTHzIFAzEfql/qaYsw/CD03VJi/MCUZtB1KlJr5j2LFb1BiVLWKlVD4FxkpiHV8 I6npKLceW61HN7+zIUw+oIirNH+8z7F9/CDImWS06V9APZHnu1snCXWVXiSq2OvRajFy iDjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m27si2875186edj.262.2020.08.13.01.51.14; Thu, 13 Aug 2020 01:51:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726597AbgHMItv (ORCPT + 99 others); Thu, 13 Aug 2020 04:49:51 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9278 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726081AbgHMItv (ORCPT ); Thu, 13 Aug 2020 04:49:51 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2A4F769E3430D62507E1; Thu, 13 Aug 2020 16:49:47 +0800 (CST) Received: from DESKTOP-A9S207P.china.huawei.com (10.174.179.61) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Thu, 13 Aug 2020 16:49:40 +0800 From: To: Christoph Lameter , Pekka Enberg , "David Rientjes" , Joonsoo Kim , "Andrew Morton" CC: , , Abel Wu , "open list:SLAB ALLOCATOR" , "open list" Subject: [PATCH] mm/slub: sysfs cleanup on cpu partial when !SLUB_CPU_PARTIAL Date: Thu, 13 Aug 2020 16:48:54 +0800 Message-ID: <20200813084858.1494-1-wuyun.wu@huawei.com> X-Mailer: git-send-email 2.28.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.179.61] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Abel Wu Hide cpu partial related sysfs entries when !CONFIG_SLUB_CPU_PARTIAL to avoid confusion. Signed-off-by: Abel Wu --- mm/slub.c | 56 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 5d89e4064f83..4f496ae5a820 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5071,29 +5071,6 @@ static ssize_t min_partial_store(struct kmem_cache *s, const char *buf, } SLAB_ATTR(min_partial); -static ssize_t cpu_partial_show(struct kmem_cache *s, char *buf) -{ - return sprintf(buf, "%u\n", slub_cpu_partial(s)); -} - -static ssize_t cpu_partial_store(struct kmem_cache *s, const char *buf, - size_t length) -{ - unsigned int objects; - int err; - - err = kstrtouint(buf, 10, &objects); - if (err) - return err; - if (objects && !kmem_cache_has_cpu_partial(s)) - return -EINVAL; - - slub_set_cpu_partial(s, objects); - flush_all(s); - return length; -} -SLAB_ATTR(cpu_partial); - static ssize_t ctor_show(struct kmem_cache *s, char *buf) { if (!s->ctor) @@ -5132,6 +5109,30 @@ static ssize_t objects_partial_show(struct kmem_cache *s, char *buf) } SLAB_ATTR_RO(objects_partial); +#ifdef CONFIG_SLUB_CPU_PARTIAL +static ssize_t cpu_partial_show(struct kmem_cache *s, char *buf) +{ + return sprintf(buf, "%u\n", slub_cpu_partial(s)); +} + +static ssize_t cpu_partial_store(struct kmem_cache *s, const char *buf, + size_t length) +{ + unsigned int objects; + int err; + + err = kstrtouint(buf, 10, &objects); + if (err) + return err; + if (objects && !kmem_cache_has_cpu_partial(s)) + return -EINVAL; + + slub_set_cpu_partial(s, objects); + flush_all(s); + return length; +} +SLAB_ATTR(cpu_partial); + static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf) { int objects = 0; @@ -5166,6 +5167,7 @@ static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf) return len + sprintf(buf + len, "\n"); } SLAB_ATTR_RO(slabs_cpu_partial); +#endif static ssize_t reclaim_account_show(struct kmem_cache *s, char *buf) { @@ -5496,10 +5498,12 @@ STAT_ATTR(DEACTIVATE_BYPASS, deactivate_bypass); STAT_ATTR(ORDER_FALLBACK, order_fallback); STAT_ATTR(CMPXCHG_DOUBLE_CPU_FAIL, cmpxchg_double_cpu_fail); STAT_ATTR(CMPXCHG_DOUBLE_FAIL, cmpxchg_double_fail); +#ifdef CONFIG_SLUB_CPU_PARTIAL STAT_ATTR(CPU_PARTIAL_ALLOC, cpu_partial_alloc); STAT_ATTR(CPU_PARTIAL_FREE, cpu_partial_free); STAT_ATTR(CPU_PARTIAL_NODE, cpu_partial_node); STAT_ATTR(CPU_PARTIAL_DRAIN, cpu_partial_drain); +#endif #endif /* CONFIG_SLUB_STATS */ static struct attribute *slab_attrs[] = { @@ -5508,7 +5512,6 @@ static struct attribute *slab_attrs[] = { &objs_per_slab_attr.attr, &order_attr.attr, &min_partial_attr.attr, - &cpu_partial_attr.attr, &objects_attr.attr, &objects_partial_attr.attr, &partial_attr.attr, @@ -5520,7 +5523,10 @@ static struct attribute *slab_attrs[] = { &reclaim_account_attr.attr, &destroy_by_rcu_attr.attr, &shrink_attr.attr, +#ifdef CONFIG_SLUB_CPU_PARTIAL + &cpu_partial_attr.attr, &slabs_cpu_partial_attr.attr, +#endif #ifdef CONFIG_SLUB_DEBUG &total_objects_attr.attr, &slabs_attr.attr, @@ -5562,11 +5568,13 @@ static struct attribute *slab_attrs[] = { &order_fallback_attr.attr, &cmpxchg_double_fail_attr.attr, &cmpxchg_double_cpu_fail_attr.attr, +#ifdef CONFIG_SLUB_CPU_PARTIAL &cpu_partial_alloc_attr.attr, &cpu_partial_free_attr.attr, &cpu_partial_node_attr.attr, &cpu_partial_drain_attr.attr, #endif +#endif #ifdef CONFIG_FAILSLAB &failslab_attr.attr, #endif -- 2.28.0.windows.1