From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Qian Cai <cai@lca.pw>
Cc: Matthew Wilcox <willy@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Marco Elver <elver@google.com>,
Linux Memory Management List <linux-mm@kvack.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm/filemap: fix a data race in filemap_fault()
Date: Tue, 11 Feb 2020 16:24:57 +0300 [thread overview]
Message-ID: <20200211132457.uhkbh6hyljry4zpo@box> (raw)
In-Reply-To: <2EFC8936-4569-418F-82EC-6F7868BEEAE2@lca.pw>
On Mon, Feb 10, 2020 at 10:55:45PM -0500, Qian Cai wrote:
>
>
> > On Feb 10, 2020, at 10:49 PM, Matthew Wilcox <willy@infradead.org> wrote:
> >
> > On Mon, Feb 10, 2020 at 10:01:34PM -0500, Qian Cai wrote:
> >> struct file_ra_state ra.mmap_miss could be accessed concurrently during
> >> page faults as noticed by KCSAN,
> >>
> >> BUG: KCSAN: data-race in filemap_fault / filemap_map_pages
> >>
> >> write to 0xffff9b1700a2c1b4 of 4 bytes by task 3292 on cpu 30:
> >> filemap_fault+0x920/0xfc0
> >> do_sync_mmap_readahead at mm/filemap.c:2384
> >> (inlined by) filemap_fault at mm/filemap.c:2486
> >> __xfs_filemap_fault+0x112/0x3e0 [xfs]
> >> xfs_filemap_fault+0x74/0x90 [xfs]
> >> __do_fault+0x9e/0x220
> >> do_fault+0x4a0/0x920
> >> __handle_mm_fault+0xc69/0xd00
> >> handle_mm_fault+0xfc/0x2f0
> >> do_page_fault+0x263/0x6f9
> >> page_fault+0x34/0x40
> >>
> >> read to 0xffff9b1700a2c1b4 of 4 bytes by task 3313 on cpu 32:
> >> filemap_map_pages+0xc2e/0xd80
> >> filemap_map_pages at mm/filemap.c:2625
> >> do_fault+0x3da/0x920
> >> __handle_mm_fault+0xc69/0xd00
> >> handle_mm_fault+0xfc/0x2f0
> >> do_page_fault+0x263/0x6f9
> >> page_fault+0x34/0x40
> >>
> >> Reported by Kernel Concurrency Sanitizer on:
> >> CPU: 32 PID: 3313 Comm: systemd-udevd Tainted: G W L 5.5.0-next-20200210+ #1
> >> Hardware name: HPE ProLiant DL385 Gen10/ProLiant DL385 Gen10, BIOS A40 07/10/2019
> >>
> >> ra.mmap_miss is used to contribute the readahead decisions, a data race
> >> could be undesirable. Both the read and write is only under
> >> non-exclusive mmap_sem, two concurrent writers could even overflow the
> >> counter. Fixing the underflow by writing to a local variable before
> >> committing a final store to ra.mmap_miss given a small inaccuracy of the
> >> counter should be acceptable.
> >>
> >> Suggested-by: Kirill A. Shutemov <kirill@shutemov.name>
> >> Signed-off-by: Qian Cai <cai@lca.pw>
> >
> > That's more than Suggested-by. The correct way to submit this patch is:
> >
> > From: Kirill A. Shutemov <kirill@shutemov.name>
> > (at the top of the patch, so it gets credited to Kirill)
>
> Sure, if Kirill is going to provide his Signed-off-by in the first place, I’ll be happy to
> submit it on his behalf.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
--
Kirill A. Shutemov
prev parent reply other threads:[~2020-02-11 13:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-11 3:01 [PATCH v2] mm/filemap: fix a data race in filemap_fault() Qian Cai
2020-02-11 3:49 ` Matthew Wilcox
2020-02-11 3:55 ` Qian Cai
2020-02-11 13:24 ` Kirill A. Shutemov [this message]
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=20200211132457.uhkbh6hyljry4zpo@box \
--to=kirill@shutemov.name \
--cc=akpm@linux-foundation.org \
--cc=cai@lca.pw \
--cc=elver@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/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).