Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

workqueue: Replace pwq_activate_inactive_work() with [__]pwq_activate_work()

To prepare for unbound nr_active handling improvements, move work activation
part of pwq_activate_inactive_work() into __pwq_activate_work() and add
pwq_activate_work() which tests WORK_STRUCT_INACTIVE and updates nr_active.

pwq_activate_first_inactive() and try_to_grab_pending() are updated to use
pwq_activate_work(). The latter conversion is functionally identical. For
the former, this conversion adds an unnecessary WORK_STRUCT_INACTIVE
testing. This is temporary and will be removed by the next patch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Lai Jiangshan <jiangshanlai@gmail.com>

+25 -6
+25 -6
kernel/workqueue.c
··· 1465 1465 return !pwq->nr_active && list_empty(&pwq->inactive_works); 1466 1466 } 1467 1467 1468 - static void pwq_activate_inactive_work(struct work_struct *work) 1468 + static void __pwq_activate_work(struct pool_workqueue *pwq, 1469 + struct work_struct *work) 1469 1470 { 1470 - struct pool_workqueue *pwq = get_work_pwq(work); 1471 - 1472 1471 trace_workqueue_activate_work(work); 1473 1472 if (list_empty(&pwq->pool->worklist)) 1474 1473 pwq->pool->watchdog_ts = jiffies; 1475 1474 move_linked_works(work, &pwq->pool->worklist, NULL); 1476 1475 __clear_bit(WORK_STRUCT_INACTIVE_BIT, work_data_bits(work)); 1476 + } 1477 + 1478 + /** 1479 + * pwq_activate_work - Activate a work item if inactive 1480 + * @pwq: pool_workqueue @work belongs to 1481 + * @work: work item to activate 1482 + * 1483 + * Returns %true if activated. %false if already active. 1484 + */ 1485 + static bool pwq_activate_work(struct pool_workqueue *pwq, 1486 + struct work_struct *work) 1487 + { 1488 + struct worker_pool *pool = pwq->pool; 1489 + 1490 + lockdep_assert_held(&pool->lock); 1491 + 1492 + if (!(*work_data_bits(work) & WORK_STRUCT_INACTIVE)) 1493 + return false; 1494 + 1477 1495 pwq->nr_active++; 1496 + __pwq_activate_work(pwq, work); 1497 + return true; 1478 1498 } 1479 1499 1480 1500 static void pwq_activate_first_inactive(struct pool_workqueue *pwq) ··· 1502 1482 struct work_struct *work = list_first_entry(&pwq->inactive_works, 1503 1483 struct work_struct, entry); 1504 1484 1505 - pwq_activate_inactive_work(work); 1485 + pwq_activate_work(pwq, work); 1506 1486 } 1507 1487 1508 1488 /** ··· 1640 1620 * management later on and cause stall. Make sure the work 1641 1621 * item is activated before grabbing. 1642 1622 */ 1643 - if (*work_data_bits(work) & WORK_STRUCT_INACTIVE) 1644 - pwq_activate_inactive_work(work); 1623 + pwq_activate_work(pwq, work); 1645 1624 1646 1625 list_del_init(&work->entry); 1647 1626 pwq_dec_nr_in_flight(pwq, *work_data_bits(work));