From patchwork Mon Apr 14 16:07:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 14050685 X-Patchwork-Delegate: kuba@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 A1C32284695 for ; Mon, 14 Apr 2025 16:08:15 +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=1744646898; cv=none; b=GK7jcu4FtnrCUGeTcOYyUsaGFB1qXi1DBJYcSJ2vVXnUOy4RBzehdMC1DMrvIQdaGZdKiOhyg2LGrIuOtirspogNdqI8Xr7lG182e/b+0enx8PjLzmXb1u8pZSeB21YJmvYqRJ9bap6YkJHfUt3sYeDl5vpUTuYMjRmgD3FETAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744646898; c=relaxed/simple; bh=mpWnrGSrlTSO+lFgale6qOtBfvpFAUndKnFyjpu3eeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M0TC7fh2ND6dh/0AaUSq/TefHfK8uc93uSqnoeLj+uhNo+KXve8BgMjqCU/EOgnGmdLzXjF9qK8Q2lkPsMB/4U+pVu+NQeeSosfZoYZ9i5HkRBPne2xxQ8SEJcMutnVGey2drkyrhjwcalNC4DRNSn09bk5ZCb7jydIErLwzvbw= 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=k5W1s5Tq; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=s0DhBvqx; 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="k5W1s5Tq"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="s0DhBvqx" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744646892; 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=B91Vs7Kr8/n30DMdAVzJeH1Fm4E83+3x5T7eHPmZihs=; b=k5W1s5TqIhHJwVsdXZz1ElipHlvaHC4AGz8OjCHTwTfYeJYfHj7VSrGhy7bBqpQLO3waxN v02Q7neFlckKw+On5Z+OMJ3M4kA6MyyiNMyJWYvJfyMRALNPEHxUh/D+pMqQVHx0PH5Sf0 oh0nZPFPslTZKXOBK+yBsk0nSmpeqS5RarJu32Y87CPLOgLdmRs+tUvuaHhknHp2I/x2gv tK836WFIEO1BQ/2DNfV0251SkrCor1dctExfEPixn0pHKI0WgstAp294YuxWTjuxaeIQ7C hbOdUThAZ1Rsyp4PEeJQpJNzo3VQahozafld+6ig0F3HYACfCsDHCfZfuUtonQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744646892; 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=B91Vs7Kr8/n30DMdAVzJeH1Fm4E83+3x5T7eHPmZihs=; b=s0DhBvqx8C59BTwRoUKTqfduQrYFixN+YMaFGYY964squ9tATPyqPn2kx9BGHlkMbWJIP/ z4/9jUOQB2RuorCw== 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 , Aaron Conole , Eelco Chaudron , Ilya Maximets , dev@openvswitch.org Subject: [PATCH net-next v2 12/18] openvswitch: Move ovs_frag_data_storage into the struct ovs_pcpu_storage Date: Mon, 14 Apr 2025 18:07:48 +0200 Message-ID: <20250414160754.503321-13-bigeasy@linutronix.de> In-Reply-To: <20250414160754.503321-1-bigeasy@linutronix.de> References: <20250414160754.503321-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org ovs_frag_data_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. Move ovs_frag_data_storage into the struct ovs_pcpu_storage which already provides locking for the structure. Cc: Aaron Conole Cc: Eelco Chaudron Cc: Ilya Maximets Cc: dev@openvswitch.org Signed-off-by: Sebastian Andrzej Siewior --- net/openvswitch/actions.c | 20 ++------------------ net/openvswitch/datapath.h | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index f4996c11aefac..4d20eadd77ceb 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -39,22 +39,6 @@ #include "flow_netlink.h" #include "openvswitch_trace.h" -#define MAX_L2_LEN (VLAN_ETH_HLEN + 3 * MPLS_HLEN) -struct ovs_frag_data { - unsigned long dst; - struct vport *vport; - struct ovs_skb_cb cb; - __be16 inner_protocol; - u16 network_offset; /* valid only for MPLS */ - u16 vlan_tci; - __be16 vlan_proto; - unsigned int l2_len; - u8 mac_proto; - u8 l2_data[MAX_L2_LEN]; -}; - -static DEFINE_PER_CPU(struct ovs_frag_data, ovs_frag_data_storage); - DEFINE_PER_CPU(struct ovs_pcpu_storage, ovs_pcpu_storage) = { .bh_lock = INIT_LOCAL_LOCK(bh_lock), }; @@ -771,7 +755,7 @@ static int set_sctp(struct sk_buff *skb, struct sw_flow_key *flow_key, static int ovs_vport_output(struct net *net, struct sock *sk, struct sk_buff *skb) { - struct ovs_frag_data *data = this_cpu_ptr(&ovs_frag_data_storage); + struct ovs_frag_data *data = this_cpu_ptr(&ovs_pcpu_storage.frag_data); struct vport *vport = data->vport; if (skb_cow_head(skb, data->l2_len) < 0) { @@ -823,7 +807,7 @@ static void prepare_frag(struct vport *vport, struct sk_buff *skb, unsigned int hlen = skb_network_offset(skb); struct ovs_frag_data *data; - data = this_cpu_ptr(&ovs_frag_data_storage); + data = this_cpu_ptr(&ovs_pcpu_storage.frag_data); data->dst = skb->_skb_refdst; data->vport = vport; data->cb = *OVS_CB(skb); diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h index 4a665c3cfa906..1b5348b0f5594 100644 --- a/net/openvswitch/datapath.h +++ b/net/openvswitch/datapath.h @@ -13,6 +13,7 @@ #include #include #include +#include #include "conntrack.h" #include "flow.h" @@ -173,6 +174,20 @@ struct ovs_net { bool xt_label; }; +#define MAX_L2_LEN (VLAN_ETH_HLEN + 3 * MPLS_HLEN) +struct ovs_frag_data { + unsigned long dst; + struct vport *vport; + struct ovs_skb_cb cb; + __be16 inner_protocol; + u16 network_offset; /* valid only for MPLS */ + u16 vlan_tci; + __be16 vlan_proto; + unsigned int l2_len; + u8 mac_proto; + u8 l2_data[MAX_L2_LEN]; +}; + struct deferred_action { struct sk_buff *skb; const struct nlattr *actions; @@ -200,6 +215,7 @@ struct action_flow_keys { struct ovs_pcpu_storage { struct action_fifo action_fifos; struct action_flow_keys flow_keys; + struct ovs_frag_data frag_data; int exec_level; struct task_struct *owner; local_lock_t bh_lock;