Module Name: src
Committed By: ozaki-r
Date: Tue Apr 19 05:48:10 UTC 2016
Modified Files:
src/sys/rump/net/lib/libshmif: if_shmem.c
src/sys/rump/net/lib/libvirtif: if_virt.c
Log Message:
Prevent LWP migrations between CPUs during upper layer processing
This is a contract of psref(9) that is used by upper layer componenets,
e.g., bridge(4).
To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/rump/net/lib/libshmif/if_shmem.c
cvs rdiff -u -r1.50 -r1.51 src/sys/rump/net/lib/libvirtif/if_virt.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/rump/net/lib/libshmif/if_shmem.c
diff -u src/sys/rump/net/lib/libshmif/if_shmem.c:1.65 src/sys/rump/net/lib/libshmif/if_shmem.c:1.66
--- src/sys/rump/net/lib/libshmif/if_shmem.c:1.65 Tue Feb 9 08:32:12 2016
+++ src/sys/rump/net/lib/libshmif/if_shmem.c Tue Apr 19 05:48:10 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: if_shmem.c,v 1.65 2016/02/09 08:32:12 ozaki-r Exp $ */
+/* $NetBSD: if_shmem.c,v 1.66 2016/04/19 05:48:10 ozaki-r Exp $ */
/*
* Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.65 2016/02/09 08:32:12 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.66 2016/04/19 05:48:10 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -764,10 +764,14 @@ shmif_rcv(void *arg)
}
if (passup) {
+ int bound = curlwp->l_pflag & LP_BOUND;
ifp->if_ipackets++;
KERNEL_LOCK(1, NULL);
+ /* Prevent LWP migrations between CPUs for psref(9) */
+ curlwp->l_pflag |= LP_BOUND;
bpf_mtap(ifp, m);
if_input(ifp, m);
+ curlwp->l_pflag ^= bound ^ LP_BOUND;
KERNEL_UNLOCK_ONE(NULL);
m = NULL;
}
Index: src/sys/rump/net/lib/libvirtif/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.50 src/sys/rump/net/lib/libvirtif/if_virt.c:1.51
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.50 Tue Feb 9 08:32:12 2016
+++ src/sys/rump/net/lib/libvirtif/if_virt.c Tue Apr 19 05:48:10 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: if_virt.c,v 1.50 2016/02/09 08:32:12 ozaki-r Exp $ */
+/* $NetBSD: if_virt.c,v 1.51 2016/04/19 05:48:10 ozaki-r Exp $ */
/*
* Copyright (c) 2008, 2013 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.50 2016/02/09 08:32:12 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.51 2016/04/19 05:48:10 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -374,11 +374,15 @@ VIF_DELIVERPKT(struct virtif_sc *sc, str
}
if (passup) {
+ int bound = curlwp->l_pflag & LP_BOUND;
ifp->if_ipackets++;
m->m_pkthdr.rcvif = ifp;
KERNEL_LOCK(1, NULL);
+ /* Prevent LWP migrations between CPUs for psref(9) */
+ curlwp->l_pflag |= LP_BOUND;
bpf_mtap(ifp, m);
if_input(ifp, m);
+ curlwp->l_pflag ^= bound ^ LP_BOUND;
KERNEL_UNLOCK_LAST(NULL);
} else {
m_freem(m);