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.

Merge tag 'wq-for-6.11-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq

Pull workqueue fixes from Tejun Heo:
"Nothing too interesting. One patch to remove spurious warning and
others to address static checker warnings"

* tag 'wq-for-6.11-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
workqueue: Correct declaration of cpu_pwq in struct workqueue_struct
workqueue: Fix spruious data race in __flush_work()
workqueue: Remove incorrect "WARN_ON_ONCE(!list_empty(&worker->entry));" from dying worker
workqueue: Fix UBSAN 'subtraction overflow' error in shift_and_mask()
workqueue: doc: Fix function name, remove markers

+28 -24
+1 -1
Documentation/core-api/workqueue.rst
··· 260 260 is in flight at any given time and the work items are processed in 261 261 queueing order. While the combination of ``@max_active`` of 1 and 262 262 ``WQ_UNBOUND`` used to achieve this behavior, this is no longer the 263 - case. Use ``alloc_ordered_queue()`` instead. 263 + case. Use alloc_ordered_workqueue() instead. 264 264 265 265 266 266 Example Execution Scenarios
+27 -23
kernel/workqueue.c
··· 377 377 378 378 /* hot fields used during command issue, aligned to cacheline */ 379 379 unsigned int flags ____cacheline_aligned; /* WQ: WQ_* flags */ 380 - struct pool_workqueue __percpu __rcu **cpu_pwq; /* I: per-cpu pwqs */ 380 + struct pool_workqueue __rcu * __percpu *cpu_pwq; /* I: per-cpu pwqs */ 381 381 struct wq_node_nr_active *node_nr_active[]; /* I: per-node nr_active */ 382 382 }; 383 383 ··· 897 897 898 898 static unsigned long shift_and_mask(unsigned long v, u32 shift, u32 bits) 899 899 { 900 - return (v >> shift) & ((1 << bits) - 1); 900 + return (v >> shift) & ((1U << bits) - 1); 901 901 } 902 902 903 903 static void work_offqd_unpack(struct work_offq_data *offqd, unsigned long data) ··· 3351 3351 set_pf_worker(false); 3352 3352 3353 3353 ida_free(&pool->worker_ida, worker->id); 3354 - WARN_ON_ONCE(!list_empty(&worker->entry)); 3355 3354 return 0; 3356 3355 } 3357 3356 ··· 4166 4167 static bool __flush_work(struct work_struct *work, bool from_cancel) 4167 4168 { 4168 4169 struct wq_barrier barr; 4169 - unsigned long data; 4170 4170 4171 4171 if (WARN_ON(!wq_online)) 4172 4172 return false; ··· 4183 4185 * was queued on a BH workqueue, we also know that it was running in the 4184 4186 * BH context and thus can be busy-waited. 4185 4187 */ 4186 - data = *work_data_bits(work); 4187 - if (from_cancel && 4188 - !WARN_ON_ONCE(data & WORK_STRUCT_PWQ) && (data & WORK_OFFQ_BH)) { 4189 - /* 4190 - * On RT, prevent a live lock when %current preempted soft 4191 - * interrupt processing or prevents ksoftirqd from running by 4192 - * keeping flipping BH. If the BH work item runs on a different 4193 - * CPU then this has no effect other than doing the BH 4194 - * disable/enable dance for nothing. This is copied from 4195 - * kernel/softirq.c::tasklet_unlock_spin_wait(). 4196 - */ 4197 - while (!try_wait_for_completion(&barr.done)) { 4198 - if (IS_ENABLED(CONFIG_PREEMPT_RT)) { 4199 - local_bh_disable(); 4200 - local_bh_enable(); 4201 - } else { 4202 - cpu_relax(); 4188 + if (from_cancel) { 4189 + unsigned long data = *work_data_bits(work); 4190 + 4191 + if (!WARN_ON_ONCE(data & WORK_STRUCT_PWQ) && 4192 + (data & WORK_OFFQ_BH)) { 4193 + /* 4194 + * On RT, prevent a live lock when %current preempted 4195 + * soft interrupt processing or prevents ksoftirqd from 4196 + * running by keeping flipping BH. If the BH work item 4197 + * runs on a different CPU then this has no effect other 4198 + * than doing the BH disable/enable dance for nothing. 4199 + * This is copied from 4200 + * kernel/softirq.c::tasklet_unlock_spin_wait(). 4201 + */ 4202 + while (!try_wait_for_completion(&barr.done)) { 4203 + if (IS_ENABLED(CONFIG_PREEMPT_RT)) { 4204 + local_bh_disable(); 4205 + local_bh_enable(); 4206 + } else { 4207 + cpu_relax(); 4208 + } 4203 4209 } 4210 + goto out_destroy; 4204 4211 } 4205 - } else { 4206 - wait_for_completion(&barr.done); 4207 4212 } 4208 4213 4214 + wait_for_completion(&barr.done); 4215 + 4216 + out_destroy: 4209 4217 destroy_work_on_stack(&barr.work); 4210 4218 return true; 4211 4219 }