Skip to content

Commit 74fe02c

Browse files
committed
Merge tag 'wq-for-7.1-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
Pull workqueue fixes from Tejun Heo: - Fix devm_alloc_workqueue() passing a va_list as a positional arg to the variadic alloc_workqueue() macro, which garbled wq->name and skipped lockdep init on the devm path. Fold both noprof entry points onto a va_list helper. Also, annotate it using __printf(1, 0) * tag 'wq-for-7.1-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq: workqueue: Annotate alloc_workqueue_va() with __printf(1, 0) workqueue: fix devm_alloc_workqueue() va_list misuse
2 parents 11f0007 + 20e81c6 commit 74fe02c

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

include/linux/workqueue.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,10 @@ alloc_workqueue_noprof(const char *fmt, unsigned int flags, int max_active, ...)
534534
* Pointer to the allocated workqueue on success, %NULL on failure.
535535
*/
536536
__printf(2, 5) struct workqueue_struct *
537-
devm_alloc_workqueue(struct device *dev, const char *fmt, unsigned int flags,
538-
int max_active, ...);
537+
devm_alloc_workqueue_noprof(struct device *dev, const char *fmt,
538+
unsigned int flags, int max_active, ...);
539+
#define devm_alloc_workqueue(...) \
540+
alloc_hooks(devm_alloc_workqueue_noprof(__VA_ARGS__))
539541

540542
#ifdef CONFIG_LOCKDEP
541543
/**

kernel/workqueue.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5906,6 +5906,21 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt,
59065906
return NULL;
59075907
}
59085908

5909+
__printf(1, 0)
5910+
static struct workqueue_struct *alloc_workqueue_va(const char *fmt,
5911+
unsigned int flags,
5912+
int max_active,
5913+
va_list args)
5914+
{
5915+
struct workqueue_struct *wq;
5916+
5917+
wq = __alloc_workqueue(fmt, flags, max_active, args);
5918+
if (wq)
5919+
wq_init_lockdep(wq);
5920+
5921+
return wq;
5922+
}
5923+
59095924
__printf(1, 4)
59105925
struct workqueue_struct *alloc_workqueue_noprof(const char *fmt,
59115926
unsigned int flags,
@@ -5915,12 +5930,8 @@ struct workqueue_struct *alloc_workqueue_noprof(const char *fmt,
59155930
va_list args;
59165931

59175932
va_start(args, max_active);
5918-
wq = __alloc_workqueue(fmt, flags, max_active, args);
5933+
wq = alloc_workqueue_va(fmt, flags, max_active, args);
59195934
va_end(args);
5920-
if (!wq)
5921-
return NULL;
5922-
5923-
wq_init_lockdep(wq);
59245935

59255936
return wq;
59265937
}
@@ -5932,15 +5943,15 @@ static void devm_workqueue_release(void *res)
59325943
}
59335944

59345945
__printf(2, 5) struct workqueue_struct *
5935-
devm_alloc_workqueue(struct device *dev, const char *fmt, unsigned int flags,
5936-
int max_active, ...)
5946+
devm_alloc_workqueue_noprof(struct device *dev, const char *fmt,
5947+
unsigned int flags, int max_active, ...)
59375948
{
59385949
struct workqueue_struct *wq;
59395950
va_list args;
59405951
int ret;
59415952

59425953
va_start(args, max_active);
5943-
wq = alloc_workqueue(fmt, flags, max_active, args);
5954+
wq = alloc_workqueue_va(fmt, flags, max_active, args);
59445955
va_end(args);
59455956
if (!wq)
59465957
return NULL;
@@ -5951,7 +5962,7 @@ devm_alloc_workqueue(struct device *dev, const char *fmt, unsigned int flags,
59515962

59525963
return wq;
59535964
}
5954-
EXPORT_SYMBOL_GPL(devm_alloc_workqueue);
5965+
EXPORT_SYMBOL_GPL(devm_alloc_workqueue_noprof);
59555966

59565967
#ifdef CONFIG_LOCKDEP
59575968
__printf(1, 5)

0 commit comments

Comments
 (0)