slub: avoid false-postive warning
Subsystems (2)
PATCH 1/1 slub: avoid false-postive warning
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 a??kmem_cache_free_bulka??:mm/slub.c:262:23: error: a??df.sa?? may be used uninitialized in this function [-Werror=maybe-uninitialized] mm/slub.c:2943:3: error: a??df.cnta?? may be used uninitialized in this function [-Werror=maybe-uninitialized] mm/slub.c:2933:4470: error: a??df.freelista?? may be used uninitialized in this function [-Werror=maybe-uninitialized] mm/slub.c:2943:3: error: a??df.taila?? 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.
--- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/slub.c +1 -1
@@ -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_);
Signature · 7 lines
2.9.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 14 lines · On Mon, 24 Oct 2016 17:56:13 +0200 Arnd Bergmann <[email protected]> wrote:
The slub allocator gives us some incorrect warnings when
CONFIG_PROFILE_ANNOTATED_BRANCHESis set, as theunlikely()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:
Quoted 7 lines
- add a bogus initialization, which would increase the runtime overhead
- replaceunlikely()withunlikely_notrace()
- remove theunlikely()annotation completelyI 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
Quoted 18 lines
Signed-off-by Arnd Bergmann <[email protected]>--- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/slub.c +1
-1@@ -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_);
Signature · 11 lines
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 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>