Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6824904rdb; Fri, 15 Dec 2023 09:13:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOzeXmVjbzAzgwQzdS2koWZHRdYlG+Ew+0kmVsbMF4X8hvjiNSQd9Qdm+pZrvsUkBiMJCw X-Received: by 2002:a05:6122:17a0:b0:4b2:8f46:f6a2 with SMTP id o32-20020a05612217a000b004b28f46f6a2mr11536665vkf.9.1702660387679; Fri, 15 Dec 2023 09:13:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702660387; cv=none; d=google.com; s=arc-20160816; b=MDKHOJxxB1n8hjcNmCM7JW2zp+p+6YQ6CDsdN0l3UBBVY2POnCym8z2g0YyjCLH7Fi Obca0RelpO1L8Ymp+E8XQPbW97soV8nEO5OvHGJ3755vpnS7B5K3IpJzrjmqmDmDabD0 BniuGEwrl5oeZ0JIK3zNzWgU+yMMCXoTwdRudmCAbHbAHXszm6xALOEdR4Sg3JSO6p4S Gk4YV9KFkQ/uckIEUZdb4Eyw4iGv7GuxH9mE3aD3OngIac2Y41GoW6UajfFJD8urPPSw ju8+J0H6Rd9OEVt/PSXatBqmyO26VbzfSkZrZJoGNXcM3dY0C2XcuAgr0dEgHp0AXMPP sb3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=Toc2vtgvKbxP7JJIcFsW6oVPRLsytfDxSXD/Hk+NeWo=; fh=mRMHo6FEBd+e0N/0wwmt9BaEcwCnNTE8npQn9DDRWX4=; b=XEzgRfBpOdWs/F6g72oflj3V7uMNpLn7befqXmBNs+AEsV/ytG3/bUZIHYdSOKtIiF H1T7N/RVFfbfD+fUt4j3EAaA4lXhTOYo0wHbm+zP7cl4qKZRcA+yHuoAP6tnxqNzYBID 3iPVlqZfBZZr9D7AR11tH/n3jOx0fqYMemNC+rEWq6xrhDSXzUGbD/7QVsn01vqGRiWK X7VKg6/6iTuLn+i4oawD8j13m4zxPMp5gA2Rs7wxrRtVjFkN2igErzWE7vFCFUi60wzQ PHr/M4wY62AYm08SLdin4cgC2hYuzsiMBPrNFhS97pfRJQehPDHlHDqvx97kpW/zFsK6 TI3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0nhI3f6g; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel+bounces-1370-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1370-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id fp15-20020a0561223a0f00b004b2efb641b5si4078050vkb.65.2023.12.15.09.13.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 09:13:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1370-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=@linutronix.de header.s=2020 header.b=0nhI3f6g; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel+bounces-1370-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1370-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 4C82A1C23E42 for ; Fri, 15 Dec 2023 17:13:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22487487A6; Fri, 15 Dec 2023 17:10:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0nhI3f6g"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qUEfwgSH" X-Original-To: linux-kernel@vger.kernel.org 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 0FB1845BFE; Fri, 15 Dec 2023 17:10:37 +0000 (UTC) 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 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702660235; 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=Toc2vtgvKbxP7JJIcFsW6oVPRLsytfDxSXD/Hk+NeWo=; b=0nhI3f6gcBk6fYaPddmLQmpdI1cFuUqcxpgyaiwIbfgYEivTAKDISE/brK9x8nJdgFmqSL 48GKYejHZoXx3++ZtokQT9V86HUYHKla4xynN49GIm15PEOfTlP79N1yveGkcKFDwu7qS/ NsOiMbcdTNU5VEElELKd4MfkNYlt8dy58bM60OFufIEr9I/eygVklupILkhlVeQXFSaGrK SfQl6Z4zBeLK3kq5G0N703Xk1ad+FBMR0isHw6FDVkHt8XZebe5QdgWPtJ6nbIuj0eSKW+ 1iJ/NrCX8CLDT52p239zJLAAR3i+ovLtoFwAfEAE3sNtE3sO3gO7bJjlycs5WA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702660235; 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=Toc2vtgvKbxP7JJIcFsW6oVPRLsytfDxSXD/Hk+NeWo=; b=qUEfwgSHsHKNeeTb/p5aBGB0X6bF2Jdfh2GyXwf+Dm+LsQnvt4fu/ceTpV4b99wQNVCSMS h+WORWax33Z78OCQ== To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: "David S. Miller" , Boqun Feng , Daniel Borkmann , Eric Dumazet , Frederic Weisbecker , Ingo Molnar , Jakub Kicinski , Paolo Abeni , Peter Zijlstra , Thomas Gleixner , Waiman Long , Will Deacon , Sebastian Andrzej Siewior Subject: [PATCH net-next 09/24] dev: Use the RPS lock for softnet_data::input_pkt_queue on PREEMPT_RT. Date: Fri, 15 Dec 2023 18:07:28 +0100 Message-ID: <20231215171020.687342-10-bigeasy@linutronix.de> In-Reply-To: <20231215171020.687342-1-bigeasy@linutronix.de> References: <20231215171020.687342-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable There is no additional locking in rps_lock_*() on PREEMPT_RT in the !CONFIG_RPS case. The reasoning is that local_bh_disable() provides the required synchronization (everywhere). All interrupts are threaded and so the required CPU local synchronization is provided by the per-CPU lock in local_bh_disable() which is always performed for the forced-threaded interrupts. Needless to say that the softirq users (NAPI) have BH disabled while being invoked as a softirq callback. Without locking in local_bh_disable() on PREEMPT_RT the softnet_data::input_pkt_queue data structure requires explicit locking in the !CONFIG_RPS case. Disabling interrupts for CPU-local locking is undesired because it will impose restrictions within the locked sections like not allowing to free a skb. Utilise the locking which is present in the CONFIG_RPS case for serialisation on PREEMPT_RT even without CONFIG_RPS enabled. Signed-off-by: Sebastian Andrzej Siewior --- net/core/dev.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index c879246be48d8..09232080843ee 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -220,34 +220,34 @@ static inline struct hlist_head *dev_index_hash(struc= t net *net, int ifindex) static inline void rps_lock_irqsave(struct softnet_data *sd, unsigned long *flags) { - if (IS_ENABLED(CONFIG_RPS)) + if (IS_ENABLED(CONFIG_RPS) || IS_ENABLED(CONFIG_PREEMPT_RT)) spin_lock_irqsave(&sd->input_pkt_queue.lock, *flags); - else if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + else local_irq_save(*flags); } =20 static inline void rps_lock_irq_disable(struct softnet_data *sd) { - if (IS_ENABLED(CONFIG_RPS)) + if (IS_ENABLED(CONFIG_RPS) || IS_ENABLED(CONFIG_PREEMPT_RT)) spin_lock_irq(&sd->input_pkt_queue.lock); - else if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + else local_irq_disable(); } =20 static inline void rps_unlock_irq_restore(struct softnet_data *sd, unsigned long *flags) { - if (IS_ENABLED(CONFIG_RPS)) + if (IS_ENABLED(CONFIG_RPS) || IS_ENABLED(CONFIG_PREEMPT_RT)) spin_unlock_irqrestore(&sd->input_pkt_queue.lock, *flags); - else if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + else local_irq_restore(*flags); } =20 static inline void rps_unlock_irq_enable(struct softnet_data *sd) { - if (IS_ENABLED(CONFIG_RPS)) + if (IS_ENABLED(CONFIG_RPS) || IS_ENABLED(CONFIG_PREEMPT_RT)) spin_unlock_irq(&sd->input_pkt_queue.lock); - else if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + else local_irq_enable(); } =20 --=20 2.43.0