Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3000787lqp; Mon, 25 Mar 2024 16:21:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWaL+T65wf14X0hK0JmPVgzTSvcBeXzDF5tbCVgcqS7X+F0e2ruDZcyYOXXsICDVOWN+wGfCWTFu68Y1HYFKb1zuy2rs6Ga1anOjSWaSg== X-Google-Smtp-Source: AGHT+IEA+TKEgwsWvsqAZSXJFGOzWyb4pA/XhMgkitOeUTFgU6l98CpM3f1YQJKqEBdWS1k2u+Sn X-Received: by 2002:a05:6a20:748e:b0:1a3:c4f8:7710 with SMTP id p14-20020a056a20748e00b001a3c4f87710mr5863523pzd.4.1711408903478; Mon, 25 Mar 2024 16:21:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711408903; cv=pass; d=google.com; s=arc-20160816; b=wMBrtoLpn9HzSerqU2Xs6S/U/PCRZd+8pfLHorjB4MQ2Ai4Ob70R2jCp8HCNrDcipD jYdBNix62RGCJ6/mViraab8W6RS+tbX2swHFlkUGnDoqYvKtCqtemN95xjoyG+tk2T5A cGHvm0xP4iAYNYILuDnwsknW75CSCBO5ZpNGw2wwBIUoZfVLRo0aksV88AC8/0nGS2/G 34CgeGXvlJhxDeMR47fdugL55Fx5zdC6GV12b0P1Xu435MTvX8rAhuzySYUtu6Z/0bGh aMhk746x3A4GuvLoOelsGrbQwZ7e8NbLTMVQi/UIIrHArxHRM7EnJ8blEi3+wQGUB7yx N0iA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature; bh=0Z1q/4B6HZUcPPwvqc/E0mzOzgVa7O8gmXhiV8qGFNc=; fh=0ykK/Y1DPYpRlJgthBTtjtqxpXq+eevZdNHU6DauTzs=; b=PKplUo0Gu8AJpARzWwYRCmeZ3F36uinUmMa2hvlPWnTzDEMLE8ruVZ5xM1xZYkaKgv Iv+l0EGXBhvleKOJsB+mtzkeF5mOSEkR679SSWXOuUFv06s0IiV7R/ptoSPRWpVH2ADV dUjashcNjjpXSt3eWsMUDpA0AjWtmcf8HBuWOfXM3Y7Y/5HqcToyW0rqhjIx7jgRoGG2 pUeXGRlHF0w5kVLyT8gyM0s/cFbGwMJ7BZrSjp6o05z6+bi3q8BTlowFYSxn3DzjsRP7 Y3kwyD4M0cQite2DYKcIXHqoPRnVonYgeSQnojOB7Pnd+UR1iRbX6Nf+7MRPhV2Po/IQ q4Fw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PMMvTKAx; 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-117609-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117609-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q5-20020a170902a3c500b001e0c54819a9si2158421plb.165.2024.03.25.16.21.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 16:21:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117609-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PMMvTKAx; 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-117609-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117609-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C794DB2096B for ; Mon, 25 Mar 2024 18:10:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2BA2132484; Mon, 25 Mar 2024 17:34:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PMMvTKAx" Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (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 5AC5362A02; Mon, 25 Mar 2024 17:34:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711388066; cv=none; b=lbO0/IfcL2mEcKFuCCtFxKFJD23JINgI7dNpoTVIi2XSCSbIAJA8uTEdU2uxHWRTFNKhDxRUEQyJi4WpFMPDKS43OIGSOhxC3I9M4bxIlCTHlSZb+zkpEE8aru25qvniVwU8KrrkO16n2oZfL9inFlWSYzqKOnB3zFd5hxv9oAA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711388066; c=relaxed/simple; bh=IyLfgGbcXo+iMp57mJ4Zi44P1XLcuNEIFvnCYa2iwcw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tdH3vyu+UET7SMDFKL7cdua05NQdRg4FDP7xM6Asahee04cgxosjmWqBFrjVNYMsWFs/mFyjgx1odjWIEivUZmdYjArskBP6OLc7yyl5lREloJNxNrov4WiKQTiEuuWlzhRmx1IPR/O7xhq9nAWh3eCYxUmQpdTz92fcxPcIoJs= 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=PMMvTKAx; arc=none smtp.client-ip=209.85.128.178 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-yw1-f178.google.com with SMTP id 00721157ae682-6114c9b4d83so12656987b3.3; Mon, 25 Mar 2024 10:34:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711388064; x=1711992864; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=0Z1q/4B6HZUcPPwvqc/E0mzOzgVa7O8gmXhiV8qGFNc=; b=PMMvTKAxAg2MXXAqTVYOuYShIYRoZeNU9/x9z80WZ+NgknRK8abgqa0VvFLpSOfk/O SO9PFVoMywOj1Px+XMoFv0fhxyLLHJy089knkBV5mm91oXMzO3jFQWsOC/P1jY9nYtrM XLKO5DPVYwPpTsbTRbwSW/9GsKf4YfxNmWeB8FCdl7Sawd2j+A6IJrh/7xYI4odQWiUs STdBblMX3VO59z72xeZ1NXMoptM1IRyxrnqxdk5G4nKzrcz3/vc/N3zKrxotKuZuDGKf WFiUiXZSD8aWqolbljGLHW8Q/eltwN4JjdUlmrhoyOgXBmSU8I8lvluwHi70UoHdwi2P 3YRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711388064; x=1711992864; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0Z1q/4B6HZUcPPwvqc/E0mzOzgVa7O8gmXhiV8qGFNc=; b=Q3ldMd5FRWhc1f3wOF8CF7vp1OxywqQmP4F7woZgyIB1Nen/VGX3Wye1bagb5gniLq zaeK0jlFyZECvmpswaQzoN5C80TR6S5QQt4cAUzlP4/JLywQGwhuVPNbMiFNN+HnD3Df pLtdyOZ/sNzX33dS3czAOJiU6cJkrTkfUFbbg/IB3g/H7t6xb1LlLMHGc5/bun2IYBCV cKzX96V0iNZEOmANUbYhQF7U6HkwSUBvBdPS2rSkRKgyyZT53affrCr9yIK3HdVtqizx +BCPIjoIPhoSmYjmUuYlZn/tcgqplvuYN93kNNAwaLabZE9Z92ANB6UNiFfa1TC+gshY NHkg== X-Forwarded-Encrypted: i=1; AJvYcCV0By0uaF4fmgJjsnlGNExdcgPist0ESgADvdtZ7jDo2lFyY9wVPZveoLQJLAT3+NMsw3qsfflUhxrUPy8vyzXq8TVUAGXkb9lsL2h1 X-Gm-Message-State: AOJu0Yzex0AHU+gWpxr53vDzCqw+HBWiKcilSLWeTNZKKa+44KqDelbp x9CvedykaxlYs0iQmif7a8tni9Vc9lDR07sM2UIqHOSxh2ZrmZjP X-Received: by 2002:a05:690c:c07:b0:611:30d8:9fcf with SMTP id cl7-20020a05690c0c0700b0061130d89fcfmr6365038ywb.31.1711388064354; Mon, 25 Mar 2024 10:34:24 -0700 (PDT) Received: from fauth2-smtp.messagingengine.com (fauth2-smtp.messagingengine.com. [103.168.172.201]) by smtp.gmail.com with ESMTPSA id t11-20020a05621421ab00b00696903f7d25sm1084625qvc.28.2024.03.25.10.34.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:34:23 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfauth.nyi.internal (Postfix) with ESMTP id 6DC831200068; Mon, 25 Mar 2024 13:34:23 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 25 Mar 2024 13:34:23 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudduuddggedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhu nhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrg htthgvrhhnpeehudfgudffffetuedtvdehueevledvhfelleeivedtgeeuhfegueeviedu ffeivdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdei gedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfih igmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 25 Mar 2024 13:34:22 -0400 (EDT) Date: Mon, 25 Mar 2024 10:33:52 -0700 From: Boqun Feng To: Johannes Berg Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E. McKenney" , Frederic Weisbecker , Josh Triplett , Peter Zijlstra , Dan Carpenter Subject: Re: [PATCH] rcu: mollify sparse with RCU guard Message-ID: References: <20240325101626.41584-2-johannes@sipsolutions.net> <055111792727869a98c1fa693014e0b6f5d256ea.camel@sipsolutions.net> 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: <055111792727869a98c1fa693014e0b6f5d256ea.camel@sipsolutions.net> On Mon, Mar 25, 2024 at 05:41:22PM +0100, Johannes Berg wrote: > On Mon, 2024-03-25 at 09:35 -0700, Boqun Feng wrote: > > > -DEFINE_LOCK_GUARD_0(rcu, rcu_read_lock(), rcu_read_unlock()) > > > +DEFINE_LOCK_GUARD_0(rcu, do { rcu_read_lock(); __release(RCU); } while(0), rcu_read_unlock()) > > > > > > > Hmm.. not a big fan of this. __release(RCU) following a rcu_read_lock() > > is really confusing. Maybe we can introduce a _rcu_read_lock(): > > > > void _rcu_read_lock(bool guard) { > > __rcu_read_lock(); > > // Skip sparse annotation in "guard(rcu)()" to work > > // around sparse's lack of support of cleanup. > > if (!guard) > > __acquire(RCU); > > rcu_lock_acquire(...); > > ... > > } > > > > and normal rcu_read_lock() is just a _rcu_read_lock(false), RCU guard is > > a _rcu_read_lock(true)? > > Not sure I see any value in that, that's pretty much equivalent but > seems IMHO less specific, where here we know we really want this only in > this case. I don't see any other case where we'd want to ever "call" > _rcu_read_lock(true). > > Also __acquire()/__release() are just empty macros without __CHECKER__. > So not sure the indirection really is warranted for this special case. > Fair enough. > I can add a comment in there, I guess, something like > > /* sparse doesn't actually "call" cleanup functions */ > Yeah, that's helpful. > perhaps. That reminds me I forgot to CC Dan ... > > > But before that how does it looks if we don't fix this entirely? ;-) > > Well basically every time you write > > void myfunc(void) > { > guard(rcu)(); > ... > } > > sparse will complain about mismatched locks, which is _really_ annoying > for e.g. networking where there's (a) a kind of "no new warnings" rule, > and (b) sparse is actually important for all the endian annotations etc. > > Which right now means that we can't use all this new machinery, which is > a shame. > Indeed. Regards, Boqun > johannes