From owner-svn-src-all@freebsd.org Fri Dec 9 13:41:27 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D74D6C6E6EF; Fri, 9 Dec 2016 13:41:27 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 955518C7; Fri, 9 Dec 2016 13:41:27 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uB9DfQ2l081761; Fri, 9 Dec 2016 13:41:26 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uB9DfQfh081760; Fri, 9 Dec 2016 13:41:26 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201612091341.uB9DfQfh081760@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 9 Dec 2016 13:41:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r309731 - head/sys/compat/linuxkpi/common/include/linux X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Dec 2016 13:41:27 -0000 Author: hselasky Date: Fri Dec 9 13:41:26 2016 New Revision: 309731 URL: https://svnweb.freebsd.org/changeset/base/309731 Log: Prefix the Linux KPI's kmem_xxx() functions with linux_ to avoid conflict with the opensolaris kernel module. This patch solves a problem where the kernel linker will incorrectly resolve opensolaris kmem_xxx() functions as linuxkpi ones, which leads to a panic when these functions are used. Submitted by: gallatin @ Sponsored by: Mellanox Technologies MFC after: 1 week Modified: head/sys/compat/linuxkpi/common/include/linux/slab.h Modified: head/sys/compat/linuxkpi/common/include/linux/slab.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/slab.h Fri Dec 9 08:41:57 2016 (r309730) +++ head/sys/compat/linuxkpi/common/include/linux/slab.h Fri Dec 9 13:41:26 2016 (r309731) @@ -55,7 +55,18 @@ MALLOC_DECLARE(M_KMALLOC); #define vmalloc(size) kmalloc(size, GFP_KERNEL) #define vmalloc_node(size, node) kmalloc(size, GFP_KERNEL) -struct kmem_cache { + +/* + * Prefix some functions with linux_ to avoid namespace conflict + * with the OpenSolaris code in the kernel. + */ +#define kmem_cache linux_kmem_cache +#define kmem_cache_create(...) linux_kmem_cache_create(__VA_ARGS__) +#define kmem_cache_alloc(...) linux_kmem_cache_alloc(__VA_ARGS__) +#define kmem_cache_free(...) linux_kmem_cache_free(__VA_ARGS__) +#define kmem_cache_destroy(...) linux_kmem_cache_destroy(__VA_ARGS__) + +struct linux_kmem_cache { uma_zone_t cache_zone; void (*cache_ctor)(void *); }; @@ -63,7 +74,7 @@ struct kmem_cache { #define SLAB_HWCACHE_ALIGN 0x0001 static inline int -kmem_ctor(void *mem, int size, void *arg, int flags) +linux_kmem_ctor(void *mem, int size, void *arg, int flags) { void (*ctor)(void *); @@ -74,7 +85,7 @@ kmem_ctor(void *mem, int size, void *arg } static inline struct kmem_cache * -kmem_cache_create(char *name, size_t size, size_t align, u_long flags, +linux_kmem_cache_create(char *name, size_t size, size_t align, u_long flags, void (*ctor)(void *)) { struct kmem_cache *c; @@ -84,7 +95,7 @@ kmem_cache_create(char *name, size_t siz align--; if (flags & SLAB_HWCACHE_ALIGN) align = UMA_ALIGN_CACHE; - c->cache_zone = uma_zcreate(name, size, ctor ? kmem_ctor : NULL, + c->cache_zone = uma_zcreate(name, size, ctor ? linux_kmem_ctor : NULL, NULL, NULL, NULL, align, 0); c->cache_ctor = ctor; @@ -92,19 +103,19 @@ kmem_cache_create(char *name, size_t siz } static inline void * -kmem_cache_alloc(struct kmem_cache *c, int flags) +linux_kmem_cache_alloc(struct kmem_cache *c, int flags) { return uma_zalloc_arg(c->cache_zone, c->cache_ctor, flags); } static inline void -kmem_cache_free(struct kmem_cache *c, void *m) +linux_kmem_cache_free(struct kmem_cache *c, void *m) { uma_zfree(c->cache_zone, m); } static inline void -kmem_cache_destroy(struct kmem_cache *c) +linux_kmem_cache_destroy(struct kmem_cache *c) { uma_zdestroy(c->cache_zone); free(c, M_KMALLOC);