Index: sys/kern/kern_sendfile.c =================================================================== --- sys/kern/kern_sendfile.c +++ sys/kern/kern_sendfile.c @@ -52,6 +52,8 @@ #include #include +#include +#include #include #include @@ -545,6 +547,7 @@ 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; @@ -742,6 +745,22 @@ 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. + */ + if ((flags & SF_NOCACHE) != 0 && + (inp = sotoinpcb(so)) != NULL && + inp->inp_numa_domain != M_NODOM && + obj->domain.dr_policy == NULL) { + VM_OBJECT_WLOCK(obj); + if (obj->domain.dr_policy == NULL) + obj->domain.dr_policy = + DOMAINSET_PREF(inp->inp_numa_domain); + VM_OBJECT_WUNLOCK(obj); + } nios = sendfile_swapin(obj, sfio, off, space, npages, rhpages, flags);