[ewg] Re: [PATCH ofed-1.2.c] ehca: backport kmem_cache_zalloc() for 2.6.10/sles10/sles10_sp1

Michael S. Tsirkin mst at dev.mellanox.co.il
Tue Aug 7 06:23:02 PDT 2007


> Quoting Hoang-Nam Nguyen <hnguyen at linux.vnet.ibm.com>:
> Subject: Re: [PATCH ofed-1.2.c] ehca: backport kmem_cache_zalloc() for 2.6.10/sles10/sles10_sp1
> 
> Hello Michael!
> Below is the patch to backport kmem_cache_zalloc() for 2.6.16/sles10/sles10_sp1
> as we've discussed previously. Thereby I realized current backport code
> in slab.h looks weird to me (sort of copy&paste mixture) - actually no build
> error, only coding "issue". 
> Therefore this patch also includes some cleanup. If it's ok, please apply.
> PS: The mentioned issue in backport slab.h exists also in other versions.
> If you want me to fix them as well, let me know.
> Regards
> Nam

Would not the following work? If yes, Vlad, I parked this at

git://git.openfabrics.org/~mst/ofed_kernel.git ofed_1_2_c

---------------------------------------------------------

commit 68ba5a0d23460b9580af3afd0dbc35ce87bce089
Author: Michael S. Tsirkin <mst at mellanox.co.il>
Date:   Tue Aug 7 16:19:30 2007 +0300

Backport kmem_cache_zalloc to kernels <= 2.6.16.
Used by ehca.

Signed-off-by: Michael S. Tsirkin <mst at dev.mellanox.co.il>

---

diff --git a/kernel_addons/backport/2.6.11/include/linux/slab.h b/kernel_addons/backport/2.6.11/include/linux/slab.h
index 9d82afa..78e096f 100644
--- a/kernel_addons/backport/2.6.11/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.11/include/linux/slab.h
@@ -40,3 +40,17 @@ void *kmalloc_node(size_t size, gfp_t flags, int nid)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.11_FC4/include/linux/slab.h b/kernel_addons/backport/2.6.11_FC4/include/linux/slab.h
index bd9671d..8089f73 100644
--- a/kernel_addons/backport/2.6.11_FC4/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.11_FC4/include/linux/slab.h
@@ -55,3 +55,17 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.12/include/linux/slab.h b/kernel_addons/backport/2.6.12/include/linux/slab.h
index bd9671d..8089f73 100644
--- a/kernel_addons/backport/2.6.12/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.12/include/linux/slab.h
@@ -55,3 +55,17 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.13/include/linux/slab.h b/kernel_addons/backport/2.6.13/include/linux/slab.h
index 0540cc6..a54188d 100644
--- a/kernel_addons/backport/2.6.13/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.13/include/linux/slab.h
@@ -45,3 +45,17 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.13_suse10_0_u/include/linux/slab.h b/kernel_addons/backport/2.6.13_suse10_0_u/include/linux/slab.h
index 0540cc6..a54188d 100644
--- a/kernel_addons/backport/2.6.13_suse10_0_u/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.13_suse10_0_u/include/linux/slab.h
@@ -45,3 +45,17 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.14/include/linux/slab.h b/kernel_addons/backport/2.6.14/include/linux/slab.h
index 46ac6e5..b805107 100644
--- a/kernel_addons/backport/2.6.14/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.14/include/linux/slab.h
@@ -32,3 +32,17 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.15/include/linux/slab.h b/kernel_addons/backport/2.6.15/include/linux/slab.h
index 46ac6e5..b805107 100644
--- a/kernel_addons/backport/2.6.15/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.15/include/linux/slab.h
@@ -32,3 +32,17 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.15_ubuntu606/include/linux/slab.h b/kernel_addons/backport/2.6.15_ubuntu606/include/linux/slab.h
index 46ac6e5..b805107 100644
--- a/kernel_addons/backport/2.6.15_ubuntu606/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.15_ubuntu606/include/linux/slab.h
@@ -32,3 +32,17 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.16/include/linux/slab.h b/kernel_addons/backport/2.6.16/include/linux/slab.h
index 46ac6e5..b805107 100644
--- a/kernel_addons/backport/2.6.16/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.16/include/linux/slab.h
@@ -32,3 +32,17 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.16_sles10/include/linux/slab.h b/kernel_addons/backport/2.6.16_sles10/include/linux/slab.h
index 46ac6e5..b805107 100644
--- a/kernel_addons/backport/2.6.16_sles10/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.16_sles10/include/linux/slab.h
@@ -32,3 +32,17 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.16_sles10_sp1/include/linux/slab.h b/kernel_addons/backport/2.6.16_sles10_sp1/include/linux/slab.h
index 46ac6e5..b805107 100644
--- a/kernel_addons/backport/2.6.16_sles10_sp1/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.16_sles10_sp1/include/linux/slab.h
@@ -32,3 +32,17 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.5_sles9_sp3/include/linux/slab.h b/kernel_addons/backport/2.6.5_sles9_sp3/include/linux/slab.h
index c8285ac..8067cb5 100644
--- a/kernel_addons/backport/2.6.5_sles9_sp3/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.5_sles9_sp3/include/linux/slab.h
@@ -30,3 +30,17 @@ void *kmalloc_node(size_t size, gfp_t flags, int nid)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.9_U2/include/linux/slab.h b/kernel_addons/backport/2.6.9_U2/include/linux/slab.h
index 9d82afa..78e096f 100644
--- a/kernel_addons/backport/2.6.9_U2/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.9_U2/include/linux/slab.h
@@ -40,3 +40,17 @@ void *kmalloc_node(size_t size, gfp_t flags, int nid)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.9_U3/include/linux/slab.h b/kernel_addons/backport/2.6.9_U3/include/linux/slab.h
index cbf6311..79af0e5 100644
--- a/kernel_addons/backport/2.6.9_U3/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.9_U3/include/linux/slab.h
@@ -21,3 +21,17 @@ void *kmalloc_node(size_t size, gfp_t flags, int nid)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/slab.h b/kernel_addons/backport/2.6.9_U4/include/linux/slab.h
index cbf6311..79af0e5 100644
--- a/kernel_addons/backport/2.6.9_U4/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.9_U4/include/linux/slab.h
@@ -21,3 +21,17 @@ void *kmalloc_node(size_t size, gfp_t flags, int nid)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.9_U5/include/linux/slab.h b/kernel_addons/backport/2.6.9_U5/include/linux/slab.h
index cbf6311..79af0e5 100644
--- a/kernel_addons/backport/2.6.9_U5/include/linux/slab.h
+++ b/kernel_addons/backport/2.6.9_U5/include/linux/slab.h
@@ -21,3 +21,17 @@ void *kmalloc_node(size_t size, gfp_t flags, int nid)
 }
 
 #endif
+#ifndef SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+#define SLAB_H_KMEMCACHE_ZALLOC_BACKPORT_TO_2_6_16
+
+static inline
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *ret = kmem_cache_alloc(cache, flags);
+       if (ret)
+	       memset(ret, 0, kmem_cache_size(cache));
+
+       return ret;
+}
+
+#endif

-- 
MST



More information about the ewg mailing list