On Tue, Apr 26, 2011 at 5:31 PM, KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote: > On Tue, 26 Apr 2011 16:19:41 -0700 > Ying Han <yinghan@xxxxxxxxxx> wrote: > >> On Mon, Apr 25, 2011 at 2:42 AM, KAMEZAWA Hiroyuki < >> kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote: > >> > @@ -3661,6 +3683,67 @@ unsigned long mem_cgroup_soft_limit_recl >> > return nr_reclaimed; >> > } >> > >> > +struct workqueue_struct *memcg_bgreclaimq; >> > + >> > +static int memcg_bgreclaim_init(void) >> > +{ >> > + /* >> > + * use UNBOUND workqueue because we traverse nodes (no locality) >> > and >> > + * the work is cpu-intensive. >> > + */ >> > + memcg_bgreclaimq = alloc_workqueue("memcg", >> > + WQ_MEM_RECLAIM | WQ_UNBOUND | WQ_FREEZABLE, 0); >> > + return 0; >> > +} >> > >> >> I read about the documentation of workqueue. So the WQ_UNBOUND support the >> max 512 execution contexts per CPU. Does the execution context means thread? >> >> I think I understand the motivation of that flag, so we can have more >> concurrency of bg reclaim workitems. But one question is on the workqueue >> scheduling mechanism. If we can queue the item anywhere as long as they are >> inserted in the queue, do we have mechanism to support the load balancing >> like the system scheduler? The scenario I am thinking is that one CPU has >> 512 work items and the other one has 1. >> > IIUC, UNBOUND workqueue doesn't have cpumask and it can be scheduled anywhere. > So, scheduler's load balancing works well. > > Because unbound_gcwq_nr_running == 0 always (If I believe comment on source), > __need_more_worker() always returns true and > need_to_create_worker() returns true if no idle thread. > > Then, I think new kthread is created always if there is a work. Ah, ok. Then this works better than I thought, so we can use the scheduler to put threads onto the CPUs. > > I wonder I shoud use WQ_CPU_INTENSIVE and spread jobs to each cpu per memcg. But > I don't see problem with UNBOUND wq, yet. I think the UNBOUND is good to start with. > > >> I don't think this is directly related issue for this patch, and I just hope >> the workqueue mechanism already support something like that for load >> balancing. >> > If not, we can add it. So, you might already answered my question. The load balancing is done by the system scheduler since we fork new thread for the queued items. --Ying > > Thanks, > -Kame > > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxxx For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href