Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp432041lqo; Fri, 10 May 2024 04:36:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW83nzod8C73E17+apBTBYDd6GfHSQvD0L8R0pfsD/71kKRAQwM6YamT2E1/cc3B72nPJdpT41bWJCWD3kZxwJogGdlg0pt9OhplBr5bA== X-Google-Smtp-Source: AGHT+IHyXbYg8nVB6Y+VAAWrV/Te4o+qDiJb+0nhyg2FU7tgexHdhP/FaINZzHPZ2Hp7jGGUTMi2 X-Received: by 2002:a50:870d:0:b0:56d:fca5:4245 with SMTP id 4fb4d7f45d1cf-5734d5c0f47mr1683457a12.10.1715341005062; Fri, 10 May 2024 04:36:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715341005; cv=pass; d=google.com; s=arc-20160816; b=SFxznxkCbdak14FjhhPN1X6gLzEvnNBvXdBgF+wdmKZNxsPjVVWujPUulSJGRyhEZF j/balyQ0fftlIJKWjF/xp5RdIo97E+0GLwCwjozSL23QWbFHulPliWdt2JOSPNshKgUV DJU+7SYYon546vxJdLmM/fw/z8cn2cR3L1xbxnq7TPPfctrhqWfEe32xR9yyHvFUXCZF C4AZ1sZ22z/SPIqc3yEXAnq9RPBARqWXiR5h/WQ4TS6aXo29Gj2MiB90T3G9BeSiDh9M yMFcZ+YRRat/gyfIvjwHE2zpaCmM9BFYse8ndFIhs45qe8nzbPrtBW8I7bBEg+IdHsPd fYag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=g2/qqYRhFWlKB3W1SwI+1uiNp1F5LJ9jGM/cRZ481m0=; fh=LMiQG8eTLzf1SyU4W+POK32JVDLYXD5v2M9mE6EPfzs=; b=Fx+wGpywCSZYdDTtZ5XgoZ/ydllxPPA+QRETXFGlzhpEru2cm3Ldn7tuS9M+HqgiZz UpH+cPglQE2aTOFQ8Rb+G0aipXOambftkbXAoX7iEThIsE3r4g22BinaqE7DpSYB1eNZ fgf51kZolLOktEyxI5BaWwKtAoFYsD8r6RqUh24RiA27gXcPdEl4tEcNLg7PYWTUUpWo 6yrf9i6dFKVbJwwt+hkV3+uHzi5WO+/8kIW5SlXZgQ13LCa3B7B10sJ0qkI4seiLptAV 0sYD7uXWzoOdFnANSB8sziNcz+9FCOYMsinAX3iIULMmE/1GJJzCqKNa+QXOo3ePo65A nsYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HCfZpGBY; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-175687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175687-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57358eb0ea9si450938a12.75.2024.05.10.04.36.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 04:36:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HCfZpGBY; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-175687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175687-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 am.mirrors.kernel.org (Postfix) with ESMTPS id C85461F25D6B for ; Fri, 10 May 2024 11:36:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66D2616EC0B; Fri, 10 May 2024 11:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HCfZpGBY" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 28BDA165FDB for ; Fri, 10 May 2024 11:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715340804; cv=none; b=L6yp75YBRIdO4UcmIHN9P5qY3CMvZQI5S17P4dK592MHmPoAg/UUSVjn6fnJ+PzIkbi5c+jjSMtNJvphDjupzZ7Nu2Q5xhZtu51s7u+qYnR4Na1goT60LYED9au4EuML04kU9PHsTk7NSZbj2Yhdpiqkg5RSTATPdGlr6S1+KzE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715340804; c=relaxed/simple; bh=HrkrZp+/n0k/6V53rE3JbD0UBV428A770HYxzG7Hupk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fTDCM/cOI/5nCHhluBXzMkoW8j7bLtt4V8aNjs79ps7zGqGvnR0OgmVg3MmxotOsVC8pgnPvy/XDriBKschF0aqvCaiWIBdscgg6cFehxSgkenFYYedBXHkKlMWMsMEQboMC4Y4fgLVblQ7UsbVbWyS5qGBZbD2TBe9vfhzPaxA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=HCfZpGBY; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715340802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=g2/qqYRhFWlKB3W1SwI+1uiNp1F5LJ9jGM/cRZ481m0=; b=HCfZpGBY3Zl+E87BDf3w4poc/0ngKc8pp7esvTQa1LSnOqN95OIThkgoQX7vEOtJZDTS1z HePsi3/Nni+J2ui6K/A4lRJ1RYzI1Fk48UoGsxnIllKgeg1rCvZRf4+bYpIVjPgrS8VNzw b3BrVTwj1OsYb/FZHiSIcBfJbpMVvo4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-356-CpMeO0AuNmSaiywsnJtJ6A-1; Fri, 10 May 2024 07:33:18 -0400 X-MC-Unique: CpMeO0AuNmSaiywsnJtJ6A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1ADBD81227E; Fri, 10 May 2024 11:33:18 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.225.196]) by smtp.corp.redhat.com (Postfix) with SMTP id 509ED44E3AF9; Fri, 10 May 2024 11:33:15 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 10 May 2024 13:31:52 +0200 (CEST) Date: Fri, 10 May 2024 13:31:49 +0200 From: Oleg Nesterov To: "Paul E. McKenney" Cc: "Uladzislau Rezki (Sony)" , RCU , Neeraj upadhyay , Boqun Feng , Hillf Danton , Joel Fernandes , LKML , Oleksiy Avramchenko , Frederic Weisbecker , Peter Zijlstra Subject: Re: [PATCH 25/48] rcu: Mark writes to rcu_sync ->gp_count field Message-ID: <20240510113149.GA24764@redhat.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> 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: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 On 05/09, Paul E. McKenney wrote: > > On Thu, May 09, 2024 at 05:13:12PM +0200, Oleg Nesterov wrote: > > > > We can move these WARN_ON()'s into the ->rss_lock protected section. > > > > Or perhaps we can use data_race(rsp->gp_count) ? To be honest I thought > > that READ_ONCE() should be enough... > > > > Or we can simply kill these WARN_ON_ONCE()'s. > > Or we could move those WARN_ON_ONCE() under the lock. Sure, see above. But could you help me to understand this magic? I naively thought that READ_ONCE() is always "safe"... So, unless I am totally confused it turns out that, say, CPU 0 CPU 1 ----- ----- spin_lock(LOCK); ++X; READ_ONCE(X); // data race spin_unlock(LOCK); is data-racy accoring to KCSAN, while CPU 0 CPU 1 ----- ----- spin_lock(LOCK); WRITE_ONCE(X, X+1); READ_ONCE(X); // no data race spin_unlock(LOCK); is not. Why is that? Trying to read Documentation/dev-tools/kcsan.rst... it says KCSAN is aware of *marked atomic operations* (``READ_ONCE``, WRITE_ONCE``, ... if all accesses to a variable that is accessed concurrently are properly marked, KCSAN will never trigger a watchpoint 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(). And what does the "all accesses" above actually mean? The 2nd version does WRITE_ONCE(X, X+1); but "X + 1" is the plain/unmarked access? Thanks, Oleg.