linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Song Liu <songliubraving@meta.com>
Cc: Hugh Dickins <hughd@google.com>, Song Liu <song@kernel.org>,
	Jiri Olsa <jolsa@kernel.org>,
	David Stevens <stevensd@chromium.org>,
	Linux-MM <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Xu <peterx@redhat.com>,
	"Kirill A . Shutemov" <kirill@shutemov.name>,
	Yang Shi <shy828301@gmail.com>,
	David Hildenbrand <david@redhat.com>,
	Jiaqi Yan <jiaqiyan@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 3/3] mm/khugepaged: maintain page cache uptodate flag
Date: Fri, 24 Mar 2023 13:31:11 +0000	[thread overview]
Message-ID: <ZB2mH/XMj3vh1RrN@casper.infradead.org> (raw)
In-Reply-To: <6F9B0A6A-B7F1-4E25-AB15-8F3782D2EF83@fb.com>

On Fri, Mar 24, 2023 at 06:03:37AM +0000, Song Liu wrote:
> 
> 
> > On Mar 23, 2023, at 8:30 PM, Matthew Wilcox <willy@infradead.org> wrote:
> 
> [...]
> 
> > 
> > The Uptodate flag check needs to be done by the caller; the
> > find_get_page() family return !uptodate pages.
> > 
> > But find_get_page() does not advertise itself as NMI-safe.  And I
> > think it's wrong to try to make it NMI-safe.  Most of the kernel is
> > not NMI-safe.  I think it's incumbent on the BPF people to get the
> > information they need ahead of taking the NMI.  NMI handlers are not
> > supposed to be doing a huge amount of work!  I don't really understand
> > why it needs to do work in NMI context; surely it can note the location of
> > the fault and queue work to be done later (eg on irq-enable, task-switch
> > or return-to-user)
> 
> The use case here is a profiler (similar to perf-record). Parsing the 
> build id in side the NMI makes the profiler a lot simpler. Otherwise, 
> we will need some post processing for each sample. 

Simpler for you, maybe.  But this is an NMI!  It's not supposed to
be doing printf-formatting or whatever, much less poking around
in the file cache.  Like perf, it should record a sample and then
convert that later.  Maybe it can defer to a tasklet, but i think
scheduling work is a better option.

> OTOH, it is totally fine if build_id_parse() fails some time, say < 5%. 
> The profiler output is still useful in such cases. 
> 
> I guess the next step is to replace find_get_page() with a NMI-safe
> version?

No, absolutely not.  Stop doing so much work in an NMI.


  reply	other threads:[~2023-03-24 13:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07  5:20 [PATCH v5 0/3] mm/khugepaged: fix khugepaged+shmem races David Stevens
2023-03-07  5:20 ` [PATCH v5 1/3] mm/khugepaged: refactor collapse_file control flow David Stevens
2023-03-23 19:51   ` Hugh Dickins
2023-03-07  5:20 ` [PATCH v5 2/3] mm/khugepaged: skip shmem with userfaultfd David Stevens
2023-03-23 19:48   ` Hugh Dickins
2023-03-24  5:34     ` David Stevens
2023-03-28 15:48       ` Peter Xu
2023-03-07  5:20 ` [PATCH v5 3/3] mm/khugepaged: maintain page cache uptodate flag David Stevens
2023-03-23 19:07   ` Hugh Dickins
2023-03-23 21:56     ` Matthew Wilcox
2023-03-23 22:28       ` Song Liu
2023-03-24  1:56         ` Hugh Dickins
2023-03-24  3:30           ` Matthew Wilcox
2023-03-24  6:03             ` Song Liu
2023-03-24 13:31               ` Matthew Wilcox [this message]
2023-03-29 16:53                 ` Song Liu
2023-03-28  9:48     ` David Stevens

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=ZB2mH/XMj3vh1RrN@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=hughd@google.com \
    --cc=jiaqiyan@google.com \
    --cc=jolsa@kernel.org \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterx@redhat.com \
    --cc=shy828301@gmail.com \
    --cc=song@kernel.org \
    --cc=songliubraving@meta.com \
    --cc=stevensd@chromium.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