Re: [PATCH v2 17/26] mm/fbatch: no lru_cache_disable() in __alloc_contig_migrate_range()
From: Hugh Dickins
Date: Tue Nov 03 2026 - 04:28:36 EST
On Mon, 2 Nov 2026, Alen Karnil wrote:
> Hi Hugh,
>
> I've come across your series because of a usecase I have, namely this patch.
>
> Not to bore you with details, I got an IMX8MPlus with some cameras.
> Due to the cameras (and other associated HW), it ends up allocating multiple
> framebuffers using CMA (currently 16 per camera)
> which is quite slow (~200ms for a single camera).
>
> I've spent some time profiling and found that the biggest
> stall is when lru_cache_disable() is called. Just applying the patch on its
> own, I saw greatly improved performance (cutting the delay almost 5x).
That's useful information, thanks for trying it and reporting back.
>
> This is on a 7.2 kernel.
>
...
> Can the patch stand on its own?
Yes and no. Yes, you can include it in your own builds if you're finding
it useful: it's not going to cause any corruption or crashes or suchlike.
But without patches 1-9, it does increase the likelihood that, once the
system has been running for a while and memory has become fragmented,
compaction for CMA allocations may fail. It's a temporary failure which
the lru_cache_disable() protects from, and maybe the retries and system
activity would work out, but there is this increased likelihood that your
camera will not work when you need it to. (And I don't know how long
the camera's memory buffer is kept, between uses of the camera.)
So no, I would never recommend this patch for a release, without the
preceding patches of the series.
Hugh
> > ---
> > mm/page_alloc.c | 3 ---
> > 1 file changed, 3 deletions(-)
> >
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 12fac9084c48..3e085a25a776 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -7147,8 +7147,6 @@ static int __alloc_contig_migrate_range(struct
> > compact_control *cc,
> > .reason = MR_CONTIG_RANGE,
> > };
> > - lru_cache_disable();
> > -
> > while (pfn < end || !list_empty(&cc->migratepages)) {
> > if (fatal_signal_pending(current)) {
> > ret = -EINTR;
> > @@ -7182,7 +7180,6 @@ static int __alloc_contig_migrate_range(struct
> > compact_control *cc,
> > break;
> > }
> > - lru_cache_enable();
> > if (ret < 0) {
> > if (!(cc->gfp_mask & __GFP_NOWARN) && ret == -EBUSY)
> > alloc_contig_dump_pages(&cc->migratepages);
>
> --
> Thanks,
> Alen Karnil