[kernel/workqueue.c] Unnecessary WORK_OFFQ_POOL_NONE in the worker_pool_assign_id(), idr_alloc().
Commit Message
When determining worker_pool->id using idr_alloc() in the
worker_pool_assign_id() function,
I think You need not to pass WORK_OFFQ_POOL_NONE to the idr_alloc() function.
This is because the idr_alloc() function checks the maximum value of
id as INT_MAX.
WORK_OFFQ_POOL_NONE is equivalent to INT_MAX.
So, I think Any code related to WORK_OFFQ_POOL_NONE is not needed.
static int worker_pool_assign_id(struct worker_pool *pool)
@@ -555,8 +555,7 @@ static int worker_pool_assign_id(struct worker_pool *pool)
lockdep_assert_held(&wq_pool_mutex);
- ret = idr_alloc(&worker_pool_idr, pool, 0, WORK_OFFQ_POOL_NONE,
- GFP_KERNEL);
+ ret = idr_alloc(&worker_pool_idr, pool, 0, 0, GFP_KERNEL);
if (ret >= 0) {
pool->id = ret;
return 0;
@@ -735,8 +734,6 @@ static struct worker_pool *get_work_pool(struct
work_struct *work)
(data & WORK_STRUCT_WQ_DATA_MASK))->pool;
pool_id = data >> WORK_OFFQ_POOL_SHIFT;
- if (pool_id == WORK_OFFQ_POOL_NONE)
- return NULL;
return idr_find(&worker_pool_idr, pool_id);
}
Please check the above.
Thanks,
From JaeJoon Jung.
@@ -79,7 +79,6 @@ enum {
WORK_OFFQ_POOL_SHIFT = WORK_OFFQ_FLAG_BASE + WORK_OFFQ_FLAG_BITS,
WORK_OFFQ_LEFT = BITS_PER_LONG - WORK_OFFQ_POOL_SHIFT,
WORK_OFFQ_POOL_BITS = WORK_OFFQ_LEFT <= 31 ? WORK_OFFQ_LEFT : 31,
- WORK_OFFQ_POOL_NONE = (1LU << WORK_OFFQ_POOL_BITS) - 1,
/* convenience constants */
WORK_STRUCT_FLAG_MASK = (1UL << WORK_STRUCT_FLAG_BITS) - 1,
@@ -546,7 +546,7 @@ static inline void debug_work_deactivate(struct
work_struct *work) { }
* worker_pool_assign_id - allocate ID and assign it to @pool
* @pool: the pool pointer of interest
*
- * Returns 0 if ID in [0, WORK_OFFQ_POOL_NONE) is allocated and assigned
+ * Returns 0 if ID in [0, INT_MAX) is allocated and assigned
* successfully, -errno on failure.
*/