Re: [PATCH v2 0/5] mm: support parallel free of memory
From: Tim Chen
Date: Wed Mar 15 2017 - 17:38:40 EST
On Wed, 2017-03-15 at 17:28 +0100, Michal Hocko wrote:
> On Wed 15-03-17 23:44:07, Aaron Lu wrote:
> >
> > On Wed, Mar 15, 2017 at 03:18:14PM +0100, Michal Hocko wrote:
> > >
> > > On Wed 15-03-17 16:59:59, Aaron Lu wrote:
> > > [...]
> > > >
> > > > The proposed parallel free did this: if the process has many pages to be
> > > > freed, accumulate them in these struct mmu_gather_batch(es) one after
> > > > another till 256K pages are accumulated. Then take this singly linked
> > > > list starting from tlb->local.next off struct mmu_gather *tlb and free
> > > > them in a worker thread. The main thread can return to continue zap
> > > > other pages(after freeing pages pointed by tlb->local.pages).
> > > I didn't have a look at the implementation yet but there are two
> > > concerns that raise up from this description. Firstly how are we going
> > > to tune the number of workers. I assume there will be some upper bound
> > > (one of the patch subject mentions debugfs for tuning) and secondly
> > The workers are put in a dedicated workqueue which is introduced in
> > patch 3/5 and the number of workers can be tuned through that workqueue's
> > sysfs interface: max_active.
> I suspect we cannot expect users to tune this. What do you consider a
> reasonable default?
>From Aaron's data, it seems like 4 is a reasonable value for max_active:
max_active:ÂÂÂtime
1ÂÂÂÂÂÂÂÂÂÂÂÂÂ8.9sÂÂÂÂ0.5%
2ÂÂÂÂÂÂÂÂÂÂÂÂÂ5.65sÂÂÂ5.5%
4ÂÂÂÂÂÂÂÂÂÂÂÂÂ4.84sÂÂÂ0.16%
8ÂÂÂÂÂÂÂÂÂÂÂÂÂ4.77sÂÂÂ0.97%
16ÂÂÂÂÂÂÂÂÂÂÂÂ4.85sÂÂÂ0.77%
32ÂÂÂÂÂÂÂÂÂÂÂÂ6.21sÂÂÂ0.46%
> Moreover, and this is a more generic question, is this functionality
> useful in general purpose workloads?
If we are running consecutive batch jobs, this optimization
should help start the next job sooner.
> After all the amount of the work to
> be done is the same we just risk more lock contentions, unexpected CPU
> usage etc. Which workloads will benefit from having exit path faster?
> Â
> >
> > >
> > > if we offload the page freeing to the worker then the original context
> > > can consume much more cpu cycles than it was configured via cpu
> I was not precise here. I meant to say more cpu cycles per time unit
> that it was allowed.
>
> >
> > >
> > > controller. How are we going to handle that? Or is this considered
> > > acceptable?
> > I'll need to think about and take a look at this subject(not familiar
> > with cpu controller).
> the main problem is that kworkers will not belong to the same cpu group
> and so they will not be throttled properly.
You do have a point that this page freeing activities should strive to
affect other threads not in the same cgroup minimally.
On the other hand, we also don't do this throttling of kworkersÂ
today (e.g. pdflush) according to the cgroup it is doing work for.
Thanks.
Tim