Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F131921905
D29077.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
D29077.id.diff
View Options
diff --git a/sys/compat/linuxkpi/common/include/linux/compat.h b/sys/compat/linuxkpi/common/include/linux/compat.h
--- a/sys/compat/linuxkpi/common/include/linux/compat.h
+++ b/sys/compat/linuxkpi/common/include/linux/compat.h
@@ -35,11 +35,13 @@
#include <sys/proc.h>
#include <sys/malloc.h>
+struct domainset;
struct thread;
struct task_struct;
extern int linux_alloc_current(struct thread *, int flags);
extern void linux_free_current(struct task_struct *);
+extern struct domainset *linux_get_vm_domain_set(int node);
static inline void
linux_set_current(struct thread *td)
diff --git a/sys/compat/linuxkpi/common/include/linux/device.h b/sys/compat/linuxkpi/common/include/linux/device.h
--- a/sys/compat/linuxkpi/common/include/linux/device.h
+++ b/sys/compat/linuxkpi/common/include/linux/device.h
@@ -554,11 +554,9 @@
sysfs_remove_file(&class->kobj, &attr->attr);
}
-static inline int
-dev_to_node(struct device *dev)
-{
- return -1;
-}
+#define dev_to_node(dev) linux_dev_to_node(dev)
+#define of_node_to_nid(node) -1
+int linux_dev_to_node(struct device *);
char *kvasprintf(gfp_t, const char *, va_list);
char *kasprintf(gfp_t, const char *, ...);
diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h
--- a/sys/compat/linuxkpi/common/include/linux/slab.h
+++ b/sys/compat/linuxkpi/common/include/linux/slab.h
@@ -2,7 +2,7 @@
* Copyright (c) 2010 Isilon Systems, Inc.
* Copyright (c) 2010 iX Systems, Inc.
* Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2021 Mellanox Technologies, Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,6 +38,7 @@
#include <sys/proc.h>
#include <vm/uma.h>
+#include <linux/compat.h>
#include <linux/types.h>
#include <linux/gfp.h>
#include <linux/llist.h>
@@ -48,16 +49,15 @@
#define kvzalloc(size, flags) kmalloc(size, (flags) | __GFP_ZERO)
#define kvcalloc(n, size, flags) kvmalloc_array(n, size, (flags) | __GFP_ZERO)
#define kzalloc(size, flags) kmalloc(size, (flags) | __GFP_ZERO)
-#define kzalloc_node(size, flags, node) kmalloc(size, (flags) | __GFP_ZERO)
+#define kzalloc_node(size, flags, node) kmalloc_node(size, (flags) | __GFP_ZERO, node)
#define kfree_const(ptr) kfree(ptr)
#define vzalloc(size) __vmalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, 0)
#define vfree(arg) kfree(arg)
#define kvfree(arg) kfree(arg)
-#define vmalloc_node(size, node) __vmalloc(size, GFP_KERNEL, 0)
+#define vmalloc_node(size, node) __vmalloc_node(size, GFP_KERNEL, node)
#define vmalloc_user(size) __vmalloc(size, GFP_KERNEL | __GFP_ZERO, 0)
#define vmalloc(size) __vmalloc(size, GFP_KERNEL, 0)
#define __kmalloc(...) kmalloc(__VA_ARGS__)
-#define kmalloc_node(chunk, flags, n) kmalloc(chunk, flags)
/*
* Prefix some functions with linux_ to avoid namespace conflict
@@ -126,6 +126,13 @@
return (malloc(size, M_KMALLOC, linux_check_m_flags(flags)));
}
+static inline void *
+kmalloc_node(size_t size, gfp_t flags, int node)
+{
+ return (malloc_domainset(size, M_KMALLOC,
+ linux_get_vm_domain_set(node), linux_check_m_flags(flags)));
+}
+
static inline void *
kcalloc(size_t n, size_t size, gfp_t flags)
{
@@ -133,12 +140,27 @@
return (mallocarray(n, size, M_KMALLOC, linux_check_m_flags(flags)));
}
+static inline void *
+kcalloc_node(size_t n, size_t size, gfp_t flags, int node)
+{
+ flags |= __GFP_ZERO;
+ return (mallocarray_domainset(n, size, M_KMALLOC,
+ linux_get_vm_domain_set(node), linux_check_m_flags(flags)));
+}
+
static inline void *
__vmalloc(size_t size, gfp_t flags, int other)
{
return (malloc(size, M_KMALLOC, linux_check_m_flags(flags)));
}
+static inline void *
+__vmalloc_node(size_t size, gfp_t flags, int node)
+{
+ return (malloc_domainset(size, M_KMALLOC,
+ linux_get_vm_domain_set(node), linux_check_m_flags(flags)));
+}
+
static inline void *
vmalloc_32(size_t size)
{
@@ -151,6 +173,13 @@
return (mallocarray(n, size, M_KMALLOC, linux_check_m_flags(flags)));
}
+static inline void *
+kmalloc_array_node(size_t n, size_t size, gfp_t flags, int node)
+{
+ return (mallocarray_domainset(n, size, M_KMALLOC,
+ linux_get_vm_domain_set(node), linux_check_m_flags(flags)));
+}
+
static inline void *
kvmalloc_array(size_t n, size_t size, gfp_t flags)
{
diff --git a/sys/compat/linuxkpi/common/include/linux/compat.h b/sys/compat/linuxkpi/common/src/linux_domain.c
copy from sys/compat/linuxkpi/common/include/linux/compat.h
copy to sys/compat/linuxkpi/common/src/linux_domain.c
--- a/sys/compat/linuxkpi/common/include/linux/compat.h
+++ b/sys/compat/linuxkpi/common/src/linux_domain.c
@@ -1,8 +1,5 @@
/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
+ * Copyright (c) 2021 NVIDIA Networking
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +22,38 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#ifndef _LINUX_COMPAT_H_
-#define _LINUX_COMPAT_H_
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
-struct thread;
-struct task_struct;
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/domainset.h>
+#include <sys/bus.h>
-extern int linux_alloc_current(struct thread *, int flags);
-extern void linux_free_current(struct task_struct *);
+#include <linux/compat.h>
+#include <linux/device.h>
-static inline void
-linux_set_current(struct thread *td)
+struct domainset *
+linux_get_vm_domain_set(int node)
{
- if (__predict_false(td->td_lkpi_task == NULL))
- lkpi_alloc_current(td, M_WAITOK);
+ KASSERT(node < MAXMEMDOM, ("Invalid VM domain %d", node));
+
+ if (node < 0)
+ return (DOMAINSET_RR());
+ else
+ return (DOMAINSET_PREF(node));
}
-static inline int
-linux_set_current_flags(struct thread *td, int flags)
+int
+linux_dev_to_node(struct device *dev)
{
- if (__predict_false(td->td_lkpi_task == NULL))
- return (lkpi_alloc_current(td, flags));
- return (0);
-}
+ int numa_domain;
-#endif /* _LINUX_COMPAT_H_ */
+ if (dev == NULL || dev->bsddev == NULL ||
+ bus_get_domain(dev->bsddev, &numa_domain) != 0)
+ return (-1);
+ else
+ return (numa_domain);
+}
diff --git a/sys/conf/files b/sys/conf/files
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -4565,6 +4565,8 @@
compile-with "${LINUXKPI_C}"
compat/linuxkpi/common/src/linux_dmi.c optional compat_linuxkpi \
compile-with "${LINUXKPI_C}"
+compat/linuxkpi/common/src/linux_domain.c optional compat_linuxkpi \
+ compile-with "${LINUXKPI_C}"
compat/linuxkpi/common/src/linux_firmware.c optional compat_linuxkpi \
compile-with "${LINUXKPI_C}"
compat/linuxkpi/common/src/linux_hrtimer.c optional compat_linuxkpi \
diff --git a/sys/modules/linuxkpi/Makefile b/sys/modules/linuxkpi/Makefile
--- a/sys/modules/linuxkpi/Makefile
+++ b/sys/modules/linuxkpi/Makefile
@@ -6,6 +6,7 @@
linux_current.c \
linux_devres.c \
linux_dmi.c \
+ linux_domain.c \
linux_firmware.c \
linux_hrtimer.c \
linux_idr.c \
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 13, 5:52 AM (15 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23623062
Default Alt Text
D29077.id.diff (7 KB)
Attached To
Mode
D29077: Implement basic support for allocating memory from a specific numa node in the LinuxKPI.
Attached
Detach File
Event Timeline
Log In to Comment