Skip to content

Commit ae1296a

Browse files
Lai Jiangshanhtejun
authored andcommitted
workqueue: Move attrs->cpumask out of worker_pool's properties when attrs->affn_strict
Allow more pools can be shared when attrs->affn_strict. Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent e7cc3be commit ae1296a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

include/linux/workqueue.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ struct workqueue_attrs {
185185
* Below fields aren't properties of a worker_pool. They only modify how
186186
* :c:func:`apply_workqueue_attrs` select pools and thus don't
187187
* participate in pool hash calculations or equality comparisons.
188+
*
189+
* If @affn_strict is set, @cpumask isn't a property of a worker_pool
190+
* either.
188191
*/
189192

190193
/**

kernel/workqueue.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4625,6 +4625,8 @@ static void wqattrs_clear_for_pool(struct workqueue_attrs *attrs)
46254625
{
46264626
attrs->affn_scope = WQ_AFFN_NR_TYPES;
46274627
attrs->ordered = false;
4628+
if (attrs->affn_strict)
4629+
cpumask_copy(attrs->cpumask, cpu_possible_mask);
46284630
}
46294631

46304632
/* hash value of the content of @attr */
@@ -4633,11 +4635,12 @@ static u32 wqattrs_hash(const struct workqueue_attrs *attrs)
46334635
u32 hash = 0;
46344636

46354637
hash = jhash_1word(attrs->nice, hash);
4636-
hash = jhash(cpumask_bits(attrs->cpumask),
4637-
BITS_TO_LONGS(nr_cpumask_bits) * sizeof(long), hash);
4638+
hash = jhash_1word(attrs->affn_strict, hash);
46384639
hash = jhash(cpumask_bits(attrs->__pod_cpumask),
46394640
BITS_TO_LONGS(nr_cpumask_bits) * sizeof(long), hash);
4640-
hash = jhash_1word(attrs->affn_strict, hash);
4641+
if (!attrs->affn_strict)
4642+
hash = jhash(cpumask_bits(attrs->cpumask),
4643+
BITS_TO_LONGS(nr_cpumask_bits) * sizeof(long), hash);
46414644
return hash;
46424645
}
46434646

@@ -4647,11 +4650,11 @@ static bool wqattrs_equal(const struct workqueue_attrs *a,
46474650
{
46484651
if (a->nice != b->nice)
46494652
return false;
4650-
if (!cpumask_equal(a->cpumask, b->cpumask))
4653+
if (a->affn_strict != b->affn_strict)
46514654
return false;
46524655
if (!cpumask_equal(a->__pod_cpumask, b->__pod_cpumask))
46534656
return false;
4654-
if (a->affn_strict != b->affn_strict)
4657+
if (!a->affn_strict && !cpumask_equal(a->cpumask, b->cpumask))
46554658
return false;
46564659
return true;
46574660
}

0 commit comments

Comments
 (0)