Author: hselasky
Date: Wed Apr 19 11:38:07 2017
New Revision: 317135
URL: https://svnweb.freebsd.org/changeset/base/317135

Log:
  Zero number of CPUs should be translated into the default number of
  CPUs when allocating a LinuxKPI workqueue. This also ensures that the
  created taskqueue always have a non-zero number of worker threads.
  
  MFC after:            1 week
  Sponsored by:         Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/src/linux_work.c

Modified: head/sys/compat/linuxkpi/common/src/linux_work.c
==============================================================================
--- head/sys/compat/linuxkpi/common/src/linux_work.c    Wed Apr 19 11:13:32 
2017        (r317134)
+++ head/sys/compat/linuxkpi/common/src/linux_work.c    Wed Apr 19 11:38:07 
2017        (r317135)
@@ -57,6 +57,8 @@ struct workqueue_struct *system_long_wq;
 struct workqueue_struct *system_unbound_wq;
 struct workqueue_struct *system_power_efficient_wq;
 
+static int linux_default_wq_cpus = 4;
+
 static void linux_delayed_work_timer_fn(void *);
 
 /*
@@ -497,6 +499,12 @@ linux_create_workqueue_common(const char
 {
        struct workqueue_struct *wq;
 
+       /*
+        * If zero CPUs are specified use the default number of CPUs:
+        */
+       if (cpus == 0)
+               cpus = linux_default_wq_cpus;
+
        wq = kmalloc(sizeof(*wq), M_WAITOK | M_ZERO);
        wq->taskqueue = taskqueue_create(name, M_WAITOK,
            taskqueue_thread_enqueue, &wq->taskqueue);
@@ -537,6 +545,9 @@ linux_work_init(void *arg)
        if (max_wq_cpus < 4)
                max_wq_cpus = 4;
 
+       /* set default number of CPUs */
+       linux_default_wq_cpus = max_wq_cpus;
+
        linux_system_short_wq = alloc_workqueue("linuxkpi_short_wq", 0, 
max_wq_cpus);
        linux_system_long_wq = alloc_workqueue("linuxkpi_long_wq", 0, 
max_wq_cpus);
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to