Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Jan 2022 19:36:30 GMT
From:      Vladimir Kondratyev <wulf@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: a692caea30d0 - stable/13 - LinuxKPI: Move kfree_async() functionality in to kfree()
Message-ID:  <202201221936.20MJaUga000218@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=a692caea30d08c0627d4ee924589f625efbefd73

commit a692caea30d08c0627d4ee924589f625efbefd73
Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2021-11-15 13:53:02 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2022-01-22 19:34:37 +0000

    LinuxKPI: Move kfree_async() functionality in to kfree()
    
    Obsolete it usage but keep for a while for drm-kmod 5.4 compatibility
    
    MFC after:      1 week
    Reviewed by:    hselasky, manu
    Differential Revision:  https://reviews.freebsd.org/D33298
    
    (cherry picked from commit 0b1244bd79c2c4da25278a2e25a2471d9edd9408)
---
 sys/compat/linuxkpi/common/include/linux/slab.h | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h
index e29dd064ff23..f7cad5f6b4cb 100644
--- a/sys/compat/linuxkpi/common/include/linux/slab.h
+++ b/sys/compat/linuxkpi/common/include/linux/slab.h
@@ -86,18 +86,8 @@ struct linux_kmem_cache;
 #define	ARCH_KMALLOC_MINALIGN \
 	__alignof(unsigned long long)
 
-/*
- * Critical section-friendly version of kfree().
- * Requires knowledge of the allocation size at build time.
- */
-#define kfree_async(ptr)	do {					\
-	_Static_assert(sizeof(*(ptr)) >= sizeof(struct llist_node),	\
-	    "Size of object to free is unknown or too small");		\
-	if (curthread->td_critnest != 0)				\
-		linux_kfree_async(ptr);					\
-	else								\
-		kfree(ptr);						\
-} while (0)
+/* drm-kmod 5.4 compat */
+#define kfree_async(ptr)	kfree(ptr);
 
 static inline gfp_t
 linux_check_m_flags(gfp_t flags)
@@ -117,7 +107,8 @@ linux_check_m_flags(gfp_t flags)
 static inline void *
 kmalloc(size_t size, gfp_t flags)
 {
-	return (malloc(size, M_KMALLOC, linux_check_m_flags(flags)));
+	return (malloc(MAX(size, sizeof(struct llist_node)), M_KMALLOC,
+	    linux_check_m_flags(flags)));
 }
 
 static inline void *
@@ -186,10 +177,15 @@ krealloc(void *ptr, size_t size, gfp_t flags)
 	return (realloc(ptr, size, M_KMALLOC, linux_check_m_flags(flags)));
 }
 
+extern void linux_kfree_async(void *);
+
 static inline void
 kfree(const void *ptr)
 {
-	free(__DECONST(void *, ptr), M_KMALLOC);
+	if (curthread->td_critnest != 0)
+		linux_kfree_async(__DECONST(void *, ptr));
+	else
+		free(__DECONST(void *, ptr), M_KMALLOC);
 }
 
 static __inline void
@@ -210,7 +206,6 @@ extern void *lkpi_kmem_cache_alloc(struct linux_kmem_cache *, gfp_t);
 extern void *lkpi_kmem_cache_zalloc(struct linux_kmem_cache *, gfp_t);
 extern void lkpi_kmem_cache_free(struct linux_kmem_cache *, void *);
 extern void linux_kmem_cache_destroy(struct linux_kmem_cache *);
-void linux_kfree_async(void *);
 void linux_kmem_cache_free_rcu_callback(struct rcu_head *head);
 void linux_kmem_cache_free_rcu(struct linux_kmem_cache *, void *);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201221936.20MJaUga000218>