Messages in this thread | | | Date | Mon, 13 Aug 2012 10:03:03 -0700 | From | Tejun Heo <> | Subject | Re: [PATCH 2/5] workqueue: change value of lcpu in queue_delayed_work_on() |
| |
Hello,
On Tue, Aug 14, 2012 at 01:54:22AM +0900, JoonSoo Kim wrote: > wq = WQ_NON_REENTRANT. > queue_delayed_work_on(CPU B) is invoked in CPU A, so lcpu = CPU A, cpu = CPU B. > > In this case, we call add_time_on(CPU B), then delayed_work_timer_fn() > is invoked on CPU B. > delayed_work_timer_fn() calls __queue_work(), then following > comparisons return true! > > gcwq = get_gcwq(cpu); > if (wq->flags & WQ_NON_REENTRANT && > (last_gcwq = get_work_gcwq(work)) && last_gcwq != gcwq) { > > I thinks that if we assign cpu to lcpu, above comparisons return > false, so save some overheads. > Is there any missing part?
Nope, that sound correct to me.
> And, do u mean @cpu is WORK_CPU_UNBOUND?
@cpu could be WORK_CPU_UNBOUND at that point. The timer will be added to local CPU but @work->data would be pointing to WORK_CPU_UNBOUND, again triggering the condition. Given that @cpu being WORK_CPU_UNBOUND is far more common than an actual CPU number, the patch would actually increase spurious nrt lookups. The right thing to do is probably setting cpu to raw_smp_processor_id() beforehand.
Thanks.
-- tejun
| |