aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/workqueue.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-04-01 14:23:34 -0400
committerTejun Heo <tj@kernel.org>2013-04-01 14:23:34 -0400
commitecf6881ff349ad8670ec53a7586002d20b5f3b2e (patch)
treee6e288cf5a0a57377434eb9ad1fd4d0260a6f27a /kernel/workqueue.c
parent6029a91829ad2bd876fed78bc088d3469a9dd777 (diff)
workqueue: make workqueue->name[] fixed len
Currently workqueue->name[] is of flexible length. We want to use the flexible field for something more useful and there isn't much benefit in allowing arbitrary name length anyway. Make it fixed len capping at 24 bytes. Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r--kernel/workqueue.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 32b474463053..c8c5838c52c9 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -101,6 +101,8 @@ enum {
101 */ 101 */
102 RESCUER_NICE_LEVEL = -20, 102 RESCUER_NICE_LEVEL = -20,
103 HIGHPRI_NICE_LEVEL = -20, 103 HIGHPRI_NICE_LEVEL = -20,
104
105 WQ_NAME_LEN = 24,
104}; 106};
105 107
106/* 108/*
@@ -252,7 +254,7 @@ struct workqueue_struct {
252#ifdef CONFIG_LOCKDEP 254#ifdef CONFIG_LOCKDEP
253 struct lockdep_map lockdep_map; 255 struct lockdep_map lockdep_map;
254#endif 256#endif
255 char name[]; /* I: workqueue name */ 257 char name[WQ_NAME_LEN]; /* I: workqueue name */
256}; 258};
257 259
258static struct kmem_cache *pwq_cache; 260static struct kmem_cache *pwq_cache;
@@ -3757,17 +3759,12 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt,
3757 struct lock_class_key *key, 3759 struct lock_class_key *key,
3758 const char *lock_name, ...) 3760 const char *lock_name, ...)
3759{ 3761{
3760 va_list args, args1; 3762 va_list args;
3761 struct workqueue_struct *wq; 3763 struct workqueue_struct *wq;
3762 struct pool_workqueue *pwq; 3764 struct pool_workqueue *pwq;
3763 size_t namelen;
3764
3765 /* determine namelen, allocate wq and format name */
3766 va_start(args, lock_name);
3767 va_copy(args1, args);
3768 namelen = vsnprintf(NULL, 0, fmt, args) + 1;
3769 3765
3770 wq = kzalloc(sizeof(*wq) + namelen, GFP_KERNEL); 3766 /* allocate wq and format name */
3767 wq = kzalloc(sizeof(*wq), GFP_KERNEL);
3771 if (!wq) 3768 if (!wq)
3772 return NULL; 3769 return NULL;
3773 3770
@@ -3777,9 +3774,9 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt,
3777 goto err_free_wq; 3774 goto err_free_wq;
3778 } 3775 }
3779 3776
3780 vsnprintf(wq->name, namelen, fmt, args1); 3777 va_start(args, lock_name);
3778 vsnprintf(wq->name, sizeof(wq->name), fmt, args);
3781 va_end(args); 3779 va_end(args);
3782 va_end(args1);
3783 3780
3784 max_active = max_active ?: WQ_DFL_ACTIVE; 3781 max_active = max_active ?: WQ_DFL_ACTIVE;
3785 max_active = wq_clamp_max_active(max_active, flags, wq->name); 3782 max_active = wq_clamp_max_active(max_active, flags, wq->name);