public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: "Daniel Walker (danielwa)" <danielwa@cisco.com>,
	Jann Horn <jannh@google.com>
Cc: Oleg Nesterov <oleg@redhat.com>,
	"Darko Tominac -X (dtominac - GLOBALLOGIC INC at Cisco)"
	<dtominac@cisco.com>, Masami Hiramatsu <mhiramat@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	James Clark <james.clark@linaro.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	"xe-linux-external(mailer list)" <xe-linux-external@cisco.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-trace-kernel@vger.kernel.org"
	<linux-trace-kernel@vger.kernel.org>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH] mm/madvise: preserve uprobe breakpoints across MADV_DONTNEED
Date: Fri, 1 May 2026 21:25:20 +0200	[thread overview]
Message-ID: <dd6da3c4-96a7-46ff-bcb2-b46d276d9a45@kernel.org> (raw)
In-Reply-To: <afOsxsC6MKhkuqKD@goliath>

On 4/30/26 21:25, Daniel Walker (danielwa) wrote:
> On Thu, Apr 30, 2026 at 05:22:18PM +0200, Jann Horn wrote:
>> On Wed, Apr 29, 2026 at 11:11 PM Daniel Walker (danielwa)
>> <danielwa@cisco.com> wrote:
>>>
>>>
>>> Shouldn't there be some sort of compensation or notification for this, or is each person that
>>> hits this suppose to just scratch their head and send a patch that's rejected?
>>
>> I guess we could add a pr_warn_once() that warns when
>> madvise(MADV_DONTNEED) is called on a read+execute file mapping,

Private mapping, yes. MADV_DONTNEED indeed interacts poorly here.

uprobe registration indeed fails if VM_WRITE is set (valid_vma), but nothing
stops the VMA from getting mprotect'ed later I guess, to allow for write access.

We could try marking a VMA that has uprobes, to then pr_warn_once() of
MADV_DONTNEED is done on such a VMA. It wouldn't sort out ptrace access.

>> and/or (as David said) add an explicit note in the madvise() manpage
>> about how that can interfere with software breakpoints and uprobes?

I guess not just software breakpoints, but any modifications done by a debugger.

I guess for read+execute file mapping we would expect these to be software
breakpoints.

> 
> It does feel like it's the debuggers problem. The application doesn't know it's
> getting debugged. So the application does whatever it does. If GDB is debugging
> an application it should assume there's a problematic madvise() call which will
> hurt/stop the debugging from happening. It should endeavor to prevent that
> from happening. There are options in userspace to prevent it from happening. I'm
> sure madvise() is not the only thing GDB has to worry about w.r.t. screwing up
> the debugging.
> 
> Noting it in the man page seems reasonable.

I assume the bigger problem here is that MADV_DONTNEED was used for memory
reclaim, when in fact, it shouldn't be used for that.

For shared mappings, the man page even documents: "MADV_DONTNEED might not lead
to immediate freeing of the pages in the range.  The kernel is free to delay
freeing the pages until an appropriate moment.".

MADV_PAGEOUT is better for reclaim, but it has its limitations when it comes to
pages shared with other processes.

-- 
Cheers,

David

      reply	other threads:[~2026-05-01 19:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29 13:15 [PATCH] mm/madvise: preserve uprobe breakpoints across MADV_DONTNEED Darko Tominac
2026-04-29 13:31 ` David Hildenbrand (Arm)
2026-04-29 15:24   ` Oleg Nesterov
2026-04-29 21:11     ` Daniel Walker (danielwa)
2026-04-30  9:16       ` Oleg Nesterov
2026-04-30  9:54         ` David Hildenbrand (Arm)
2026-04-30 18:46           ` Oleg Nesterov
2026-04-30 19:11             ` Jann Horn
2026-04-30 15:22       ` Jann Horn
2026-04-30 19:25         ` Daniel Walker (danielwa)
2026-05-01 19:25           ` David Hildenbrand (Arm) [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=dd6da3c4-96a7-46ff-bcb2-b46d276d9a45@kernel.org \
    --to=david@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=danielwa@cisco.com \
    --cc=dtominac@cisco.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jannh@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=vbabka@kernel.org \
    --cc=xe-linux-external@cisco.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