From: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Michal Hocko <mhocko@kernel.org>,
Andrea Arcangeli <aarcange@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
linux-mm <linux-mm@kvack.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
stable <stable@vger.kernel.org>
Subject: Re: [PATCHv2] mm, page_vma_mapped: Drop faulty pointer arithmetics in check_pte()
Date: Mon, 22 Jan 2018 08:49:36 +0900 [thread overview]
Message-ID: <201801212349.w0LNna1E022604@www262.sakura.ne.jp> (raw)
In-Reply-To: <CA+55aFxobYQ5cqnCZuf8xVWr3hCUmg=rTxDPV3zHWqeQysVkxA@mail.gmail.com>
Linus Torvalds wrote:
> On Fri, Jan 19, 2018 at 4:49 AM, Kirill A. Shutemov
> <kirill.shutemov@linux.intel.com> wrote:
> >
> > + if (pfn < page_to_pfn(pvmw->page))
> > + return false;
> > +
> > + /* THP can be referenced by any subpage */
> > + if (pfn - page_to_pfn(pvmw->page) >= hpage_nr_pages(pvmw->page))
> > + return false;
> > +
>
> Is gcc actually clever enough to merge these? The "page_to_pfn()"
> logic can be pretty expensive (exactly for the sparsemem case, but
> per-node DISCOTIGMEM has some complexity too.
As far as I tested, using helper function made no difference. Unless I
explicitly insert barriers like cpu_relax() or smp_mb() between these,
the object side does not change.
>
> So I'd prefer to make that explicit, perhaps by having a helper
> function that does this something like
>
> static inline bool pfn_in_hpage(unsigned long pfn, struct page *hpage)
> {
> unsigned long hpage_pfn = page_to_pfn(hpage);
>
> return pfn >= hpage_pfn && pfn - hpage_pfn < hpage_nr_pages(hpage);
> }
>
> and then just use
>
> return pfn_in_hpage(pfn, pvmw->page);
>
> in that caller. Hmm? Wouldn't that be more legible, and avoid the
> repeated pvmw->page and page_to_pfn() cases?
>
> Even if maybe gcc can do the CSE and turn it all into the same thing
> in the end..
You can apply with
Acked-by: Michal Hocko <mhocko@suse.com>
Tested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
added.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2018-01-21 23:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-19 12:49 Kirill A. Shutemov
2018-01-19 12:57 ` Michal Hocko
2018-01-19 18:01 ` Linus Torvalds
2018-01-21 23:49 ` Tetsuo Handa [this message]
2018-01-22 1:49 ` Linus Torvalds
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=201801212349.w0LNna1E022604@www262.sakura.ne.jp \
--to=penguin-kernel@i-love.sakura.ne.jp \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@linux.intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.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