Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1507337 > unrolled thread

[PATCH] slub: avoid false-postive warning

Started byArnd Bergmann <arnd@arndb.de>
First post2016-10-24 18:00 +0200
Last post2016-10-25 13:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] slub: avoid false-postive warning Arnd Bergmann <arnd@arndb.de> - 2016-10-24 18:00 +0200
    Re: [PATCH] slub: avoid false-postive warning Jesper Dangaard Brouer <brouer@redhat.com> - 2016-10-25 13:40 +0200

#1507337 — [PATCH] slub: avoid false-postive warning

FromArnd Bergmann <arnd@arndb.de>
Date2016-10-24 18:00 +0200
Subject[PATCH] slub: avoid false-postive warning
Message-ID<svPPj-1bs-1@gated-at.bofh.it>
The slub allocator gives us some incorrect warnings when
CONFIG_PROFILE_ANNOTATED_BRANCHES is set, as the unlikely()
macro prevents it from seeing that the return code matches
what it was before:

mm/slub.c: In function ‘kmem_cache_free_bulk’:
mm/slub.c:262:23: error: ‘df.s’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
mm/slub.c:2943:3: error: ‘df.cnt’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
mm/slub.c:2933:4470: error: ‘df.freelist’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
mm/slub.c:2943:3: error: ‘df.tail’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

I have not been able to come up with a perfect way for dealing with
this, the three options I see are:

- add a bogus initialization, which would increase the runtime overhead
- replace unlikely() with unlikely_notrace()
- remove the unlikely() annotation completely

I checked the object code for a typical x86 configuration and the
last two cases produce the same result, so I went for the last
one, which is the simplest.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 mm/slub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/slub.c b/mm/slub.c
index 2b3e740609e9..68b84f93d38d 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3076,7 +3076,7 @@ void kmem_cache_free_bulk(struct kmem_cache *s, size_t size, void **p)
 		struct detached_freelist df;
 
 		size = build_detached_freelist(s, size, p, &df);
-		if (unlikely(!df.page))
+		if (!df.page)
 			continue;
 
 		slab_free(df.s, df.page, df.freelist, df.tail, df.cnt,_RET_IP_);
-- 
2.9.0

[toc] | [next] | [standalone]


#1508221

FromJesper Dangaard Brouer <brouer@redhat.com>
Date2016-10-25 13:40 +0200
Message-ID<sw8ff-4ZX-1@gated-at.bofh.it>
In reply to#1507337
On Mon, 24 Oct 2016 17:56:13 +0200 Arnd Bergmann <arnd@arndb.de> wrote:

> The slub allocator gives us some incorrect warnings when
> CONFIG_PROFILE_ANNOTATED_BRANCHES is set, as the unlikely()
> macro prevents it from seeing that the return code matches
> what it was before:
> 
> mm/slub.c: In function ‘kmem_cache_free_bulk’:
> mm/slub.c:262:23: error: ‘df.s’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> mm/slub.c:2943:3: error: ‘df.cnt’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> mm/slub.c:2933:4470: error: ‘df.freelist’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> mm/slub.c:2943:3: error: ‘df.tail’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> I have not been able to come up with a perfect way for dealing with
> this, the three options I see are:
> 
> - add a bogus initialization, which would increase the runtime overhead
> - replace unlikely() with unlikely_notrace()
> - remove the unlikely() annotation completely
> 
> I checked the object code for a typical x86 configuration and the
> last two cases produce the same result, so I went for the last
> one, which is the simplest.

If the object code is the same, then I've fine with this solution, as
the performance should then also be the same.

I do have micro-benchmark module there to verify the performance:
 https://github.com/netoptimizer/prototype-kernel/blob/master/kernel/mm/slab_bulk_test01.c

Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>


> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  mm/slub.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 2b3e740609e9..68b84f93d38d 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -3076,7 +3076,7 @@ void kmem_cache_free_bulk(struct kmem_cache *s, size_t size, void **p)
>  		struct detached_freelist df;
>  
>  		size = build_detached_freelist(s, size, p, &df);
> -		if (unlikely(!df.page))
> +		if (!df.page)
>  			continue;
>  
>  		slab_free(df.s, df.page, df.freelist, df.tail, df.cnt,_RET_IP_);



-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  Author of http://www.iptv-analyzer.org
  LinkedIn: http://www.linkedin.com/in/brouer

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web