Skip to content

Commit 49277a5

Browse files
Waiman-Longhtejun
authored andcommitted
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]>
1 parent e76d28b commit 49277a5

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
@@ -4417,19 +4417,6 @@ static void apply_wqattrs_commit(struct apply_wqattrs_ctx *ctx)
44174417
mutex_unlock(&ctx->wq->mutex);
44184418
}
44194419

4420-
static void apply_wqattrs_lock(void)
4421-
{
4422-
/* CPUs should stay stable across pwq creations and installations */
4423-
cpus_read_lock();
4424-
mutex_lock(&wq_pool_mutex);
4425-
}
4426-
4427-
static void apply_wqattrs_unlock(void)
4428-
{
4429-
mutex_unlock(&wq_pool_mutex);
4430-
cpus_read_unlock();
4431-
}
4432-
44334420
static int apply_workqueue_attrs_locked(struct workqueue_struct *wq,
44344421
const struct workqueue_attrs *attrs)
44354422
{
@@ -5833,44 +5820,6 @@ static int workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask)
58335820
return ret;
58345821
}
58355822

5836-
/**
5837-
* workqueue_set_unbound_cpumask - Set the low-level unbound cpumask
5838-
* @cpumask: the cpumask to set
5839-
*
5840-
* The low-level workqueues cpumask is a global cpumask that limits
5841-
* the affinity of all unbound workqueues. This function check the @cpumask
5842-
* and apply it to all unbound workqueues and updates all pwqs of them.
5843-
*
5844-
* Return: 0 - Success
5845-
* -EINVAL - Invalid @cpumask
5846-
* -ENOMEM - Failed to allocate memory for attrs or pwqs.
5847-
*/
5848-
static int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
5849-
{
5850-
int ret = -EINVAL;
5851-
5852-
/*
5853-
* Not excluding isolated cpus on purpose.
5854-
* If the user wishes to include them, we allow that.
5855-
*/
5856-
cpumask_and(cpumask, cpumask, cpu_possible_mask);
5857-
if (!cpumask_empty(cpumask)) {
5858-
apply_wqattrs_lock();
5859-
cpumask_copy(wq_requested_unbound_cpumask, cpumask);
5860-
if (cpumask_equal(cpumask, wq_unbound_cpumask)) {
5861-
ret = 0;
5862-
goto out_unlock;
5863-
}
5864-
5865-
ret = workqueue_apply_unbound_cpumask(cpumask);
5866-
5867-
out_unlock:
5868-
apply_wqattrs_unlock();
5869-
}
5870-
5871-
return ret;
5872-
}
5873-
58745823
/**
58755824
* workqueue_unbound_exclude_cpumask - Exclude given CPUs from unbound cpumask
58765825
* @exclude_cpumask: the cpumask to be excluded from wq_unbound_cpumask
@@ -6027,6 +5976,19 @@ static struct attribute *wq_sysfs_attrs[] = {
60275976
};
60285977
ATTRIBUTE_GROUPS(wq_sysfs);
60295978

5979+
static void apply_wqattrs_lock(void)
5980+
{
5981+
/* CPUs should stay stable across pwq creations and installations */
5982+
cpus_read_lock();
5983+
mutex_lock(&wq_pool_mutex);
5984+
}
5985+
5986+
static void apply_wqattrs_unlock(void)
5987+
{
5988+
mutex_unlock(&wq_pool_mutex);
5989+
cpus_read_unlock();
5990+
}
5991+
60305992
static ssize_t wq_nice_show(struct device *dev, struct device_attribute *attr,
60315993
char *buf)
60325994
{
@@ -6203,6 +6165,44 @@ static struct bus_type wq_subsys = {
62036165
.dev_groups = wq_sysfs_groups,
62046166
};
62056167

6168+
/**
6169+
* workqueue_set_unbound_cpumask - Set the low-level unbound cpumask
6170+
* @cpumask: the cpumask to set
6171+
*
6172+
* The low-level workqueues cpumask is a global cpumask that limits
6173+
* the affinity of all unbound workqueues. This function check the @cpumask
6174+
* and apply it to all unbound workqueues and updates all pwqs of them.
6175+
*
6176+
* Return: 0 - Success
6177+
* -EINVAL - Invalid @cpumask
6178+
* -ENOMEM - Failed to allocate memory for attrs or pwqs.
6179+
*/
6180+
static int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
6181+
{
6182+
int ret = -EINVAL;
6183+
6184+
/*
6185+
* Not excluding isolated cpus on purpose.
6186+
* If the user wishes to include them, we allow that.
6187+
*/
6188+
cpumask_and(cpumask, cpumask, cpu_possible_mask);
6189+
if (!cpumask_empty(cpumask)) {
6190+
apply_wqattrs_lock();
6191+
cpumask_copy(wq_requested_unbound_cpumask, cpumask);
6192+
if (cpumask_equal(cpumask, wq_unbound_cpumask)) {
6193+
ret = 0;
6194+
goto out_unlock;
6195+
}
6196+
6197+
ret = workqueue_apply_unbound_cpumask(cpumask);
6198+
6199+
out_unlock:
6200+
apply_wqattrs_unlock();
6201+
}
6202+
6203+
return ret;
6204+
}
6205+
62066206
static ssize_t __wq_cpumask_show(struct device *dev,
62076207
struct device_attribute *attr, char *buf, cpumask_var_t mask)
62086208
{

0 commit comments

Comments
 (0)