From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Mark Rutland <mark.rutland@arm.com>,
Changbin Du <changbin.du@huawei.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Valentin Schneider <vschneid@redhat.com>,
kasan-dev@googlegroups.com, linux-mm@kvack.org,
Alexander Potapenko <glider@google.com>,
linux-kernel@vger.kernel.org, Marco Elver <elver@google.com>
Subject: Re: [PATCH] mm: kmsan: fix instrumentation recursion on preempt_count
Date: Fri, 15 Mar 2024 17:32:05 +0100 [thread overview]
Message-ID: <lisylv2horoqxszuajysz6gp5nv4pkfhtdehi7wkp3oidao6dj@djh3zzri56dt> (raw)
In-Reply-To: <Ze7uJUynNXDjLmmn@FVFF77S0Q05N>
On Mon, Mar 11, 2024 at 11:42:29AM +0000, Mark Rutland wrote:
> On Mon, Mar 11, 2024 at 07:23:30PM +0800, Changbin Du wrote:
> > This disables msan check for preempt_count_{add,sub} to fix a
> > instrumentation recursion issue on preempt_count:
> >
> > __msan_metadata_ptr_for_load_4() -> kmsan_virt_addr_valid() ->
> > preempt_disable() -> __msan_metadata_ptr_for_load_4()
> >
> > With this fix, I was able to run kmsan kernel with:
> > o CONFIG_DEBUG_KMEMLEAK=n
> > o CONFIG_KFENCE=n
> > o CONFIG_LOCKDEP=n
> >
> > KMEMLEAK and KFENCE generate too many false positives in unwinding code.
> > LOCKDEP still introduces instrumenting recursions issue. But these are
> > other issues expected to be fixed.
> >
> > Cc: Marco Elver <elver@google.com>
> > Signed-off-by: Changbin Du <changbin.du@huawei.com>
> > ---
> > kernel/sched/core.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index 9116bcc90346..5b63bb98e60a 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -5848,7 +5848,7 @@ static inline void preempt_latency_start(int val)
> > }
> > }
> >
> > -void preempt_count_add(int val)
> > +void __no_kmsan_checks preempt_count_add(int val)
> > {
> > #ifdef CONFIG_DEBUG_PREEMPT
> > /*
> > @@ -5880,7 +5880,7 @@ static inline void preempt_latency_stop(int val)
> > trace_preempt_on(CALLER_ADDR0, get_lock_parent_ip());
> > }
>
> What prevents a larger loop via one of the calles of preempt_count_{add,sub}()
>
> For example, via preempt_latency_{start,stop}() ?
>
> ... or via some *other* instrumentation that might be placed in those?
>
> I suspect we should be using noinstr or __always_inline in a bunch of places to
> clean this up properly.
>
> Mark.
Hi,
I tried the patch with the ftrace testsuite, and this uncovered another
loop, as predicted here:
preempt_count_add():int3
function_trace_call()
__msan_metadata_ptr_for_load_8()
kmsan_get_shadow_origin_ptr()
kmsan_get_metadata()
virt_to_page_or_null()
preempt_count_add()
Best regards,
Ilya
prev parent reply other threads:[~2024-03-15 16:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-11 11:23 Changbin Du
2024-03-11 11:42 ` Mark Rutland
2024-03-11 12:06 ` Changbin Du
2024-03-15 16:32 ` Ilya Leoshkevich [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=lisylv2horoqxszuajysz6gp5nv4pkfhtdehi7wkp3oidao6dj@djh3zzri56dt \
--to=iii@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=changbin.du@huawei.com \
--cc=dietmar.eggemann@arm.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=juri.lelli@redhat.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.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