Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 365543
b: refs/heads/master
c: bce9038
h: refs/heads/master
i:
  365541: e3b92c6
  365539: 0940a7b
  365535: 2dea5ca
v: v3
  • Loading branch information
Tejun Heo committed Apr 1, 2013
1 parent 2435251 commit f714cc3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a892cacc7f4960a39c0fad7bbdf04c5cbf7c229e
refs/heads/master: bce903809ab3f29eca97e0be5537778c1689c82b
46 changes: 46 additions & 0 deletions trunk/kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <linux/jhash.h>
#include <linux/hashtable.h>
#include <linux/rculist.h>
#include <linux/nodemask.h>

#include "workqueue_internal.h"

Expand Down Expand Up @@ -253,6 +254,12 @@ struct workqueue_struct {

static struct kmem_cache *pwq_cache;

static int wq_numa_tbl_len; /* highest possible NUMA node id + 1 */
static cpumask_var_t *wq_numa_possible_cpumask;
/* possible CPUs of each node */

static bool wq_numa_enabled; /* unbound NUMA affinity enabled */

static DEFINE_MUTEX(wq_pool_mutex); /* protects pools and workqueues list */
static DEFINE_SPINLOCK(wq_mayday_lock); /* protects wq->maydays list */

Expand Down Expand Up @@ -4407,6 +4414,43 @@ void thaw_workqueues(void)
}
#endif /* CONFIG_FREEZER */

static void __init wq_numa_init(void)
{
cpumask_var_t *tbl;
int node, cpu;

/* determine NUMA pwq table len - highest node id + 1 */
for_each_node(node)
wq_numa_tbl_len = max(wq_numa_tbl_len, node + 1);

if (num_possible_nodes() <= 1)
return;

/*
* We want masks of possible CPUs of each node which isn't readily
* available. Build one from cpu_to_node() which should have been
* fully initialized by now.
*/
tbl = kzalloc(wq_numa_tbl_len * sizeof(tbl[0]), GFP_KERNEL);
BUG_ON(!tbl);

for_each_node(node)
BUG_ON(!alloc_cpumask_var_node(&tbl[node], GFP_KERNEL, node));

for_each_possible_cpu(cpu) {
node = cpu_to_node(cpu);
if (WARN_ON(node == NUMA_NO_NODE)) {
pr_warn("workqueue: NUMA node mapping not available for cpu%d, disabling NUMA support\n", cpu);
/* happens iff arch is bonkers, let's just proceed */
return;
}
cpumask_set_cpu(cpu, tbl[node]);
}

wq_numa_possible_cpumask = tbl;
wq_numa_enabled = true;
}

static int __init init_workqueues(void)
{
int std_nice[NR_STD_WORKER_POOLS] = { 0, HIGHPRI_NICE_LEVEL };
Expand All @@ -4423,6 +4467,8 @@ static int __init init_workqueues(void)
cpu_notifier(workqueue_cpu_up_callback, CPU_PRI_WORKQUEUE_UP);
hotcpu_notifier(workqueue_cpu_down_callback, CPU_PRI_WORKQUEUE_DOWN);

wq_numa_init();

/* initialize CPU pools */
for_each_possible_cpu(cpu) {
struct worker_pool *pool;
Expand Down

0 comments on commit f714cc3

Please sign in to comment.