linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: skd: fix incorrect linux/slab_def.h inclusion
@ 2018-02-02 15:03 Arnd Bergmann
  2018-02-02 15:08 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2018-02-02 15:03 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Nicolas Pitre, Andi Kleen, Arnd Bergmann, Jens Axboe,
	linux-block, linux-kernel

skd includes slab_def.h to get access to the slab cache object size.
However, including this header breaks when we use SLUB or SLOB instead of
the SLAB allocator, since the structure layout is completely different,
as shown by this warning when we build this driver in one of the invalid
configurations with link-time optimizations enabled:

include/linux/slab.h:715:0: error: type of 'kmem_cache_size' does not match original declaration [-Werror=lto-type-mismatch]
 unsigned int kmem_cache_size(struct kmem_cache *s);

mm/slab_common.c:77:14: note: 'kmem_cache_size' was previously declared here
 unsigned int kmem_cache_size(struct kmem_cache *s)
              ^
mm/slab_common.c:77:14: note: code may be misoptimized unless -fno-strict-aliasing is used
include/linux/slab.h:147:0: error: type of 'kmem_cache_destroy' does not match original declaration [-Werror=lto-type-mismatch]
 void kmem_cache_destroy(struct kmem_cache *);

mm/slab_common.c:858:6: note: 'kmem_cache_destroy' was previously declared here
 void kmem_cache_destroy(struct kmem_cache *s)
      ^
mm/slab_common.c:858:6: note: code may be misoptimized unless -fno-strict-aliasing is used
include/linux/slab.h:140:0: error: type of 'kmem_cache_create' does not match original declaration [-Werror=lto-type-mismatch]
 struct kmem_cache *kmem_cache_create(const char *name, size_t size,

mm/slab_common.c:534:1: note: 'kmem_cache_create' was previously declared here
 kmem_cache_create(const char *name, size_t size, size_t align,
 ^

This removes the header inclusion and instead uses the kmem_cache_size()
interface to get the size in a reliable way.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/block/skd_main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index de0d08133c7e..e41935ab41ef 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -32,7 +32,6 @@
 #include <linux/aer.h>
 #include <linux/wait.h>
 #include <linux/stringify.h>
-#include <linux/slab_def.h>
 #include <scsi/scsi.h>
 #include <scsi/sg.h>
 #include <linux/io.h>
@@ -2603,7 +2602,8 @@ static void *skd_alloc_dma(struct skd_device *skdev, struct kmem_cache *s,
 	buf = kmem_cache_alloc(s, gfp);
 	if (!buf)
 		return NULL;
-	*dma_handle = dma_map_single(dev, buf, s->size, dir);
+	*dma_handle = dma_map_single(dev, buf,
+				     kmem_cache_size(s), dir);
 	if (dma_mapping_error(dev, *dma_handle)) {
 		kmem_cache_free(s, buf);
 		buf = NULL;
@@ -2618,7 +2618,8 @@ static void skd_free_dma(struct skd_device *skdev, struct kmem_cache *s,
 	if (!vaddr)
 		return;
 
-	dma_unmap_single(&skdev->pdev->dev, dma_handle, s->size, dir);
+	dma_unmap_single(&skdev->pdev->dev, dma_handle,
+			 kmem_cache_size(s), dir);
 	kmem_cache_free(s, vaddr);
 }
 
-- 
2.9.0

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

* Re: [PATCH] block: skd: fix incorrect linux/slab_def.h inclusion
  2018-02-02 15:03 [PATCH] block: skd: fix incorrect linux/slab_def.h inclusion Arnd Bergmann
@ 2018-02-02 15:08 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2018-02-02 15:08 UTC (permalink / raw)
  To: Arnd Bergmann, Bart Van Assche
  Cc: Nicolas Pitre, Andi Kleen, linux-block, linux-kernel

On 2/2/18 8:03 AM, Arnd Bergmann wrote:
> skd includes slab_def.h to get access to the slab cache object size.
> However, including this header breaks when we use SLUB or SLOB instead of
> the SLAB allocator, since the structure layout is completely different,
> as shown by this warning when we build this driver in one of the invalid
> configurations with link-time optimizations enabled:
> 
> include/linux/slab.h:715:0: error: type of 'kmem_cache_size' does not match original declaration [-Werror=lto-type-mismatch]
>  unsigned int kmem_cache_size(struct kmem_cache *s);
> 
> mm/slab_common.c:77:14: note: 'kmem_cache_size' was previously declared here
>  unsigned int kmem_cache_size(struct kmem_cache *s)
>               ^
> mm/slab_common.c:77:14: note: code may be misoptimized unless -fno-strict-aliasing is used
> include/linux/slab.h:147:0: error: type of 'kmem_cache_destroy' does not match original declaration [-Werror=lto-type-mismatch]
>  void kmem_cache_destroy(struct kmem_cache *);
> 
> mm/slab_common.c:858:6: note: 'kmem_cache_destroy' was previously declared here
>  void kmem_cache_destroy(struct kmem_cache *s)
>       ^
> mm/slab_common.c:858:6: note: code may be misoptimized unless -fno-strict-aliasing is used
> include/linux/slab.h:140:0: error: type of 'kmem_cache_create' does not match original declaration [-Werror=lto-type-mismatch]
>  struct kmem_cache *kmem_cache_create(const char *name, size_t size,
> 
> mm/slab_common.c:534:1: note: 'kmem_cache_create' was previously declared here
>  kmem_cache_create(const char *name, size_t size, size_t align,>  ^
> 
> This removes the header inclusion and instead uses the kmem_cache_size()
> interface to get the size in a reliable way.

Thanks Arnd, applied.

-- 
Jens Axboe

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

end of thread, other threads:[~2018-02-02 15:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-02 15:03 [PATCH] block: skd: fix incorrect linux/slab_def.h inclusion Arnd Bergmann
2018-02-02 15:08 ` Jens Axboe

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).