From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0998539150D for ; Tue, 23 Jun 2026 09:45:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782207908; cv=none; b=sYUqhIVJk41pWeV2EeJ/e26evSn6Q6we11vYgnTP16ijElaPVA+FvlXbx++i1X6hV5q2hgk94v8oI3UPRxWK7EUYuSLbsFQasicaBsIIG/dCHCwMqdB5xoHUmsUB5Kn9j6xU6Qbe/zz0pYGHwk2Q30/A/T87g2iuYiYt+ZEqmK4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782207908; c=relaxed/simple; bh=j1WbO3JCB6CWXdLVmpTyDghd9VvQrUj9/GJZyBzZho0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qrGf+yF7nwC9haQXWlm5un+0RhdrPvFfGZHNBtqV1PS3iEy7lnCL8yOa4YJuoyyACHfsn1mWpCMe/ZmCdI7Ch3QYPEMAjU82jOhFB3OfX6w0Fsvmtn5KobmBsLEGqDUXirpooh8/Dj5N6f6iChDiHHPW/HuHInDasmfnlMYV+Ck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=AqUs4Jzy; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="AqUs4Jzy" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=zqL/Bd4yneCKmP8oKnhgmL//kv+JUs4sTrl+X7vKYsE=; b=AqUs4Jzy2PbSXy0dTGqtEunKkP LeYKhQ6njwaOh8G1ctMQS43AztQAkQKLIFVGYcrKef5TRmMOpqFc0MREhOSr/GBYQ9e7gY3fgEns/ WoAzH7GSdLRXfg5991N9OMAxeYvbEb4jxOpe8AOT28ZmeSVvFDtLbvHfhVJIsIgnnagwOGDKqOTL0 /Vz+oMEkKlh+4ixUh0iTLPuhbzpqKq2UTyKacQeVC0mUBavoABonX0X9BU8wCAl0x63DG1sbByFOQ ap1QAxipmTh9kGY4BlMhPOtbppUnz3YKixEX+dNi+GLHx7TBu9m8HD0Gq+pzqu0hnZ6wTnMKDJaJ1 0tMOdCiQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.99.2 #2 (Red Hat Linux)) id 1wbxgZ-00000000vhM-47yk; Tue, 23 Jun 2026 09:45:03 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 7F2253032AC; Tue, 23 Jun 2026 11:44:50 +0200 (CEST) Date: Tue, 23 Jun 2026 11:44:50 +0200 From: Peter Zijlstra To: Sun Shaojie Cc: Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , linux-kernel@vger.kernel.org Subject: Re: [PATCH] locking/percpu-rwsem: Annotate intentional data race in readers_active_check() Message-ID: <20260623094450.GP42921@noisy.programming.kicks-ass.net> References: <20260623093445.456402-1-sunshaojie@kylinos.cn> 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: <20260623093445.456402-1-sunshaojie@kylinos.cn> On Tue, Jun 23, 2026 at 05:34:45PM +0800, Sun Shaojie wrote: > KCSAN reports a data race in readers_active_check(): > > BUG: KCSAN: data-race in readers_active_check / percpu_down_write > > race at unknown origin, with read to 0xffff9f3eb5bf5f30 of 4 bytes > by task 1271 on cpu 14: > readers_active_check+0x... > percpu_down_write+0x152/0x1f0 > > value changed: 0xfffffff9 -> 0xfffffff8 > > This is a benign race. Annotate it with data_race() to suppress the > KCSAN warning. I'm not even sure I can tell what actual access is seemed problematic from this report, let alone tell your reasoning for why it is benign. And while I think the patch is ok (with my vague memories of the code at hand), this changelog is entirely insufficient. > Signed-off-by: Sun Shaojie > --- > kernel/locking/percpu-rwsem.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/locking/percpu-rwsem.c b/kernel/locking/percpu-rwsem.c > index f7e152c40d6d..6c78961fe753 100644 > --- a/kernel/locking/percpu-rwsem.c > +++ b/kernel/locking/percpu-rwsem.c > @@ -211,7 +211,7 @@ EXPORT_SYMBOL_GPL(percpu_is_read_locked); > */ > static bool readers_active_check(struct percpu_rw_semaphore *sem) > { > - if (per_cpu_sum(*sem->read_count) != 0) > + if (data_race(per_cpu_sum(*sem->read_count)) != 0) > return false; > > /* > -- > 2.25.1 >