Skip to content

Commit 6524bc7

Browse files
committed
workqueue: Move workqueue_set_unbound_cpumask() and its helpers inside CONFIG_SYSFS
JIRA: https://issues.redhat.com/browse/RHEL-21798 Conflicts: A minor context diff due to missing upstream commit fcecfa8 ("workqueue: Remove module param disable_numa and sysfs knobs pool_ids and numa"). commit 49277a5 Author: Waiman Long <[email protected]> Date: Mon, 20 Nov 2023 21:18:40 -0500 workqueue: Move workqueue_set_unbound_cpumask() and its helpers inside CONFIG_SYSFS Commit fe28f63 ("workqueue: Add workqueue_unbound_exclude_cpumask() to exclude CPUs from wq_unbound_cpumask") makes workqueue_set_unbound_cpumask() static as it is not used elsewhere in the kernel. However, this triggers a kernel test robot warning about 'workqueue_set_unbound_cpumask' defined but not used when CONFIG_SYS isn't defined. It happens that workqueue_set_unbound_cpumask() is only called when CONFIG_SYS is defined. Move workqueue_set_unbound_cpumask() and its helpers inside the CONFIG_SYSFS compilation block to avoid the warning. There is no functional change. Fixes: fe28f63 ("workqueue: Add workqueue_unbound_exclude_cpumask() to exclude CPUs from wq_unbound_cpumask") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]> Signed-off-by: Waiman Long <[email protected]>
1 parent 24be7e3 commit 6524bc7

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed

kernel/workqueue.c

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4158,19 +4158,6 @@ static void apply_wqattrs_commit(struct apply_wqattrs_ctx *ctx)
41584158
mutex_unlock(&ctx->wq->mutex);
41594159
}
41604160

4161-
static void apply_wqattrs_lock(void)
4162-
{
4163-
/* CPUs should stay stable across pwq creations and installations */
4164-
cpus_read_lock();
4165-
mutex_lock(&wq_pool_mutex);
4166-
}
4167-
4168-
static void apply_wqattrs_unlock(void)
4169-
{
4170-
mutex_unlock(&wq_pool_mutex);
4171-
cpus_read_unlock();
4172-
}
4173-
41744161
static int apply_workqueue_attrs_locked(struct workqueue_struct *wq,
41754162
const struct workqueue_attrs *attrs)
41764163
{
@@ -5488,44 +5475,6 @@ static int workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask)
54885475
return ret;
54895476
}
54905477

5491-
/**
5492-
* workqueue_set_unbound_cpumask - Set the low-level unbound cpumask
5493-
* @cpumask: the cpumask to set
5494-
*
5495-
* The low-level workqueues cpumask is a global cpumask that limits
5496-
* the affinity of all unbound workqueues. This function check the @cpumask
5497-
* and apply it to all unbound workqueues and updates all pwqs of them.
5498-
*
5499-
* Return: 0 - Success
5500-
* -EINVAL - Invalid @cpumask
5501-
* -ENOMEM - Failed to allocate memory for attrs or pwqs.
5502-
*/
5503-
static int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
5504-
{
5505-
int ret = -EINVAL;
5506-
5507-
/*
5508-
* Not excluding isolated cpus on purpose.
5509-
* If the user wishes to include them, we allow that.
5510-
*/
5511-
cpumask_and(cpumask, cpumask, cpu_possible_mask);
5512-
if (!cpumask_empty(cpumask)) {
5513-
apply_wqattrs_lock();
5514-
cpumask_copy(wq_requested_unbound_cpumask, cpumask);
5515-
if (cpumask_equal(cpumask, wq_unbound_cpumask)) {
5516-
ret = 0;
5517-
goto out_unlock;
5518-
}
5519-
5520-
ret = workqueue_apply_unbound_cpumask(cpumask);
5521-
5522-
out_unlock:
5523-
apply_wqattrs_unlock();
5524-
}
5525-
5526-
return ret;
5527-
}
5528-
55295478
/**
55305479
* workqueue_unbound_exclude_cpumask - Exclude given CPUs from unbound cpumask
55315480
* @exclude_cpumask: the cpumask to be excluded from wq_unbound_cpumask
@@ -5653,6 +5602,19 @@ static ssize_t wq_pool_ids_show(struct device *dev,
56535602
return written;
56545603
}
56555604

5605+
static void apply_wqattrs_lock(void)
5606+
{
5607+
/* CPUs should stay stable across pwq creations and installations */
5608+
cpus_read_lock();
5609+
mutex_lock(&wq_pool_mutex);
5610+
}
5611+
5612+
static void apply_wqattrs_unlock(void)
5613+
{
5614+
mutex_unlock(&wq_pool_mutex);
5615+
cpus_read_unlock();
5616+
}
5617+
56565618
static ssize_t wq_nice_show(struct device *dev, struct device_attribute *attr,
56575619
char *buf)
56585620
{
@@ -5795,6 +5757,44 @@ static struct bus_type wq_subsys = {
57955757
.dev_groups = wq_sysfs_groups,
57965758
};
57975759

5760+
/**
5761+
* workqueue_set_unbound_cpumask - Set the low-level unbound cpumask
5762+
* @cpumask: the cpumask to set
5763+
*
5764+
* The low-level workqueues cpumask is a global cpumask that limits
5765+
* the affinity of all unbound workqueues. This function check the @cpumask
5766+
* and apply it to all unbound workqueues and updates all pwqs of them.
5767+
*
5768+
* Return: 0 - Success
5769+
* -EINVAL - Invalid @cpumask
5770+
* -ENOMEM - Failed to allocate memory for attrs or pwqs.
5771+
*/
5772+
static int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
5773+
{
5774+
int ret = -EINVAL;
5775+
5776+
/*
5777+
* Not excluding isolated cpus on purpose.
5778+
* If the user wishes to include them, we allow that.
5779+
*/
5780+
cpumask_and(cpumask, cpumask, cpu_possible_mask);
5781+
if (!cpumask_empty(cpumask)) {
5782+
apply_wqattrs_lock();
5783+
cpumask_copy(wq_requested_unbound_cpumask, cpumask);
5784+
if (cpumask_equal(cpumask, wq_unbound_cpumask)) {
5785+
ret = 0;
5786+
goto out_unlock;
5787+
}
5788+
5789+
ret = workqueue_apply_unbound_cpumask(cpumask);
5790+
5791+
out_unlock:
5792+
apply_wqattrs_unlock();
5793+
}
5794+
5795+
return ret;
5796+
}
5797+
57985798
static ssize_t __wq_cpumask_show(struct device *dev,
57995799
struct device_attribute *attr, char *buf, cpumask_var_t mask)
58005800
{

0 commit comments

Comments
 (0)