From: Michel Lespinasse <walken@google.com>
To: Stafford Horne <shorne@gmail.com>
Cc: Atish Patra <atishp@atishpatra.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
linux-riscv <linux-riscv@lists.infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
Bjorn Topel <bjorn.topel@gmail.com>
Subject: Re: mm lock issue while booting Linux on 5.8-rc1 for RISC-V
Date: Tue, 16 Jun 2020 23:29:56 -0700 [thread overview]
Message-ID: <CANN689F=LKGprNx9_Wb5HOvT-Fvv8WUR_T2DJPhy0u2HeT-A7g@mail.gmail.com> (raw)
In-Reply-To: <20200617060734.GC1401039@lianli.shorne-pla.net>
On Tue, Jun 16, 2020 at 11:07 PM Stafford Horne <shorne@gmail.com> wrote:
> On Wed, Jun 17, 2020 at 02:35:39PM +0900, Stafford Horne wrote:
> > On Tue, Jun 16, 2020 at 01:47:24PM -0700, Michel Lespinasse wrote:
> > > This makes me wonder actually - maybe there is a latent bug that got
> > > exposed after my change added the rwsem_is_locked assertion to the
> > > lockdep_assert_held one. If that is the case, it may be helpful to
> > > bisect when that issue first appeared, by testing before my patchset
> > > with VM_BUG_ON(!rwsem_is_locked(&walk.mm->mmap_lock)) added to
> > > walk_page_range() / walk_page_range_novma() / walk_page_vma() ...
> >
> > Hello,
> >
> > I tried to bisect it, but I think this issue goes much further back.
> >
> > Just with the below patch booting fails all the way back to v5.7.
> >
> > What does this mean by they way, why would mmap_assert_locked() want to assert
> > that the rwsem_is_locked() is not true?
It's the opposite - VM_BUG_ON(cond) triggers if cond is true, so in
other words it asserts that cond is false. Yeah, I agree it is kinda
confusing. But in our case, it asserts that the rwsem is locked, which
is what we want.
> The openrisc code that was walking the page ranges was not locking mm. I have
> added the below patch to v5.8-rc1 and it seems to work fine. I will send a
> better patch in a bit.
>
> iff --git a/arch/openrisc/kernel/dma.c b/arch/openrisc/kernel/dma.c
> index c152a68811dd..bd5f05dd9174 100644
> --- a/arch/openrisc/kernel/dma.c
> +++ b/arch/openrisc/kernel/dma.c
> @@ -74,8 +74,10 @@ void *arch_dma_set_uncached(void *cpu_addr, size_t size)
> * We need to iterate through the pages, clearing the dcache for
> * them and setting the cache-inhibit bit.
> */
> + mmap_read_lock(&init_mm);
> error = walk_page_range(&init_mm, va, va + size, &set_nocache_walk_ops,
> NULL);
> + mmap_read_unlock(&init_mm);
> if (error)
> return ERR_PTR(error);
> return cpu_addr;
> @@ -85,9 +87,11 @@ void arch_dma_clear_uncached(void *cpu_addr, size_t size)
> {
> unsigned long va = (unsigned long)cpu_addr;
>
> + mmap_read_lock(&init_mm);
> /* walk_page_range shouldn't be able to fail here */
> WARN_ON(walk_page_range(&init_mm, va, va + size,
> &clear_nocache_walk_ops, NULL));
> + mmap_read_unlock(&init_mm);
> }
Thanks a lot for getting to the bottom of this. I think this is the proper fix.
next prev parent reply other threads:[~2020-06-17 6:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-15 7:28 mm lock issue while booting Linux on 5.8-rc1 for RISC-V Atish Patra
2020-06-15 21:57 ` Stafford Horne
2020-06-16 4:51 ` Stafford Horne
2020-06-16 8:40 ` Palmer Dabbelt
2020-06-16 10:44 ` Michel Lespinasse
2020-06-16 17:54 ` Atish Patra
2020-06-16 18:07 ` Palmer Dabbelt
2020-06-16 18:08 ` Atish Patra
2020-06-16 18:15 ` Palmer Dabbelt
2020-06-16 18:21 ` Atish Patra
2020-06-16 19:18 ` Alex Ghiti
2020-06-16 19:19 ` Stafford Horne
2020-06-16 19:41 ` Atish Patra
2020-06-16 20:47 ` Michel Lespinasse
2020-06-17 5:35 ` Stafford Horne
2020-06-17 6:07 ` Stafford Horne
2020-06-17 6:29 ` Michel Lespinasse [this message]
2020-06-17 7:34 ` Atish Patra
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='CANN689F=LKGprNx9_Wb5HOvT-Fvv8WUR_T2DJPhy0u2HeT-A7g@mail.gmail.com' \
--to=walken@google.com \
--cc=atishp@atishpatra.org \
--cc=bjorn.topel@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=shorne@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).