Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp343636lql; Mon, 11 Mar 2024 04:42:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVdEHFYoCwLlqcc6816bmGcZ0F5idUKfMoL8GlWYqQ0t73nAis0QCS+ecQZoRqbTtCfjdG7M7MqxJAUI/NUBjPSeBqLk0SUX9zO+n6vXA== X-Google-Smtp-Source: AGHT+IEp+5Vg5TdaOI8dG7UctnaWVV733pYGq9dv+UyThnsE2Ma0qZmusFHQggX0iy84EOBTexys X-Received: by 2002:a05:6359:7614:b0:178:6211:871 with SMTP id wg20-20020a056359761400b0017862110871mr8818291rwc.0.1710157369323; Mon, 11 Mar 2024 04:42:49 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id dv11-20020a05620a1b8b00b00787c0bd8f36si5546617qkb.333.2024.03.11.04.42.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 04:42:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98774-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-98774-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98774-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0DDB91C21733 for ; Mon, 11 Mar 2024 11:42:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC4113B797; Mon, 11 Mar 2024 11:42:43 +0000 (UTC) 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.