From: Dong Aisheng <dongas86@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
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 11:41:37 +0800 [thread overview]
Message-ID: <CAA+hA=Ss=YBt-3f=r1BL1NuO7FK56kTf31zWzNjMBkAKQE41Rg@mail.gmail.com> (raw)
In-Reply-To: <20220315155837.2dcef6eb226ad74e37ca31ca@linux-foundation.org>
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.
Do you think that's ok?
> A much cleaner solution is to use appropriate locking so that various
> threads run this code in order, without messing each other up.
>
> And it looks like the way to do that is to simply revert the commit
> which caused this regression, a4efc174b382 ("mm/cma.c: remove redundant
> cma_mutex lock")?
Yes, agree it could be a backup solution if not better ideas.
Regards
Aisheng
next prev parent reply other threads:[~2022-03-16 3:47 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 [this message]
2022-03-16 21:09 ` Andrew Morton
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='CAA+hA=Ss=YBt-3f=r1BL1NuO7FK56kTf31zWzNjMBkAKQE41Rg@mail.gmail.com' \
--to=dongas86@gmail.com \
--cc=aisheng.dong@nxp.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.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