From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 904E62C69A for ; Mon, 11 Mar 2024 11:42:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710157363; cv=none; b=HWqejbFQXJXwoiPxr3HOKlFcMZdvH2AsAq1f30+OzbcjBdF3swRBlgGHVAWn3roVS7RMhKHERwjbeAVdO4cmyz0kObw4R9Otzd83tyKRR/8668fZCeNQUY6FEuUkX+kpw6FlZTh/mi4FFIXoU3Ee62eDK+GN4urmD+D/q49SMm8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710157363; c=relaxed/simple; bh=QJ8mCU78FrXZ6n5IJs2I64RMXveWUU9Gf3SWRWrxCv0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hz3oFwWFjezlDX/GY/m+2b1s9zJPS7PoyyqEuMz1Zl3TftdDygPU/F59Yy1DVbMcwazWYpPjp5OoEolrAvWfFU9TRCztSS9e3XBV0Rl8SaWwfIeUA1M524s8KjXnKLntS90TciLZjnsR03x5ulzcLIe04V2KSloArjz4vKzC+Gk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 42127FEC; Mon, 11 Mar 2024 04:43:16 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.70.189]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ACF2E3F64C; Mon, 11 Mar 2024 04:42:36 -0700 (PDT) Date: Mon, 11 Mar 2024 11:42:29 +0000 From: Mark Rutland To: Changbin Du Cc: Ingo Molnar , Andrew Morton , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , kasan-dev@googlegroups.com, linux-mm@kvack.org, Alexander Potapenko , linux-kernel@vger.kernel.org, Marco Elver Subject: Re: [PATCH] mm: kmsan: fix instrumentation recursion on preempt_count Message-ID: References: <20240311112330.372158-1-changbin.du@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240311112330.372158-1-changbin.du@huawei.com> 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 > Signed-off-by: Changbin Du > --- > 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.