linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Michal Hocko <mhocko@kernel.org>
Cc: Jan Stancek <jstancek@redhat.com>,
	linux-mm@kvack.org, lersek@redhat.com,
	alex.williamson@redhat.com, aarcange@redhat.com,
	rientjes@google.com, mgorman@techsingularity.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm: page_mapped: don't assume compound page is huge or THP
Date: Fri, 30 Nov 2018 15:55:29 +0300	[thread overview]
Message-ID: <20181130125529.6lw2xqiccnoddrvj@kshutemo-mobl1> (raw)
In-Reply-To: <20181130124546.GJ6923@dhcp22.suse.cz>

On Fri, Nov 30, 2018 at 01:45:46PM +0100, Michal Hocko wrote:
> On Fri 30-11-18 15:36:51, Kirill A. Shutemov wrote:
> > On Fri, Nov 30, 2018 at 01:18:51PM +0100, Michal Hocko wrote:
> > > On Fri 30-11-18 13:06:57, Jan Stancek wrote:
> > > > LTP proc01 testcase has been observed to rarely trigger crashes
> > > > on arm64:
> > > >     page_mapped+0x78/0xb4
> > > >     stable_page_flags+0x27c/0x338
> > > >     kpageflags_read+0xfc/0x164
> > > >     proc_reg_read+0x7c/0xb8
> > > >     __vfs_read+0x58/0x178
> > > >     vfs_read+0x90/0x14c
> > > >     SyS_read+0x60/0xc0
> > > > 
> > > > Issue is that page_mapped() assumes that if compound page is not
> > > > huge, then it must be THP. But if this is 'normal' compound page
> > > > (COMPOUND_PAGE_DTOR), then following loop can keep running
> > > > (for HPAGE_PMD_NR iterations) until it tries to read from memory
> > > > that isn't mapped and triggers a panic:
> > > >         for (i = 0; i < hpage_nr_pages(page); i++) {
> > > >                 if (atomic_read(&page[i]._mapcount) >= 0)
> > > >                         return true;
> > > > 	}
> > > > 
> > > > I could replicate this on x86 (v4.20-rc4-98-g60b548237fed) only
> > > > with a custom kernel module [1] which:
> > > > - allocates compound page (PAGEC) of order 1
> > > > - allocates 2 normal pages (COPY), which are initialized to 0xff
> > > >   (to satisfy _mapcount >= 0)
> > > > - 2 PAGEC page structs are copied to address of first COPY page
> > > > - second page of COPY is marked as not present
> > > > - call to page_mapped(COPY) now triggers fault on access to 2nd
> > > >   COPY page at offset 0x30 (_mapcount)
> > > > 
> > > > [1] https://github.com/jstancek/reproducers/blob/master/kernel/page_mapped_crash/repro.c
> > > > 
> > > > Fix the loop to iterate for "1 << compound_order" pages.
> > > 
> > > This is much less magic than the previous version. It is still not clear
> > > to me how is mapping higher order pages to page tables other than THP
> > > though. So a more detailed information about the source would bre really
> > > welcome. Once we know that we can add a Fixes tag and also mark the
> > > patch for stable because that sounds like a stable material.
> > 
> > IIRC, sound subsystem can producuce custom mapped compound pages.
> 
> Do I assume correctly that consecutive ptes simply point to subpages?

Yes. No huge pages there.

-- 
 Kirill A. Shutemov

  reply	other threads:[~2018-11-30 12:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29 21:53 [PATCH] " Jan Stancek
2018-11-30 10:19 ` Kirill A. Shutemov
2018-11-30 12:06 ` [PATCH v2] " Jan Stancek
2018-11-30 12:18   ` Michal Hocko
2018-11-30 12:36     ` Kirill A. Shutemov
2018-11-30 12:45       ` Michal Hocko
2018-11-30 12:55         ` Kirill A. Shutemov [this message]
2018-11-30 15:53   ` David Hildenbrand
2018-12-03 10:23   ` Laszlo Ersek
2018-12-03 11:28     ` Kirill A. Shutemov
2019-01-04 21:56   ` Andrea Arcangeli
2019-02-04 14:38   ` Lars Persson
2019-02-05  7:14     ` Jan Stancek
2019-02-18 13:43       ` Lars Persson
2019-02-18 13:50         ` Michal Hocko

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=20181130125529.6lw2xqiccnoddrvj@kshutemo-mobl1 \
    --to=kirill@shutemov.name \
    --cc=aarcange@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=jstancek@redhat.com \
    --cc=lersek@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@kernel.org \
    --cc=rientjes@google.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