Skip to content

Commit f97a4a1

Browse files
Lai Jiangshanhtejun
authored andcommitted
workqueue: Rename "delayed" (delayed by active management) to "inactive"
There are two kinds of "delayed" work items in workqueue subsystem. One is for timer-delayed work items which are visible to workqueue users. The other kind is for work items delayed by active management which can not be directly visible to workqueue users. We mixed the word "delayed" for both kinds and caused somewhat ambiguity. This patch renames the later one (delayed by active management) to "inactive", because it is used for workqueue active management and most of its related symbols are named with "active" or "activate". All "delayed" and "DELAYED" are carefully checked and renamed one by one to avoid accidentally changing the name of the other kind for timer-delayed. No functional change intended. Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent ffd8bea commit f97a4a1

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

include/linux/workqueue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void delayed_work_timer_fn(struct timer_list *t);
2929

3030
enum {
3131
WORK_STRUCT_PENDING_BIT = 0, /* work item is pending execution */
32-
WORK_STRUCT_DELAYED_BIT = 1, /* work item is delayed */
32+
WORK_STRUCT_INACTIVE_BIT= 1, /* work item is inactive */
3333
WORK_STRUCT_PWQ_BIT = 2, /* data points to pwq */
3434
WORK_STRUCT_LINKED_BIT = 3, /* next work is linked to this one */
3535
#ifdef CONFIG_DEBUG_OBJECTS_WORK
@@ -42,7 +42,7 @@ enum {
4242
WORK_STRUCT_COLOR_BITS = 4,
4343

4444
WORK_STRUCT_PENDING = 1 << WORK_STRUCT_PENDING_BIT,
45-
WORK_STRUCT_DELAYED = 1 << WORK_STRUCT_DELAYED_BIT,
45+
WORK_STRUCT_INACTIVE = 1 << WORK_STRUCT_INACTIVE_BIT,
4646
WORK_STRUCT_PWQ = 1 << WORK_STRUCT_PWQ_BIT,
4747
WORK_STRUCT_LINKED = 1 << WORK_STRUCT_LINKED_BIT,
4848
#ifdef CONFIG_DEBUG_OBJECTS_WORK

kernel/workqueue.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ struct pool_workqueue {
207207
/* L: nr of in_flight works */
208208
int nr_active; /* L: nr of active works */
209209
int max_active; /* L: max active works */
210-
struct list_head delayed_works; /* L: delayed works */
210+
struct list_head inactive_works; /* L: inactive works */
211211
struct list_head pwqs_node; /* WR: node on wq->pwqs */
212212
struct list_head mayday_node; /* MD: node on wq->maydays */
213213

@@ -1136,24 +1136,24 @@ static void put_pwq_unlocked(struct pool_workqueue *pwq)
11361136
}
11371137
}
11381138

1139-
static void pwq_activate_delayed_work(struct work_struct *work)
1139+
static void pwq_activate_inactive_work(struct work_struct *work)
11401140
{
11411141
struct pool_workqueue *pwq = get_work_pwq(work);
11421142

11431143
trace_workqueue_activate_work(work);
11441144
if (list_empty(&pwq->pool->worklist))
11451145
pwq->pool->watchdog_ts = jiffies;
11461146
move_linked_works(work, &pwq->pool->worklist, NULL);
1147-
__clear_bit(WORK_STRUCT_DELAYED_BIT, work_data_bits(work));
1147+
__clear_bit(WORK_STRUCT_INACTIVE_BIT, work_data_bits(work));
11481148
pwq->nr_active++;
11491149
}
11501150

1151-
static void pwq_activate_first_delayed(struct pool_workqueue *pwq)
1151+
static void pwq_activate_first_inactive(struct pool_workqueue *pwq)
11521152
{
1153-
struct work_struct *work = list_first_entry(&pwq->delayed_works,
1153+
struct work_struct *work = list_first_entry(&pwq->inactive_works,
11541154
struct work_struct, entry);
11551155

1156-
pwq_activate_delayed_work(work);
1156+
pwq_activate_inactive_work(work);
11571157
}
11581158

11591159
/**
@@ -1176,10 +1176,10 @@ static void pwq_dec_nr_in_flight(struct pool_workqueue *pwq, int color)
11761176
pwq->nr_in_flight[color]--;
11771177

11781178
pwq->nr_active--;
1179-
if (!list_empty(&pwq->delayed_works)) {
1180-
/* one down, submit a delayed one */
1179+
if (!list_empty(&pwq->inactive_works)) {
1180+
/* one down, submit an inactive one */
11811181
if (pwq->nr_active < pwq->max_active)
1182-
pwq_activate_first_delayed(pwq);
1182+
pwq_activate_first_inactive(pwq);
11831183
}
11841184

11851185
/* is flush in progress and are we at the flushing tip? */
@@ -1281,14 +1281,14 @@ static int try_to_grab_pending(struct work_struct *work, bool is_dwork,
12811281
debug_work_deactivate(work);
12821282

12831283
/*
1284-
* A delayed work item cannot be grabbed directly because
1284+
* An inactive work item cannot be grabbed directly because
12851285
* it might have linked NO_COLOR work items which, if left
1286-
* on the delayed_list, will confuse pwq->nr_active
1286+
* on the inactive_works list, will confuse pwq->nr_active
12871287
* management later on and cause stall. Make sure the work
12881288
* item is activated before grabbing.
12891289
*/
1290-
if (*work_data_bits(work) & WORK_STRUCT_DELAYED)
1291-
pwq_activate_delayed_work(work);
1290+
if (*work_data_bits(work) & WORK_STRUCT_INACTIVE)
1291+
pwq_activate_inactive_work(work);
12921292

12931293
list_del_init(&work->entry);
12941294
pwq_dec_nr_in_flight(pwq, get_work_color(work));
@@ -1490,8 +1490,8 @@ static void __queue_work(int cpu, struct workqueue_struct *wq,
14901490
if (list_empty(worklist))
14911491
pwq->pool->watchdog_ts = jiffies;
14921492
} else {
1493-
work_flags |= WORK_STRUCT_DELAYED;
1494-
worklist = &pwq->delayed_works;
1493+
work_flags |= WORK_STRUCT_INACTIVE;
1494+
worklist = &pwq->inactive_works;
14951495
}
14961496

14971497
debug_work_activate(work);
@@ -2530,7 +2530,7 @@ static int rescuer_thread(void *__rescuer)
25302530
/*
25312531
* The above execution of rescued work items could
25322532
* have created more to rescue through
2533-
* pwq_activate_first_delayed() or chained
2533+
* pwq_activate_first_inactive() or chained
25342534
* queueing. Let's put @pwq back on mayday list so
25352535
* that such back-to-back work items, which may be
25362536
* being used to relieve memory pressure, don't
@@ -2956,7 +2956,7 @@ void drain_workqueue(struct workqueue_struct *wq)
29562956
bool drained;
29572957

29582958
raw_spin_lock_irq(&pwq->pool->lock);
2959-
drained = !pwq->nr_active && list_empty(&pwq->delayed_works);
2959+
drained = !pwq->nr_active && list_empty(&pwq->inactive_works);
29602960
raw_spin_unlock_irq(&pwq->pool->lock);
29612961

29622962
if (drained)
@@ -3712,7 +3712,7 @@ static void pwq_unbound_release_workfn(struct work_struct *work)
37123712
* @pwq: target pool_workqueue
37133713
*
37143714
* If @pwq isn't freezing, set @pwq->max_active to the associated
3715-
* workqueue's saved_max_active and activate delayed work items
3715+
* workqueue's saved_max_active and activate inactive work items
37163716
* accordingly. If @pwq is freezing, clear @pwq->max_active to zero.
37173717
*/
37183718
static void pwq_adjust_max_active(struct pool_workqueue *pwq)
@@ -3741,9 +3741,9 @@ static void pwq_adjust_max_active(struct pool_workqueue *pwq)
37413741

37423742
pwq->max_active = wq->saved_max_active;
37433743

3744-
while (!list_empty(&pwq->delayed_works) &&
3744+
while (!list_empty(&pwq->inactive_works) &&
37453745
pwq->nr_active < pwq->max_active) {
3746-
pwq_activate_first_delayed(pwq);
3746+
pwq_activate_first_inactive(pwq);
37473747
kick = true;
37483748
}
37493749

@@ -3774,7 +3774,7 @@ static void init_pwq(struct pool_workqueue *pwq, struct workqueue_struct *wq,
37743774
pwq->wq = wq;
37753775
pwq->flush_color = -1;
37763776
pwq->refcnt = 1;
3777-
INIT_LIST_HEAD(&pwq->delayed_works);
3777+
INIT_LIST_HEAD(&pwq->inactive_works);
37783778
INIT_LIST_HEAD(&pwq->pwqs_node);
37793779
INIT_LIST_HEAD(&pwq->mayday_node);
37803780
INIT_WORK(&pwq->unbound_release_work, pwq_unbound_release_workfn);
@@ -4361,7 +4361,7 @@ static bool pwq_busy(struct pool_workqueue *pwq)
43614361

43624362
if ((pwq != pwq->wq->dfl_pwq) && (pwq->refcnt > 1))
43634363
return true;
4364-
if (pwq->nr_active || !list_empty(&pwq->delayed_works))
4364+
if (pwq->nr_active || !list_empty(&pwq->inactive_works))
43654365
return true;
43664366

43674367
return false;
@@ -4557,7 +4557,7 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq)
45574557
else
45584558
pwq = unbound_pwq_by_node(wq, cpu_to_node(cpu));
45594559

4560-
ret = !list_empty(&pwq->delayed_works);
4560+
ret = !list_empty(&pwq->inactive_works);
45614561
preempt_enable();
45624562
rcu_read_unlock();
45634563

@@ -4753,11 +4753,11 @@ static void show_pwq(struct pool_workqueue *pwq)
47534753
pr_cont("\n");
47544754
}
47554755

4756-
if (!list_empty(&pwq->delayed_works)) {
4756+
if (!list_empty(&pwq->inactive_works)) {
47574757
bool comma = false;
47584758

4759-
pr_info(" delayed:");
4760-
list_for_each_entry(work, &pwq->delayed_works, entry) {
4759+
pr_info(" inactive:");
4760+
list_for_each_entry(work, &pwq->inactive_works, entry) {
47614761
pr_cont_work(comma, work);
47624762
comma = !(*work_data_bits(work) & WORK_STRUCT_LINKED);
47634763
}
@@ -4787,7 +4787,7 @@ void show_workqueue_state(void)
47874787
bool idle = true;
47884788

47894789
for_each_pwq(pwq, wq) {
4790-
if (pwq->nr_active || !list_empty(&pwq->delayed_works)) {
4790+
if (pwq->nr_active || !list_empty(&pwq->inactive_works)) {
47914791
idle = false;
47924792
break;
47934793
}
@@ -4799,7 +4799,7 @@ void show_workqueue_state(void)
47994799

48004800
for_each_pwq(pwq, wq) {
48014801
raw_spin_lock_irqsave(&pwq->pool->lock, flags);
4802-
if (pwq->nr_active || !list_empty(&pwq->delayed_works))
4802+
if (pwq->nr_active || !list_empty(&pwq->inactive_works))
48034803
show_pwq(pwq);
48044804
raw_spin_unlock_irqrestore(&pwq->pool->lock, flags);
48054805
/*
@@ -5182,7 +5182,7 @@ EXPORT_SYMBOL_GPL(work_on_cpu_safe);
51825182
* freeze_workqueues_begin - begin freezing workqueues
51835183
*
51845184
* Start freezing workqueues. After this function returns, all freezable
5185-
* workqueues will queue new works to their delayed_works list instead of
5185+
* workqueues will queue new works to their inactive_works list instead of
51865186
* pool->worklist.
51875187
*
51885188
* CONTEXT:

0 commit comments

Comments
 (0)