Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 ADA57266B7D for ; Mon, 12 May 2025 09:27:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747042067; cv=none; b=CLDrYnhwdu64DhNfdNDuZKBZLhKppaiwCsKqmhH1afNwtjUoNwzbmAl0jW3gE8QiE/pqYf4Ftl7qRbIjEFIA2PLkFyznGbjBnqyvS6A+s+ka/VkEr1SzEGnyNxa1RNH0YlX6AO1oW6g44j2bKni3Rq26IqADJb474Th9bKcnthg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747042067; c=relaxed/simple; bh=ikhY+bHEuuPq+Wi377sZpWwI70FH5caxkwylptiayXo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ItJyZ4F2N8pCZ3p6aUm+49yjv5H5NmlN2ABL6MH8NoB1PHSkHNlhCjg568Nkl4dCLTlxTXejC21crbNntLlbOHfod054qEFHJ9xD4LMmECMvbVW6dyE+ln2KjsJu7huxl/KtbX6C8alI0bYbV7Fznr3lGEbfcOUqRWusOYzx3Sw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=MIsGH0qz; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=670viFAy; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="MIsGH0qz"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="670viFAy" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1747042063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uaElcyYJlHDajUNT3LTdSQakOyifkztF7WLYup3LZE4=; b=MIsGH0qzVbg3km3XR2VFVazMlc4FU7ou4pfJ2vDU8v4aYtT3BeMPAq91oNdUDcF8PGJjWS PzblJ9Pft5Vn3k5Evcj6Ne0/ezrpZHGzILAyRfkeoD/buaR69Zu+hYUaXNJgbmW4qEH0MU YEhPYY0fYYEUsC9PPQV+2+WbB2omEHO5shA6hSs104iQHQFrTNGP0r+bpXCLR/278TmP6W EzZyZP193ak7Ry6807x4hZsG8UHwJrKM8V383PXG27Vxfc7G8P4OHgn6ZabZHp4ay7buaJ zcMdWTADSLFWeAlJOllqvamP+GnAucdzrGkgdOZygv/5IFJi3Nmq9Ujf+3aBbw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1747042063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uaElcyYJlHDajUNT3LTdSQakOyifkztF7WLYup3LZE4=; b=670viFAy43dRTDrMrK+kmNl0gsOZi1hptdpFyys0aN1NG68IhjGNKPF251p0GnfM5HeEYE aTGgR+uWZZtc48AA== To: netdev@vger.kernel.org, linux-rt-devel@lists.linux.dev Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Thomas Gleixner , Sebastian Andrzej Siewior , David Ahern Subject: [PATCH net-next v4 04/15] ipv6: sr: Use nested-BH locking for hmac_storage Date: Mon, 12 May 2025 11:27:25 +0200 Message-ID: <20250512092736.229935-5-bigeasy@linutronix.de> In-Reply-To: <20250512092736.229935-1-bigeasy@linutronix.de> References: <20250512092736.229935-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-rt-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable hmac_storage is a per-CPU variable and relies on disabled BH for its locking. Without per-CPU locking in local_bh_disable() on PREEMPT_RT this data structure requires explicit locking. Add a local_lock_t to the data structure and use local_lock_nested_bh() for locking. This change adds only lockdep coverage and does not alter the functional behaviour for !PREEMPT_RT. Cc: David Ahern Signed-off-by: Sebastian Andrzej Siewior --- net/ipv6/seg6_hmac.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c index bbf5b84a70fca..f78ecb6ad8383 100644 --- a/net/ipv6/seg6_hmac.c +++ b/net/ipv6/seg6_hmac.c @@ -40,7 +40,14 @@ #include #include =20 -static DEFINE_PER_CPU(char [SEG6_HMAC_RING_SIZE], hmac_ring); +struct hmac_storage { + local_lock_t bh_lock; + char hmac_ring[SEG6_HMAC_RING_SIZE]; +}; + +static DEFINE_PER_CPU(struct hmac_storage, hmac_storage) =3D { + .bh_lock =3D INIT_LOCAL_LOCK(bh_lock), +}; =20 static int seg6_hmac_cmpfn(struct rhashtable_compare_arg *arg, const void = *obj) { @@ -187,7 +194,8 @@ int seg6_hmac_compute(struct seg6_hmac_info *hinfo, str= uct ipv6_sr_hdr *hdr, */ =20 local_bh_disable(); - ring =3D this_cpu_ptr(hmac_ring); + local_lock_nested_bh(&hmac_storage.bh_lock); + ring =3D this_cpu_ptr(hmac_storage.hmac_ring); off =3D ring; =20 /* source address */ @@ -212,6 +220,7 @@ int seg6_hmac_compute(struct seg6_hmac_info *hinfo, str= uct ipv6_sr_hdr *hdr, =20 dgsize =3D __do_hmac(hinfo, ring, plen, tmp_out, SEG6_HMAC_MAX_DIGESTSIZE); + local_unlock_nested_bh(&hmac_storage.bh_lock); local_bh_enable(); =20 if (dgsize < 0) --=20 2.49.0