Page MenuHomeFreeBSD

D20062.diff
No OneTemporary

D20062.diff

Index: sys/kern/kern_sendfile.c
===================================================================
--- sys/kern/kern_sendfile.c
+++ sys/kern/kern_sendfile.c
@@ -52,6 +52,8 @@
#include <sys/vnode.h>
#include <net/vnet.h>
+#include <netinet/in.h>
+#include <netinet/in_pcb.h>
#include <security/audit/audit.h>
#include <security/mac/mac_framework.h>
@@ -119,6 +121,12 @@
SYSCTL_PROC(_kern_ipc, OID_AUTO, sfstat, CTLTYPE_OPAQUE | CTLFLAG_RW,
NULL, 0, sfstat_sysctl, "I", "sendfile statistics");
+bool sendfile_numa_local = true;
+
+SYSCTL_BOOL(_kern_ipc, OID_AUTO, sendfile_numa_local, CTLFLAG_RWTUN,
+ &sendfile_numa_local, 0,
+ "Allocate NUMA local memory for sendfile when SF_NOCACHE is set");
+
/*
* Detach mapped page and release resources back to the system. Called
* by mbuf(9) code when last reference to a page is freed.
@@ -545,8 +553,9 @@
struct shmfd *shmfd;
struct sendfile_sync *sfs;
struct vattr va;
+ struct inpcb *inp;
off_t off, sbytes, rem, obj_size;
- int error, softerr, bsize, hdrlen;
+ int domain, error, softerr, bsize, hdrlen;
obj = NULL;
so = NULL;
@@ -742,6 +751,23 @@
refcount_init(&sfio->nios, 1);
sfio->so = so;
sfio->error = 0;
+ /*
+ * If the network connection is associated with a NUMA
+ * domain, and if the user has requested the data be
+ * quickly freed, then allocate backing pages from the
+ * domain which is local to the network connection
+ * (when allowed to by kern.ipc.sendfile_numa_local).
+ */
+ if ((flags & SF_NOCACHE) != 0 && sendfile_numa_local &&
+ (inp = sotoinpcb(so)) != NULL &&
+ (domain = inp->inp_numa_domain) != M_NODOM &&
+ obj->domain.dr_policy != DOMAINSET_PREF(domain)) {
+ VM_OBJECT_WLOCK(obj);
+ if (obj->domain.dr_policy != DOMAINSET_PREF(domain))
+ obj->domain.dr_policy =
+ DOMAINSET_PREF(domain);
+ VM_OBJECT_WUNLOCK(obj);
+ }
nios = sendfile_swapin(obj, sfio, off, space, npages, rhpages,
flags);

File Metadata

Mime Type
text/plain
Expires
Sun, Feb 15, 9:36 PM (1 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28756857
Default Alt Text
D20062.diff (1 KB)

Event Timeline