linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Dong Aisheng <dongas86@gmail.com>
Cc: Dong Aisheng <aisheng.dong@nxp.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, shawnguo@kernel.org,
	linux-imx@nxp.com, m.szyprowski@samsung.com,
	lecopzer.chen@mediatek.com, david@redhat.com, vbabka@suse.cz,
	stable@vger.kernel.org, shijie.qin@nxp.com
Subject: Re: [PATCH v3 1/2] mm: cma: fix allocation may fail sometimes
Date: Wed, 16 Mar 2022 14:09:04 -0700	[thread overview]
Message-ID: <20220316140904.513fe0e8180b4e3fcad24e3b@linux-foundation.org> (raw)
In-Reply-To: <CAA+hA=Ss=YBt-3f=r1BL1NuO7FK56kTf31zWzNjMBkAKQE41Rg@mail.gmail.com>

On Wed, 16 Mar 2022 11:41:37 +0800 Dong Aisheng <dongas86@gmail.com> wrote:

> On Wed, Mar 16, 2022 at 6:58 AM Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > On Tue, 15 Mar 2022 22:45:20 +0800 Dong Aisheng <aisheng.dong@nxp.com> wrote:
> >
> > > --- a/mm/cma.c
> > > +++ b/mm/cma.c
> > >
> > > ...
> > >
> > > @@ -457,6 +458,16 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
> > >                               offset);
> > >               if (bitmap_no >= bitmap_maxno) {
> > >                       spin_unlock_irq(&cma->lock);
> > > +                     pr_debug("%s(): alloc fail, retry loop %d\n", __func__, loop++);
> > > +                     /*
> > > +                      * rescan as others may finish the memory migration
> > > +                      * and quit if no available CMA memory found finally
> > > +                      */
> > > +                     if (start) {
> > > +                             schedule();
> > > +                             start = 0;
> > > +                             continue;
> > > +                     }
> > >                       break;
> >
> > The schedule() is problematic. For a start, we'd normally use
> > cond_resched() here, so we avoid calling the more expensive schedule()
> > if we know it won't perform any action.
> >
> > But cond_resched() is problematic if this thread has realtime
> > scheduling policy and the process we're waiting on does not.  One way
> > to address that is to use an unconditional msleep(1), but that's still
> > just a hack.
> >
> 
> I think we can simply drop schedule() here during the second round of retry
> as the estimated delay may not be really needed.

That will simply cause a tight loop, so I'm obviously not understanding
the proposal.



  reply	other threads:[~2022-03-16 21:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 14:45 [PATCH v3 0/2] mm: fix cma allocation " Dong Aisheng
2022-03-15 14:45 ` [PATCH v3 1/2] mm: cma: fix allocation may " Dong Aisheng
2022-03-15 22:58   ` Andrew Morton
2022-03-16  3:41     ` Dong Aisheng
2022-03-16 21:09       ` Andrew Morton [this message]
2022-03-17  3:49         ` Dong Aisheng
2022-03-17 10:55   ` David Hildenbrand
2022-03-17 14:26     ` Dong Aisheng
2022-03-17 17:12       ` Minchan Kim
2022-03-18  3:43         ` Dong Aisheng
2022-03-18 16:20           ` Minchan Kim
2022-05-04 15:52             ` Dong Aisheng
2022-05-04 23:25               ` Minchan Kim
2022-03-15 14:45 ` [PATCH v3 2/2] mm: cma: try next MAX_ORDER_NR_PAGES during retry Dong Aisheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220316140904.513fe0e8180b4e3fcad24e3b@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=aisheng.dong@nxp.com \
    --cc=david@redhat.com \
    --cc=dongas86@gmail.com \
    --cc=lecopzer.chen@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=m.szyprowski@samsung.com \
    --cc=shawnguo@kernel.org \
    --cc=shijie.qin@nxp.com \
    --cc=stable@vger.kernel.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox