Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178081855
D62137.1795905642.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D62137.1795905642.diff
View Options
diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c
--- a/sys/dev/netmap/netmap_freebsd.c
+++ b/sys/dev/netmap/netmap_freebsd.c
@@ -1213,8 +1213,16 @@
/* Continuously execute worker process. */
ctx->worker_fn(ctx->worker_private); /* worker body */
+
+ /* Let the other threads bound to this CPU run. */
+ maybe_yield();
}
+ /* nm_os_kctx_worker_stop() waits for this. */
+ mtx_lock(&nmk->worker_lock);
+ nmk->worker = NULL;
+ wakeup(nmk);
+ mtx_unlock(&nmk->worker_lock);
kthread_exit();
}
@@ -1251,10 +1259,8 @@
struct proc *p = NULL;
int error = 0;
- /* Temporarily disable this function as it is currently broken
- * and causes kernel crashes. The failure can be triggered by
- * the "vale_polling_enable_disable" test in ctrl-api-test.c. */
- return EOPNOTSUPP;
+ if (nmk->affinity >= 0 && CPU_ABSENT(nmk->affinity))
+ return EINVAL;
if (nmk->worker)
return EBUSY;
@@ -1274,7 +1280,8 @@
goto err;
}
- nm_prinf("nm_kthread started td %p", nmk->worker);
+ if (netmap_verbose)
+ nm_prinf("nm_kthread started td %p", nmk->worker);
return 0;
err:
@@ -1286,16 +1293,19 @@
void
nm_os_kctx_worker_stop(struct nm_kctx *nmk)
{
- if (!nmk->worker)
- return;
+ mtx_lock(&nmk->worker_lock);
+ if (nmk->worker != NULL) {
+ /* tell to kthread to exit from main loop */
+ nmk->run = 0;
- /* tell to kthread to exit from main loop */
- nmk->run = 0;
+ /* wake up kthread if it sleeps */
+ kthread_resume(nmk->worker);
- /* wake up kthread if it sleeps */
- kthread_resume(nmk->worker);
-
- nmk->worker = NULL;
+ /* the caller frees what the worker function uses */
+ while (nmk->worker != NULL)
+ mtx_sleep(nmk, &nmk->worker_lock, 0, "nmkstop", 0);
+ }
+ mtx_unlock(&nmk->worker_lock);
}
void
@@ -1304,9 +1314,8 @@
if (!nmk)
return;
- if (nmk->worker)
- nm_os_kctx_worker_stop(nmk);
-
+ nm_os_kctx_worker_stop(nmk);
+ mtx_destroy(&nmk->worker_lock);
free(nmk, M_DEVBUF);
}
diff --git a/tests/sys/netmap/ctrl-api-test.c b/tests/sys/netmap/ctrl-api-test.c
--- a/tests/sys/netmap/ctrl-api-test.c
+++ b/tests/sys/netmap/ctrl-api-test.c
@@ -921,6 +921,12 @@
{
int ret = 0;
+ /* The kernel does not let polling use all the CPUs. */
+ if (sysconf(_SC_NPROCESSORS_ONLN) < 2) {
+ printf("Skipping VALE polling on a single CPU\n");
+ return 0;
+ }
+
if ((ret = vale_attach(ctx)) != 0) {
return ret;
}
@@ -930,14 +936,7 @@
ctx->nr_first_cpu_id = 0;
if ((ret = vale_polling_enable(ctx))) {
vale_detach(ctx);
-#ifdef __FreeBSD__
- /* NETMAP_REQ_VALE_POLLING_DISABLE is disabled on FreeBSD,
- * because it is currently broken. We are happy to see that
- * it fails. */
- return 0;
-#else
return ret;
-#endif
}
if ((ret = vale_polling_disable(ctx))) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 28, 10:40 PM (21 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42079937
Default Alt Text
D62137.1795905642.diff (2 KB)
Attached To
Mode
D62137: netmap: Make VALE polling work on FreeBSD
Attached
Detach File
Event Timeline