Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2996146lqp; Mon, 25 Mar 2024 16:09:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXRI31Wwfit1yRPrZtqk6/OVOEu9bb1Lz6S9OJNmfopxqfdmKupayY/mBBPvV/MkNCKeijapkDQbtOzUGirX/ePKABeU7qhz1a4OlwBpg== X-Google-Smtp-Source: AGHT+IGGlJxxzI8Tbd3pgKNzk56ViAYM5bHhXldBjQP0UnDvgXiHWDB8if1u5GSQpTRM+jNWN9hs X-Received: by 2002:a05:6a00:8a16:b0:6ea:aaf5:e1b0 with SMTP id ic22-20020a056a008a1600b006eaaaf5e1b0mr4678341pfb.6.1711408185078; Mon, 25 Mar 2024 16:09:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711408185; cv=pass; d=google.com; s=arc-20160816; b=QIbglPR4OqPhnt0pUmK1SMWlr9ut3u6TssPciL8QbdVuh56Qg+BmiioQESxrh2tes5 dEbZVN4W1xoXHehwFOtem69lf4BNay/PruAGN6ErtoLP68ywUqNudQYivXs72ODTu8hE tJXtvubVuBpGcOdZgMl5Ltn7ECyS2lctxrX5dEVfjyWfcBg5VslZoBsdvjqhVRNb/k9y 6UQz+nEy5zpaLVyCgH9cvq65Smaq0hL7Ka2QshVk/nPZ5farAWAxS1lKpnbu+e5Mm6wM jb/bkE80FOR4wxD0xWUbtKT/JeIB3HM8ZpWcQtZhEJ2uN7fBCZjfF0eklgc2FARZblJw jPPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=9Bw7ZOyhcGm63lwlF9HqOuIvk1orl2j1qZi0NNeEQAc=; fh=5Arx1j/dufwUMbrLJ232p4IqyKpOxrlgE5ytdanbyOQ=; b=uNuUhKTDT4mU+C933pDnOdbVzukZuBYcwsHimepkeMXLNj5Ms5xRzr7XXRqC+VDM0/ XOMA5FwPWEFenxPK8YZvshyF4yX+ZJBQPQFZqjbwkxNTuTA6KgETvRPH3FhBCyJ8pOUk 2I0AKFn4vwDRK+4j5z2PzlLG/5m7NhoQYP2eViGkQ2M5/4sgmbpZoEcVrTGGlNqUYBBS 1SspluuRE1zC/mU/VmaXE7mFm6j2I5XeNI4HyvgZnY+uGhE/WHKEl3B3U9fWHzLQbW1f 7TOkq0vLF5BdmAHYVtjK/UqGM0tgl+7jBec09GcNeQua7LD18y0omtQz8GtKPN0VqvaY R2Kw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=ElYf+oVU; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-kernel+bounces-117488-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117488-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 18-20020a630112000000b005ed0deb5a66si8456027pgb.120.2024.03.25.16.09.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 16:09:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117488-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=@sipsolutions.net header.s=mail header.b=ElYf+oVU; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-kernel+bounces-117488-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117488-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net 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 35AF7C6389A for ; Mon, 25 Mar 2024 17:38:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4D1559B7E; Mon, 25 Mar 2024 16:41:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="ElYf+oVU" Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 272A1823C3; Mon, 25 Mar 2024 16:41:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711384888; cv=none; b=ZaKDQtjhAzAgFvCdxXQZ9HjIz3O1IlbaTRzgwfmNtxXve9vWBPFuqcfEWFWcOgD9knTIlPgFtHpwWGLX418i2NEoWAiKU3aj1W7kTIiV5LAvTwDIt/s56DYVHv3xwHyQfskG8EIBvIjMdzNRG5e0r/mHa0x+h/IgrhK88C8/It4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711384888; c=relaxed/simple; bh=J8TFNBjKT8XKA6rSxr767vBkNBvvVSapyx8mZob0aJ0=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=judu6PLFaxLSiGKm2oKGedigszWq97cZk60x9xCT4tWw+wH4n3DshIughMrrwNqA7ks7I252uiWo+LyjN/5J+UWFT29wLB43LcF8VrkF6EBGqrTl7lTes2P4mEaN/ILVVYYNlsIdyPstYkkmPvXNb+2OG9wRGu+ya0JVlcxRrCQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=ElYf+oVU; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=9Bw7ZOyhcGm63lwlF9HqOuIvk1orl2j1qZi0NNeEQAc=; t=1711384887; x=1712594487; b=ElYf+oVUlNHfQN3rtK11O/rg0DajyUvjh+VsnmPLhRVvWXf p3ONE3o4x4JfM7fuG+zXh6g5FZL+/uvtHyEOE4qMdd3z67LMQiffVtnNOG36mhKF6wfzbao29/W7e QA85s0BhqfTklxzalVEhLW2dpLv7S1anO8YV02wsZg+S3Yl03JIMaufEZJ7aBNSd5ZI8YRIx6O5QO XlfclBImzf5DOxefY/i8o4tVP71WiJItK59agHWG6LsaRU4VDv+XzXGnMjnnUO2TEKH/ucaLrBOLk EO1ltC9qf3n6CdVHlcKDFJ5OtKLXdLBjffVMSSsrmx3OkINuH7ej8mfwzO/IfHRw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1ronNz-0000000DxMk-3SHd; Mon, 25 Mar 2024 17:41:24 +0100 Message-ID: <055111792727869a98c1fa693014e0b6f5d256ea.camel@sipsolutions.net> Subject: Re: [PATCH] rcu: mollify sparse with RCU guard From: Johannes Berg To: Boqun Feng Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E. McKenney" , Frederic Weisbecker , Josh Triplett , Peter Zijlstra , Dan Carpenter Date: Mon, 25 Mar 2024 17:41:22 +0100 In-Reply-To: References: <20240325101626.41584-2-johannes@sipsolutions.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.4 (3.50.4-1.fc39) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-malware-bazaar: not-scanned On Mon, 2024-03-25 at 09:35 -0700, Boqun Feng wrote:=20 > > -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()) > > =20 >=20 > 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(): >=20 > 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(...); > ... > } >=20 > 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. I can add a comment in there, I guess, something like /* sparse doesn't actually "call" cleanup functions */ 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. johannes