Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2728312rdd; Fri, 12 Jan 2024 22:32:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuGUTXCBv48IxKLHu1xyKMSmk4myoBJxAziHgWDcSpC5JNvCfILLUTaBjY8XEaF8QRqb+G X-Received: by 2002:a05:622a:189:b0:423:b9e3:f54c with SMTP id s9-20020a05622a018900b00423b9e3f54cmr3840378qtw.45.1705127557557; Fri, 12 Jan 2024 22:32:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705127557; cv=none; d=google.com; s=arc-20160816; b=PRwSdXmYCUnurDwkDNUD9hhCgKn+7xIlFI0nBYM+X24M7k6IPemlct5Xnw/P/fXEZS 4ExGJ5yvs7Km3QA6so7axK3CzgUsud1P80JBPpSLTIN2DJEs/FkMGhX4S/9zLEVoFMYv eQrBdMeJgGat27S0feJ/wqRq6bd4qpu5V/Zs64c9oGpOGDBEgE7/1Wm4d/um2uLeMjPX iTceB7rwYRwb3bimUxJ9GY12Jz1nAW77a5K1Q+B8lWOc9MLW0CW+7BaydQ9G5dRRFAG8 HrbtJxd+lJ0JIWGRcqSo0wJvcjqVdC8LLEa3dcGJkN0UW/3CkzoUj124GMuVOstg00fP TBrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from:dkim-signature; bh=hBWwQWp7dC35ghKsGzD2uVVANkhQJJIdr7WQxvme+M8=; fh=UVrLp6WklLFByEkAZ2aXEUDKLVnlkx1Itu8qnRnQLZw=; b=EDLaRCX0dykV5cQcklPFuA6fnM0O98GZu62BDHRpnnpvH4UCNTIIPCKl1k9v9sJ/iI uyr1AlW1aJXyyBNaxe3+HM9S6FUa6aQa2qArlju4nd3S6og/ik3OFgGjsmHS6ckTZq0D GloQJz6kGAwTkoW48hJAzKcL8lWhHrrrmtFfQhxEiOGNrsuSzP67OJ8RIPp6LPquvLEV 13VmVNSHQwDw6IZFbJPwFs1byVbwTD/O5AJc9DtJKWbZ7n3w23SIBG/hRKhoJJzD3BVD Uq2n2GGLRrzTraLUwGZIOvffykJtCCoYQDd0FfGuPmv+iVe8IvKKkTUfRwwOp0ypmdFo U0Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ERuGwVMN; spf=pass (google.com: domain of linux-wireless+bounces-1868-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-1868-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t42-20020a05622a182a00b00429c84b8a8csi3931510qtc.674.2024.01.12.22.32.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 22:32:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-1868-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ERuGwVMN; spf=pass (google.com: domain of linux-wireless+bounces-1868-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-1868-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 21A271C227FF for ; Sat, 13 Jan 2024 06:32:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B34351C32; Sat, 13 Jan 2024 06:32:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ERuGwVMN" X-Original-To: linux-wireless@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 90EF1E574; Sat, 13 Jan 2024 06:32:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB52AC433F1; Sat, 13 Jan 2024 06:32:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705127550; bh=2iJy/IbcVSngH7U5FJKIAQpRVXxlDL+ZrRZ3nGMmnv0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=ERuGwVMND9FQF8XVkStT34HR626Nz5XACBfcQn0Hzhl8FbkAFyXeuGrZpyDSzUK/D KcQtY0n7pARwbPlxBtZHT9AuZGDKx+LMvb9UnUNaIxTg5SW5mwp6LK6YIo1xXA0teC vGZPj/8Yz+6ldD7/OKOipQiddjWdiz+I71xPpzZslpCBOK2haas3SdtfLbegjVujx5 sxqY9MXRIHiumh9dVJvreaH1mjV+Qe8YjvpZvjdkXhK6c8nG62GVSA3fC/afonYeSg sORtiMn1y8uKxDUPdEYzN3DwDuSjsvXg/NbwQIYpQRyi5V0m+nbemqQ//3gUCHtiTC exBGzSMpZ1Hlw== From: Kalle Valo To: Brent Pappas Cc: Johannes Berg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] wifi: mac80211: tx: Add __must_hold() annotation References: <20240113011145.10888-2-bpappas@pappasbrent.com> Date: Sat, 13 Jan 2024 08:32:26 +0200 In-Reply-To: <20240113011145.10888-2-bpappas@pappasbrent.com> (Brent Pappas's message of "Fri, 12 Jan 2024 20:11:45 -0500") Message-ID: <87sf31hhfp.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Brent Pappas writes: > Annotates ieee80211_set_beacon_cntdwn() with a __must_hold() annotation to > make it clear that ieee80211_set_beacon_cntdwn() is only intended to be > called when the caller has a lock on the argument "link." > > Signed-off-by: Brent Pappas > --- > > Currently, ieee80211_set_beacon_cntdwn() calls rcu_dereference(), but > without calling rcu_read_lock() beforehand and rcu_read_unlock() > afterward. At first I thought this was a bug, since (if I understand the > RCU API correctly) rcu_dereference() should only be called in RCU > read-side critical sections. However, upon closer inspection of the code, > I realized that ieee80211_set_beacon_cntdwn() is only ever called inside > critical sections. Therefore it seems appropriate to me to annotate > ieee80211_set_beacon_cntdwn() with a __must_hold() annotation to make this > apparent precondition explicit. > > This is my first time submitting an RCU-related patch so please tell me if > I am misunderstanding the RCU API. > > net/mac80211/tx.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c > index 314998fdb1a5..7245f2e641ba 100644 > --- a/net/mac80211/tx.c > +++ b/net/mac80211/tx.c > @@ -10,6 +10,7 @@ > * Transmit and frame generation functions. > */ > > +#include "linux/compiler_types.h" > #include > #include > #include > @@ -4974,6 +4975,7 @@ static int ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, > static void ieee80211_set_beacon_cntdwn(struct ieee80211_sub_if_data *sdata, > struct beacon_data *beacon, > struct ieee80211_link_data *link) > + __must_hold(link) Oh, never seen __must_hold() before and looks very useful. So does this work with RCU, mutexes and spinlocks? In case others are interested, here's the documentation I was able to find: https://docs.kernel.org/dev-tools/sparse.html#using-sparse-for-lock-checking -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches