[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YejkUlnnYeED1pC5@google.com>
Date: Wed, 19 Jan 2022 20:25:54 -0800
From: Minchan Kim <minchan@...nel.org>
To: Michal Hocko <mhocko@...e.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
David Hildenbrand <david@...hat.com>,
linux-mm <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>,
Suren Baghdasaryan <surenb@...gle.com>,
John Dias <joaodias@...gle.com>
Subject: Re: [RESEND][PATCH v2] mm: don't call lru draining in the nested
lru_cache_disable
On Wed, Jan 19, 2022 at 10:20:22AM +0100, Michal Hocko wrote:
> On Tue 18-01-22 16:12:54, Minchan Kim wrote:
> > On Mon, Jan 17, 2022 at 02:47:06PM +0100, Michal Hocko wrote:
> > > On Thu 30-12-21 11:36:27, Minchan Kim wrote:
> > > > lru_cache_disable involves IPIs to drain pagevec of each core,
> > > > which sometimes takes quite long time to complete depending
> > > > on cpu's business, which makes allocation too slow up to
> > > > sveral hundredth milliseconds. Furthermore, the repeated draining
> > > > in the alloc_contig_range makes thing worse considering caller
> > > > of alloc_contig_range usually tries multiple times in the loop.
> > > >
> > > > This patch makes the lru_cache_disable aware of the fact the
> > > > pagevec was already disabled. With that, user of alloc_contig_range
> > > > can disable the lru cache in advance in their context during the
> > > > repeated trial so they can avoid the multiple costly draining
> > > > in cma allocation.
> > >
> > > Do you have any numbers on any improvements?
> >
> > The LRU draining consumed above 50% overhead for the 20M CMA alloc.
>
> This doesn't say much about the improvement itself.
The improvement is various depending on system state since it's
timing sensitive. Let me try to get it.
>
> > > Now to the change. I do not like this much to be honest. LRU cache
> > > disabling is a complex synchronization scheme implemented in
> > > __lru_add_drain_all now you are stacking another level on top of that.
> > >
> > > More fundamentally though. I am not sure I understand the problem TBH.
> >
> > The problem is that kinds of IPI using normal prority workqueue to drain
> > takes much time depending on the system CPU business.
>
> How does this patch address that problem? The IPI has to happen at some
> point as we need to sync up with pcp caches.
True but the goal is to minimize the IPI overhead. Pleas look at
alloc_contig_range and what happens if it fails with -EBUSY.
The caller usually try again and then alloc_contig_range calls
the drain again. In our workload, it keeps repeated until the
allocation succeeded and the IPI keeps calling. Totally wasted.
>
> > > What prevents you from calling lru_cache_disable at the cma level in the
> > > first place?
> >
> > You meant moving the call from alloc_contig_range to caller layer?
>
> Yes.
>
> > So, virtio_mem_fake_online, too? It could and make sense from
> > performance perspective since upper layer usually calls the
> > alloc_contig_range multiple times on retrial loop.
> >
> > Havid said, semantically, not good in that why upper layer should
> > know how alloc_contig_range works(LRU disable is too low level stuff)
> > internally but I chose the performance here.
> >
> > There is an example why the stacking is needed.
> > cma_alloc also can be called from outside.
> > A usecase is try to call
> >
> > lru_cache_disable
> > for (order = 10; order >= 0; order) {
> > page = cma_alloc(1<<order)
> > if (page)
> > break;
> > }
> > lru_cacne_enable
> >
> > Here, putting the disable lru outside of cma_alloc is
> > much better than inside. That's why I put it outside.
>
> What does prevent you from calling lru_cache_{disable,enable} this way
> with the existing implementation? AFAICS calls can be nested just fine.
> Or am I missing something?
It just increases more IPI calls since we drain the lru cache
both upper layer and lower layer. That's I'd like to avoid
in this patch. Just disable lru cache one time for entire
allocation path.
Powered by blists - more mailing lists