slow-work.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /* Worker thread pool for slow items, such as filesystem lookups or mkdirs
  2. *
  3. * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. *
  11. * See Documentation/slow-work.txt
  12. */
  13. #include <linux/module.h>
  14. #include <linux/slow-work.h>
  15. #include <linux/kthread.h>
  16. #include <linux/freezer.h>
  17. #include <linux/wait.h>
  18. #define SLOW_WORK_CULL_TIMEOUT (5 * HZ) /* cull threads 5s after running out of
  19. * things to do */
  20. #define SLOW_WORK_OOM_TIMEOUT (5 * HZ) /* can't start new threads for 5s after
  21. * OOM */
  22. static void slow_work_cull_timeout(unsigned long);
  23. static void slow_work_oom_timeout(unsigned long);
  24. #ifdef CONFIG_SYSCTL
  25. static int slow_work_min_threads_sysctl(struct ctl_table *, int,
  26. void __user *, size_t *, loff_t *);
  27. static int slow_work_max_threads_sysctl(struct ctl_table *, int ,
  28. void __user *, size_t *, loff_t *);
  29. #endif
  30. /*
  31. * The pool of threads has at least min threads in it as long as someone is
  32. * using the facility, and may have as many as max.
  33. *
  34. * A portion of the pool may be processing very slow operations.
  35. */
  36. static unsigned slow_work_min_threads = 2;
  37. static unsigned slow_work_max_threads = 4;
  38. static unsigned vslow_work_proportion = 50; /* % of threads that may process
  39. * very slow work */
  40. #ifdef CONFIG_SYSCTL
  41. static const int slow_work_min_min_threads = 2;
  42. static int slow_work_max_max_threads = 255;
  43. static const int slow_work_min_vslow = 1;
  44. static const int slow_work_max_vslow = 99;
  45. ctl_table slow_work_sysctls[] = {
  46. {
  47. .procname = "min-threads",
  48. .data = &slow_work_min_threads,
  49. .maxlen = sizeof(unsigned),
  50. .mode = 0644,
  51. .proc_handler = slow_work_min_threads_sysctl,
  52. .extra1 = (void *) &slow_work_min_min_threads,
  53. .extra2 = &slow_work_max_threads,
  54. },
  55. {
  56. .procname = "max-threads",
  57. .data = &slow_work_max_threads,
  58. .maxlen = sizeof(unsigned),
  59. .mode = 0644,
  60. .proc_handler = slow_work_max_threads_sysctl,
  61. .extra1 = &slow_work_min_threads,
  62. .extra2 = (void *) &slow_work_max_max_threads,
  63. },
  64. {
  65. .procname = "vslow-percentage",
  66. .data = &vslow_work_proportion,
  67. .maxlen = sizeof(unsigned),
  68. .mode = 0644,
  69. .proc_handler = &proc_dointvec_minmax,
  70. .extra1 = (void *) &slow_work_min_vslow,
  71. .extra2 = (void *) &slow_work_max_vslow,
  72. },
  73. {}
  74. };
  75. #endif
  76. /*
  77. * The active state of the thread pool
  78. */
  79. static atomic_t slow_work_thread_count;
  80. static atomic_t vslow_work_executing_count;
  81. static bool slow_work_may_not_start_new_thread;
  82. static bool slow_work_cull; /* cull a thread due to lack of activity */
  83. static DEFINE_TIMER(slow_work_cull_timer, slow_work_cull_timeout, 0, 0);
  84. static DEFINE_TIMER(slow_work_oom_timer, slow_work_oom_timeout, 0, 0);
  85. static struct slow_work slow_work_new_thread; /* new thread starter */
  86. /*
  87. * The queues of work items and the lock governing access to them. These are
  88. * shared between all the CPUs. It doesn't make sense to have per-CPU queues
  89. * as the number of threads bears no relation to the number of CPUs.
  90. *
  91. * There are two queues of work items: one for slow work items, and one for
  92. * very slow work items.
  93. */
  94. static LIST_HEAD(slow_work_queue);
  95. static LIST_HEAD(vslow_work_queue);
  96. static DEFINE_SPINLOCK(slow_work_queue_lock);
  97. /*
  98. * The thread controls. A variable used to signal to the threads that they
  99. * should exit when the queue is empty, a waitqueue used by the threads to wait
  100. * for signals, and a completion set by the last thread to exit.
  101. */
  102. static bool slow_work_threads_should_exit;
  103. static DECLARE_WAIT_QUEUE_HEAD(slow_work_thread_wq);
  104. static DECLARE_COMPLETION(slow_work_last_thread_exited);
  105. /*
  106. * The number of users of the thread pool and its lock. Whilst this is zero we
  107. * have no threads hanging around, and when this reaches zero, we wait for all
  108. * active or queued work items to complete and kill all the threads we do have.
  109. */
  110. static int slow_work_user_count;
  111. static DEFINE_MUTEX(slow_work_user_lock);
  112. /*
  113. * Calculate the maximum number of active threads in the pool that are
  114. * permitted to process very slow work items.
  115. *
  116. * The answer is rounded up to at least 1, but may not equal or exceed the
  117. * maximum number of the threads in the pool. This means we always have at
  118. * least one thread that can process slow work items, and we always have at
  119. * least one thread that won't get tied up doing so.
  120. */
  121. static unsigned slow_work_calc_vsmax(void)
  122. {
  123. unsigned vsmax;
  124. vsmax = atomic_read(&slow_work_thread_count) * vslow_work_proportion;
  125. vsmax /= 100;
  126. vsmax = max(vsmax, 1U);
  127. return min(vsmax, slow_work_max_threads - 1);
  128. }
  129. /*
  130. * Attempt to execute stuff queued on a slow thread. Return true if we managed
  131. * it, false if there was nothing to do.
  132. */
  133. static bool slow_work_execute(void)
  134. {
  135. struct slow_work *work = NULL;
  136. unsigned vsmax;
  137. bool very_slow;
  138. vsmax = slow_work_calc_vsmax();
  139. /* see if we can schedule a new thread to be started if we're not
  140. * keeping up with the work */
  141. if (!waitqueue_active(&slow_work_thread_wq) &&
  142. (!list_empty(&slow_work_queue) || !list_empty(&vslow_work_queue)) &&
  143. atomic_read(&slow_work_thread_count) < slow_work_max_threads &&
  144. !slow_work_may_not_start_new_thread)
  145. slow_work_enqueue(&slow_work_new_thread);
  146. /* find something to execute */
  147. spin_lock_irq(&slow_work_queue_lock);
  148. if (!list_empty(&vslow_work_queue) &&
  149. atomic_read(&vslow_work_executing_count) < vsmax) {
  150. work = list_entry(vslow_work_queue.next,
  151. struct slow_work, link);
  152. if (test_and_set_bit_lock(SLOW_WORK_EXECUTING, &work->flags))
  153. BUG();
  154. list_del_init(&work->link);
  155. atomic_inc(&vslow_work_executing_count);
  156. very_slow = true;
  157. } else if (!list_empty(&slow_work_queue)) {
  158. work = list_entry(slow_work_queue.next,
  159. struct slow_work, link);
  160. if (test_and_set_bit_lock(SLOW_WORK_EXECUTING, &work->flags))
  161. BUG();
  162. list_del_init(&work->link);
  163. very_slow = false;
  164. } else {
  165. very_slow = false; /* avoid the compiler warning */
  166. }
  167. spin_unlock_irq(&slow_work_queue_lock);
  168. if (!work)
  169. return false;
  170. if (!test_and_clear_bit(SLOW_WORK_PENDING, &work->flags))
  171. BUG();
  172. work->ops->execute(work);
  173. if (very_slow)
  174. atomic_dec(&vslow_work_executing_count);
  175. clear_bit_unlock(SLOW_WORK_EXECUTING, &work->flags);
  176. /* if someone tried to enqueue the item whilst we were executing it,
  177. * then it'll be left unenqueued to avoid multiple threads trying to
  178. * execute it simultaneously
  179. *
  180. * there is, however, a race between us testing the pending flag and
  181. * getting the spinlock, and between the enqueuer setting the pending
  182. * flag and getting the spinlock, so we use a deferral bit to tell us
  183. * if the enqueuer got there first
  184. */
  185. if (test_bit(SLOW_WORK_PENDING, &work->flags)) {
  186. spin_lock_irq(&slow_work_queue_lock);
  187. if (!test_bit(SLOW_WORK_EXECUTING, &work->flags) &&
  188. test_and_clear_bit(SLOW_WORK_ENQ_DEFERRED, &work->flags))
  189. goto auto_requeue;
  190. spin_unlock_irq(&slow_work_queue_lock);
  191. }
  192. work->ops->put_ref(work);
  193. return true;
  194. auto_requeue:
  195. /* we must complete the enqueue operation
  196. * - we transfer our ref on the item back to the appropriate queue
  197. * - don't wake another thread up as we're awake already
  198. */
  199. if (test_bit(SLOW_WORK_VERY_SLOW, &work->flags))
  200. list_add_tail(&work->link, &vslow_work_queue);
  201. else
  202. list_add_tail(&work->link, &slow_work_queue);
  203. spin_unlock_irq(&slow_work_queue_lock);
  204. return true;
  205. }
  206. /**
  207. * slow_work_enqueue - Schedule a slow work item for processing
  208. * @work: The work item to queue
  209. *
  210. * Schedule a slow work item for processing. If the item is already undergoing
  211. * execution, this guarantees not to re-enter the execution routine until the
  212. * first execution finishes.
  213. *
  214. * The item is pinned by this function as it retains a reference to it, managed
  215. * through the item operations. The item is unpinned once it has been
  216. * executed.
  217. *
  218. * An item may hog the thread that is running it for a relatively large amount
  219. * of time, sufficient, for example, to perform several lookup, mkdir, create
  220. * and setxattr operations. It may sleep on I/O and may sleep to obtain locks.
  221. *
  222. * Conversely, if a number of items are awaiting processing, it may take some
  223. * time before any given item is given attention. The number of threads in the
  224. * pool may be increased to deal with demand, but only up to a limit.
  225. *
  226. * If SLOW_WORK_VERY_SLOW is set on the work item, then it will be placed in
  227. * the very slow queue, from which only a portion of the threads will be
  228. * allowed to pick items to execute. This ensures that very slow items won't
  229. * overly block ones that are just ordinarily slow.
  230. *
  231. * Returns 0 if successful, -EAGAIN if not.
  232. */
  233. int slow_work_enqueue(struct slow_work *work)
  234. {
  235. unsigned long flags;
  236. BUG_ON(slow_work_user_count <= 0);
  237. BUG_ON(!work);
  238. BUG_ON(!work->ops);
  239. BUG_ON(!work->ops->get_ref);
  240. /* when honouring an enqueue request, we only promise that we will run
  241. * the work function in the future; we do not promise to run it once
  242. * per enqueue request
  243. *
  244. * we use the PENDING bit to merge together repeat requests without
  245. * having to disable IRQs and take the spinlock, whilst still
  246. * maintaining our promise
  247. */
  248. if (!test_and_set_bit_lock(SLOW_WORK_PENDING, &work->flags)) {
  249. spin_lock_irqsave(&slow_work_queue_lock, flags);
  250. /* we promise that we will not attempt to execute the work
  251. * function in more than one thread simultaneously
  252. *
  253. * this, however, leaves us with a problem if we're asked to
  254. * enqueue the work whilst someone is executing the work
  255. * function as simply queueing the work immediately means that
  256. * another thread may try executing it whilst it is already
  257. * under execution
  258. *
  259. * to deal with this, we set the ENQ_DEFERRED bit instead of
  260. * enqueueing, and the thread currently executing the work
  261. * function will enqueue the work item when the work function
  262. * returns and it has cleared the EXECUTING bit
  263. */
  264. if (test_bit(SLOW_WORK_EXECUTING, &work->flags)) {
  265. set_bit(SLOW_WORK_ENQ_DEFERRED, &work->flags);
  266. } else {
  267. if (work->ops->get_ref(work) < 0)
  268. goto cant_get_ref;
  269. if (test_bit(SLOW_WORK_VERY_SLOW, &work->flags))
  270. list_add_tail(&work->link, &vslow_work_queue);
  271. else
  272. list_add_tail(&work->link, &slow_work_queue);
  273. wake_up(&slow_work_thread_wq);
  274. }
  275. spin_unlock_irqrestore(&slow_work_queue_lock, flags);
  276. }
  277. return 0;
  278. cant_get_ref:
  279. spin_unlock_irqrestore(&slow_work_queue_lock, flags);
  280. return -EAGAIN;
  281. }
  282. EXPORT_SYMBOL(slow_work_enqueue);
  283. /*
  284. * Schedule a cull of the thread pool at some time in the near future
  285. */
  286. static void slow_work_schedule_cull(void)
  287. {
  288. mod_timer(&slow_work_cull_timer,
  289. round_jiffies(jiffies + SLOW_WORK_CULL_TIMEOUT));
  290. }
  291. /*
  292. * Worker thread culling algorithm
  293. */
  294. static bool slow_work_cull_thread(void)
  295. {
  296. unsigned long flags;
  297. bool do_cull = false;
  298. spin_lock_irqsave(&slow_work_queue_lock, flags);
  299. if (slow_work_cull) {
  300. slow_work_cull = false;
  301. if (list_empty(&slow_work_queue) &&
  302. list_empty(&vslow_work_queue) &&
  303. atomic_read(&slow_work_thread_count) >
  304. slow_work_min_threads) {
  305. slow_work_schedule_cull();
  306. do_cull = true;
  307. }
  308. }
  309. spin_unlock_irqrestore(&slow_work_queue_lock, flags);
  310. return do_cull;
  311. }
  312. /*
  313. * Determine if there is slow work available for dispatch
  314. */
  315. static inline bool slow_work_available(int vsmax)
  316. {
  317. return !list_empty(&slow_work_queue) ||
  318. (!list_empty(&vslow_work_queue) &&
  319. atomic_read(&vslow_work_executing_count) < vsmax);
  320. }
  321. /*
  322. * Worker thread dispatcher
  323. */
  324. static int slow_work_thread(void *_data)
  325. {
  326. int vsmax;
  327. DEFINE_WAIT(wait);
  328. set_freezable();
  329. set_user_nice(current, -5);
  330. for (;;) {
  331. vsmax = vslow_work_proportion;
  332. vsmax *= atomic_read(&slow_work_thread_count);
  333. vsmax /= 100;
  334. prepare_to_wait_exclusive(&slow_work_thread_wq, &wait,
  335. TASK_INTERRUPTIBLE);
  336. if (!freezing(current) &&
  337. !slow_work_threads_should_exit &&
  338. !slow_work_available(vsmax) &&
  339. !slow_work_cull)
  340. schedule();
  341. finish_wait(&slow_work_thread_wq, &wait);
  342. try_to_freeze();
  343. vsmax = vslow_work_proportion;
  344. vsmax *= atomic_read(&slow_work_thread_count);
  345. vsmax /= 100;
  346. if (slow_work_available(vsmax) && slow_work_execute()) {
  347. cond_resched();
  348. if (list_empty(&slow_work_queue) &&
  349. list_empty(&vslow_work_queue) &&
  350. atomic_read(&slow_work_thread_count) >
  351. slow_work_min_threads)
  352. slow_work_schedule_cull();
  353. continue;
  354. }
  355. if (slow_work_threads_should_exit)
  356. break;
  357. if (slow_work_cull && slow_work_cull_thread())
  358. break;
  359. }
  360. if (atomic_dec_and_test(&slow_work_thread_count))
  361. complete_and_exit(&slow_work_last_thread_exited, 0);
  362. return 0;
  363. }
  364. /*
  365. * Handle thread cull timer expiration
  366. */
  367. static void slow_work_cull_timeout(unsigned long data)
  368. {
  369. slow_work_cull = true;
  370. wake_up(&slow_work_thread_wq);
  371. }
  372. /*
  373. * Get a reference on slow work thread starter
  374. */
  375. static int slow_work_new_thread_get_ref(struct slow_work *work)
  376. {
  377. return 0;
  378. }
  379. /*
  380. * Drop a reference on slow work thread starter
  381. */
  382. static void slow_work_new_thread_put_ref(struct slow_work *work)
  383. {
  384. }
  385. /*
  386. * Start a new slow work thread
  387. */
  388. static void slow_work_new_thread_execute(struct slow_work *work)
  389. {
  390. struct task_struct *p;
  391. if (slow_work_threads_should_exit)
  392. return;
  393. if (atomic_read(&slow_work_thread_count) >= slow_work_max_threads)
  394. return;
  395. if (!mutex_trylock(&slow_work_user_lock))
  396. return;
  397. slow_work_may_not_start_new_thread = true;
  398. atomic_inc(&slow_work_thread_count);
  399. p = kthread_run(slow_work_thread, NULL, "kslowd");
  400. if (IS_ERR(p)) {
  401. printk(KERN_DEBUG "Slow work thread pool: OOM\n");
  402. if (atomic_dec_and_test(&slow_work_thread_count))
  403. BUG(); /* we're running on a slow work thread... */
  404. mod_timer(&slow_work_oom_timer,
  405. round_jiffies(jiffies + SLOW_WORK_OOM_TIMEOUT));
  406. } else {
  407. /* ratelimit the starting of new threads */
  408. mod_timer(&slow_work_oom_timer, jiffies + 1);
  409. }
  410. mutex_unlock(&slow_work_user_lock);
  411. }
  412. static const struct slow_work_ops slow_work_new_thread_ops = {
  413. .get_ref = slow_work_new_thread_get_ref,
  414. .put_ref = slow_work_new_thread_put_ref,
  415. .execute = slow_work_new_thread_execute,
  416. };
  417. /*
  418. * post-OOM new thread start suppression expiration
  419. */
  420. static void slow_work_oom_timeout(unsigned long data)
  421. {
  422. slow_work_may_not_start_new_thread = false;
  423. }
  424. #ifdef CONFIG_SYSCTL
  425. /*
  426. * Handle adjustment of the minimum number of threads
  427. */
  428. static int slow_work_min_threads_sysctl(struct ctl_table *table, int write,
  429. void __user *buffer,
  430. size_t *lenp, loff_t *ppos)
  431. {
  432. int ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
  433. int n;
  434. if (ret == 0) {
  435. mutex_lock(&slow_work_user_lock);
  436. if (slow_work_user_count > 0) {
  437. /* see if we need to start or stop threads */
  438. n = atomic_read(&slow_work_thread_count) -
  439. slow_work_min_threads;
  440. if (n < 0 && !slow_work_may_not_start_new_thread)
  441. slow_work_enqueue(&slow_work_new_thread);
  442. else if (n > 0)
  443. slow_work_schedule_cull();
  444. }
  445. mutex_unlock(&slow_work_user_lock);
  446. }
  447. return ret;
  448. }
  449. /*
  450. * Handle adjustment of the maximum number of threads
  451. */
  452. static int slow_work_max_threads_sysctl(struct ctl_table *table, int write,
  453. void __user *buffer,
  454. size_t *lenp, loff_t *ppos)
  455. {
  456. int ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
  457. int n;
  458. if (ret == 0) {
  459. mutex_lock(&slow_work_user_lock);
  460. if (slow_work_user_count > 0) {
  461. /* see if we need to stop threads */
  462. n = slow_work_max_threads -
  463. atomic_read(&slow_work_thread_count);
  464. if (n < 0)
  465. slow_work_schedule_cull();
  466. }
  467. mutex_unlock(&slow_work_user_lock);
  468. }
  469. return ret;
  470. }
  471. #endif /* CONFIG_SYSCTL */
  472. /**
  473. * slow_work_register_user - Register a user of the facility
  474. *
  475. * Register a user of the facility, starting up the initial threads if there
  476. * aren't any other users at this point. This will return 0 if successful, or
  477. * an error if not.
  478. */
  479. int slow_work_register_user(void)
  480. {
  481. struct task_struct *p;
  482. int loop;
  483. mutex_lock(&slow_work_user_lock);
  484. if (slow_work_user_count == 0) {
  485. printk(KERN_NOTICE "Slow work thread pool: Starting up\n");
  486. init_completion(&slow_work_last_thread_exited);
  487. slow_work_threads_should_exit = false;
  488. slow_work_init(&slow_work_new_thread,
  489. &slow_work_new_thread_ops);
  490. slow_work_may_not_start_new_thread = false;
  491. slow_work_cull = false;
  492. /* start the minimum number of threads */
  493. for (loop = 0; loop < slow_work_min_threads; loop++) {
  494. atomic_inc(&slow_work_thread_count);
  495. p = kthread_run(slow_work_thread, NULL, "kslowd");
  496. if (IS_ERR(p))
  497. goto error;
  498. }
  499. printk(KERN_NOTICE "Slow work thread pool: Ready\n");
  500. }
  501. slow_work_user_count++;
  502. mutex_unlock(&slow_work_user_lock);
  503. return 0;
  504. error:
  505. if (atomic_dec_and_test(&slow_work_thread_count))
  506. complete(&slow_work_last_thread_exited);
  507. if (loop > 0) {
  508. printk(KERN_ERR "Slow work thread pool:"
  509. " Aborting startup on ENOMEM\n");
  510. slow_work_threads_should_exit = true;
  511. wake_up_all(&slow_work_thread_wq);
  512. wait_for_completion(&slow_work_last_thread_exited);
  513. printk(KERN_ERR "Slow work thread pool: Aborted\n");
  514. }
  515. mutex_unlock(&slow_work_user_lock);
  516. return PTR_ERR(p);
  517. }
  518. EXPORT_SYMBOL(slow_work_register_user);
  519. /**
  520. * slow_work_unregister_user - Unregister a user of the facility
  521. *
  522. * Unregister a user of the facility, killing all the threads if this was the
  523. * last one.
  524. */
  525. void slow_work_unregister_user(void)
  526. {
  527. mutex_lock(&slow_work_user_lock);
  528. BUG_ON(slow_work_user_count <= 0);
  529. slow_work_user_count--;
  530. if (slow_work_user_count == 0) {
  531. printk(KERN_NOTICE "Slow work thread pool: Shutting down\n");
  532. slow_work_threads_should_exit = true;
  533. del_timer_sync(&slow_work_cull_timer);
  534. del_timer_sync(&slow_work_oom_timer);
  535. wake_up_all(&slow_work_thread_wq);
  536. wait_for_completion(&slow_work_last_thread_exited);
  537. printk(KERN_NOTICE "Slow work thread pool:"
  538. " Shut down complete\n");
  539. }
  540. mutex_unlock(&slow_work_user_lock);
  541. }
  542. EXPORT_SYMBOL(slow_work_unregister_user);
  543. /*
  544. * Initialise the slow work facility
  545. */
  546. static int __init init_slow_work(void)
  547. {
  548. unsigned nr_cpus = num_possible_cpus();
  549. if (slow_work_max_threads < nr_cpus)
  550. slow_work_max_threads = nr_cpus;
  551. #ifdef CONFIG_SYSCTL
  552. if (slow_work_max_max_threads < nr_cpus * 2)
  553. slow_work_max_max_threads = nr_cpus * 2;
  554. #endif
  555. return 0;
  556. }
  557. subsys_initcall(init_slow_work);