Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp518233lqo; Fri, 10 May 2024 07:01:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUt3o3DjZuwFoWtlcFP8nSKaV2Pe14vten5gyFbMF2MODwGSIfzGrVEoFQKIOJxT1xlMc78Dl71xZzQyQCpX2rvUS9c8tEglYfW+1U6Yw== X-Google-Smtp-Source: AGHT+IFZeupwckL8DzuUe9xEKbj1vkBklR04a4/QciUjONh7jSrygETXmud8ngX5AbIQNIIpzkST X-Received: by 2002:a05:6808:4c4:b0:3c9:66f2:f31a with SMTP id 5614622812f47-3c99706e4acmr2947449b6e.34.1715349694686; Fri, 10 May 2024 07:01:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715349694; cv=pass; d=google.com; s=arc-20160816; b=lDpasOvvVJcnaoWkVCTxICuRhM5PJsAOdFqT/2i9+uFZdTQ/YMnRmd3SV6OAQHYGp1 p8KCTdGuYkI5Gq6mLNCojYYQv7vMyAR4Y+lDOcT8sEuw74tS89PUq/JI3pVmqFNi8EFP y/RkDTez3jcrOlzjauMcupKXYeh5thN7nFDXsAB9WY+ZNUZQJUVjCjET1dhOPZZkefHl 7V4jNEgMjNNU5wV7TG9ERqXcuOXcj5qSvMPtWWzF9k/IG4YsUasV/eagalcawq2P87zK Ad8dEJMENJK794zPwWDYE4hWlVdK87gB37GXEZrXNzP2psScOq42JkYNuoHEO9JyvOuR SymA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=UHIFISUNsOGDKsrJclScXfJELpLoDAA3NnSvi1tZND0=; fh=JcKr8mEeU8SVIqew+DFt2MyxaySMP4NwIJVzziVR+JU=; b=sMEUQdGVcT/0LosqLPpok+wJG/oj/iVEDlQR6DA6616mfLnT+hFKMRt6qDMgp2uy1d QHFXkMiEdghsCdw7L70zrfUU7Blci4wqASUKsBYqdcDj9odwEnZSAg3w1dPjM9fSdoha k9mlOeBJCFlrtt5X97kEEaYXfYLGBRNTKOqJMSh5yYExZkCHPpUNjFcvARslpgL+RbLi glBggTeYYBgFiV4tF+m6KD2e8usm+avkRgqmJ3PyyL64IlLOLC6/Dim86YLwjJktUYrK EH8Mv+EDajoSGLEUO22OHT+OU8ScVi0u7otl2PvWuS5FUk/7t48xv1r3KisauhR866mc sMMw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="B/tJIqz2"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-175850-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175850-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 5614622812f47-3c998f66bbfsi574172b6e.43.2024.05.10.07.01.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 07:01:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175850-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="B/tJIqz2"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-175850-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175850-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7288E28519E for ; Fri, 10 May 2024 14:00:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 228CE12C7E8; Fri, 10 May 2024 14:00:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B/tJIqz2" Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0897A127B73; Fri, 10 May 2024 14:00:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715349635; cv=none; b=Oz7uTpVpO8ixfSnU3BsRpwS3J5t2YpRptfE81D1/oOGIq2c5fgG0HfCc9DCqOI+rzyFp17iwsS/fZ97XpqHMiQVvEq/1efPI4pwkrpfH2Hg7jghB1FYfHtgScKRESI8jA51T/hgvLvRrIMEfROPtBIPHSF7GUqjV9MQWVYyKTl8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715349635; c=relaxed/simple; bh=UHIFISUNsOGDKsrJclScXfJELpLoDAA3NnSvi1tZND0=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=gSjVjkN3weMpVVk4plRJBk8ARbZ0O2KE0jk/Xu05rgVNNSM94WGV9LyGQt6pj2Pfxlw1xdKGTX6jC4e6EeqmyvPg360L777VVvEjiXuKn5/lo7NZJMiEvXoT8g+220pKVDgQnYsehu8mVAZSUCnenr9bt6oteV713WK7rmV7CkY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=B/tJIqz2; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1eca195a7c8so17655515ad.2; Fri, 10 May 2024 07:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715349633; x=1715954433; darn=vger.kernel.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UHIFISUNsOGDKsrJclScXfJELpLoDAA3NnSvi1tZND0=; b=B/tJIqz2OndL5YTM+MdJxeXq67pWVJYVBKXEYVjM36bhnnegM6X2vFHG8lu9Y7fquG 0gcDFcANnhvivIyuSZ6bVpGT/VEL+rmhl9roNXmXbZMrhsZ4ZzMYQnCNkQg0joLFw7v3 JrZ0V2JYNRpcvjHJ+0slVg+AKKK5h5RXTy5Zfx8til+y+9z4rgSUVTnR5BkyVfa+uv1Q ESZ/TgPo3Cx3OMwiZqPl5GAnNXYXKvQ4N0/lvCAxKKU6WZUzWKt+0vflNtdrKXqvHa2v w9MIQjevqIdTHyXDnhJYFjumkDYLz7rnymabRNxeiqPec3gVg7xy+Fk+UQxWgoPy59yg WDOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715349633; x=1715954433; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UHIFISUNsOGDKsrJclScXfJELpLoDAA3NnSvi1tZND0=; b=RUwa2FpZwbfMvjGD7oh1zPVmE2yJ//gq/x04X5DhoUcEW+9KViyaPwMIZUQof01MA2 ZIFxGtF9IV3faI1p6tHHzthvIhZDeOP2bqyi1qwCW61Cmnzg9PGfGp1f/Zd5qkp9Bhk5 GuLKViyQ+hfjOMEQ4uHk2qtMWiZxDDb+oYJbTRat4cbWZnVWm00QK6B34S15zUe3cfxK xqqknd+v1/XRR+/NKolpBM/jEnr8s7+GKBbEuh57+0I3J5Io9N+u4akeD4RNeCzV7AO9 c2hh8vetipEEQKW6shvThqQHCUjAn/mIFPw4gmdvP5yQPNnrQfV7s6nv7B75jFnlObyd 7J7Q== X-Forwarded-Encrypted: i=1; AJvYcCULyM8Z4puhClCLrf38a+Qidz2cX8LN+pyGkpxZQjS73+q1VcURgvm+tUCUjhbFJMSOMET8JOeCVElUG0kCseIys85mdtxMUmnFPUz6IkXtTIiJYOKX7bGlMWRoRcqVOWhU X-Gm-Message-State: AOJu0YzYNSU7neClQGjAk0/NraYRia+j/vrwU2wAgBGHBoNv1UjqbDgS g+JSkX09VGwrk9GJu112d13w5Gr0B3le3lDsLc4teoQ5T78puEWI0ZQZNw== X-Received: by 2002:a17:902:7c89:b0:1ec:2517:3a06 with SMTP id d9443c01a7336-1ef43d2e938mr20932425ad.27.1715349633240; Fri, 10 May 2024 07:00:33 -0700 (PDT) Received: from smtpclient.apple ([2402:d0c0:11:86::1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bada405sm32528285ad.92.2024.05.10.07.00.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2024 07:00:32 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\)) Subject: Re: [PATCH 25/48] rcu: Mark writes to rcu_sync ->gp_count field From: Alan Huang In-Reply-To: <20240510113149.GA24764@redhat.com> Date: Fri, 10 May 2024 22:00:07 +0800 Cc: "Paul E. McKenney" , "Uladzislau Rezki (Sony)" , RCU , Neeraj upadhyay , Boqun Feng , Hillf Danton , Joel Fernandes , LKML , Oleksiy Avramchenko , Frederic Weisbecker , Peter Zijlstra Content-Transfer-Encoding: quoted-printable Message-Id: <5831814D-BAE2-4161-A6C1-5DE1717D1D83@gmail.com> References: <20240507093530.3043-1-urezki@gmail.com> <20240507093530.3043-26-urezki@gmail.com> <4c9e89b5-c981-4809-8bc2-247563ce04e9@paulmck-laptop> <20240509151312.GA22612@redhat.com> <20240510113149.GA24764@redhat.com> To: Oleg Nesterov X-Mailer: Apple Mail (2.3774.500.171.1.1) > 2024=E5=B9=B45=E6=9C=8810=E6=97=A5 19:31=EF=BC=8COleg Nesterov = wrote=EF=BC=9A >=20 > On 05/09, Paul E. McKenney wrote: >>=20 >> On Thu, May 09, 2024 at 05:13:12PM +0200, Oleg Nesterov wrote: >>>=20 >>> We can move these WARN_ON()'s into the ->rss_lock protected section. >>>=20 >>> Or perhaps we can use data_race(rsp->gp_count) ? To be honest I = thought >>> that READ_ONCE() should be enough... >>>=20 >>> Or we can simply kill these WARN_ON_ONCE()'s. >>=20 >> Or we could move those WARN_ON_ONCE() under the lock. >=20 > Sure, see above. >=20 > But could you help me to understand this magic? I naively thought > that READ_ONCE() is always "safe"... >=20 > So, unless I am totally confused it turns out that, say, >=20 > CPU 0 CPU 1 > ----- ----- >=20 > spin_lock(LOCK); > ++X; READ_ONCE(X); // data race > spin_unlock(LOCK); >=20 > is data-racy accoring to KCSAN, while >=20 > CPU 0 CPU 1 > ----- ----- >=20 > spin_lock(LOCK); > WRITE_ONCE(X, X+1); READ_ONCE(X); // no data race > spin_unlock(LOCK); >=20 > is not. >=20 > Why is that? >=20 > Trying to read Documentation/dev-tools/kcsan.rst... it says >=20 > KCSAN is aware of *marked atomic operations* (``READ_ONCE``, = WRITE_ONCE``, >=20 > ... >=20 > if all accesses to a variable that is accessed concurrently are = properly > marked, KCSAN will never trigger a watchpoint >=20 > but how can KCSAN detect that all accesses to X are properly marked? I = see nothing > KCSAN-related in the definition of WRITE_ONCE() or READ_ONCE(). >=20 > And what does the "all accesses" above actually mean? The 2nd version = does >=20 > WRITE_ONCE(X, X+1); >=20 > but "X + 1" is the plain/unmarked access? X + 1 and READ_ONCE(X) are two read. >=20 > Thanks, >=20 > Oleg. >=20 >=20