linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/slub: sysfs cleanup on cpu partial when !SLUB_CPU_PARTIAL
@ 2020-08-13  8:48 wuyun.wu
  2020-08-19  3:26 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: wuyun.wu @ 2020-08-13  8:48 UTC (permalink / raw)
  To: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton
  Cc: hewenliang4, hushiyuan, Abel Wu, open list:SLAB ALLOCATOR, open list

From: Abel Wu <wuyun.wu@huawei.com>

Hide cpu partial related sysfs entries when !CONFIG_SLUB_CPU_PARTIAL to
avoid confusion.

Signed-off-by: Abel Wu <wuyun.wu@huawei.com>
---
 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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/slub: sysfs cleanup on cpu partial when !SLUB_CPU_PARTIAL
  2020-08-13  8:48 [PATCH] mm/slub: sysfs cleanup on cpu partial when !SLUB_CPU_PARTIAL wuyun.wu
@ 2020-08-19  3:26 ` Andrew Morton
  2020-08-19  8:41   ` Abel Wu
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2020-08-19  3:26 UTC (permalink / raw)
  To: wuyun.wu
  Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	hewenliang4, hushiyuan, open list:SLAB ALLOCATOR, open list

On Thu, 13 Aug 2020 16:48:54 +0800 <wuyun.wu@huawei.com> wrote:

> Hide cpu partial related sysfs entries when !CONFIG_SLUB_CPU_PARTIAL to
> avoid confusion.
> 

But it changes the userspace interface in ways which might cause
existing code to misbehave?

We just had to revert a different commit for this reason :(

http://lkml.kernel.org/r/20200811075412.12872-1-bhe@redhat.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/slub: sysfs cleanup on cpu partial when !SLUB_CPU_PARTIAL
  2020-08-19  3:26 ` Andrew Morton
@ 2020-08-19  8:41   ` Abel Wu
  0 siblings, 0 replies; 3+ messages in thread
From: Abel Wu @ 2020-08-19  8:41 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	hewenliang4, hushiyuan, open list:SLAB ALLOCATOR, open list



On 2020/8/19 11:26, Andrew Morton wrote:
> On Thu, 13 Aug 2020 16:48:54 +0800 <wuyun.wu@huawei.com> wrote:
> 
>> Hide cpu partial related sysfs entries when !CONFIG_SLUB_CPU_PARTIAL to
>> avoid confusion.
>>
> 
> But it changes the userspace interface in ways which might cause
> existing code to misbehave?
Yes, indeed.
> 
> We just had to revert a different commit for this reason :(
> 
> http://lkml.kernel.org/r/20200811075412.12872-1-bhe@redhat.com
> .
> 
OK, just ignore this patch and leave it as is!

Thanks,
	Abel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-19  8:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13  8:48 [PATCH] mm/slub: sysfs cleanup on cpu partial when !SLUB_CPU_PARTIAL wuyun.wu
2020-08-19  3:26 ` Andrew Morton
2020-08-19  8:41   ` Abel Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).