From patchwork Mon Mar 3 22:52:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Zanussi X-Patchwork-Id: 870746 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 C379423959B; Mon, 3 Mar 2025 22:53:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741042382; cv=none; b=d7TeZ1HHbx4Pf2Ivpkae7k6OZeozZ0+fTfkh21D98z5rr70dvwHW3KAP6B46NwUK7xPC/Xl9iEp2BJBugmpLaWML96PR3ne7pY4Gmk5MRXqoFUO9RHVs6jUNK/oeZ2eMJbSoXpBQ1btG/25avgTLqUIazhGQ9+EOlrfp2c10KFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741042382; c=relaxed/simple; bh=sor4RPR8AkE4RMrn6yjMcCsIKCkzTu3ehkf4YiV6WaE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lz3pp6Wgohz9tIuT73GGEm9n2eFKZe0ITUalbXjgSch8aVuZ3oSY40q2ro3QrBM6ghSCVn45ei+xT50UGboBYFMd6V/P115R1MQTxhzLhUSlxxgVP2nVWodNvyxrV5UqyyU1X6w0rVnV9/yad6aZI1Uhhn4KmR+E7lrb3rPCYzs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ba+q9rVo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ba+q9rVo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2835FC4CEE9; Mon, 3 Mar 2025 22:53:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741042382; bh=sor4RPR8AkE4RMrn6yjMcCsIKCkzTu3ehkf4YiV6WaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ba+q9rVom0aFHsmkQzWAJrhvdEtu1qoHPAk65iAsnlxx+41v1Rz1y8Y7nK3gEpXID eqwjAchnl3ALJaoAdNt91XBZc4U55WVfoOaHbkTuE+FtkUa5R8i5NmJbXeRazZ7h2b VGMtLoz3EVw4Gj1YPGboQoAERXAJWvpL5++p4pIm++yxZ4ESg/LCxNanebj6FNzKkb k6kGu7nQ2uXyFJQ05VWkS5c/VGP5O8KBFfjj5OeT+r7JWFr5ZNo3VMsY1tnCX4jj7i qhiXNg645Ua7O8woBVp1saf5e7g3cM4qwtuacW6iF0MbEOnOyuluBeQm6RHpATSeAL 1oeeUSsrFpIcg== From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Clark Williams , "Luis Claudio R. Goncalves" , Joseph Salisbury , Tom Zanussi Cc: Eric Dumazet , "David S . Miller" Subject: [PATCH RT 1/4] u64_stats: provide u64_stats_t type Date: Mon, 3 Mar 2025 16:52:55 -0600 Message-ID: <4159ba68c4b989be05e493a0dd95e10310a30aea.1741042351.git.zanussi@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-rt-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Eric Dumazet v5.4.290-rt96-rc1 stable review patch. If anyone has any objections, please let me know. ----------- [ Upstream commit 316580b69d0a7aeeee5063af47438b626bc47cbd ] On 64bit arches, struct u64_stats_sync is empty and provides no help against load/store tearing. Using READ_ONCE()/WRITE_ONCE() would be needed. But the update side would be slightly more expensive. local64_t was defined so that we could use regular adds in a manner which is atomic wrt IRQs. However the u64_stats infra means we do not have to use local64_t on 32bit arches since the syncp provides the needed protection. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Tom Zanussi --- include/linux/u64_stats_sync.h | 51 +++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/include/linux/u64_stats_sync.h b/include/linux/u64_stats_sync.h index ca40163933e33..a1f656fc317e6 100644 --- a/include/linux/u64_stats_sync.h +++ b/include/linux/u64_stats_sync.h @@ -40,8 +40,8 @@ * spin_lock_bh(...) or other synchronization to get exclusive access * ... * u64_stats_update_begin(&stats->syncp); - * stats->bytes64 += len; // non atomic operation - * stats->packets64++; // non atomic operation + * u64_stats_add(&stats->bytes64, len); // non atomic operation + * u64_stats_inc(&stats->packets64); // non atomic operation * u64_stats_update_end(&stats->syncp); * * While a consumer (reader) should use following template to get consistent @@ -52,8 +52,8 @@ * * do { * start = u64_stats_fetch_begin(&stats->syncp); - * tbytes = stats->bytes64; // non atomic operation - * tpackets = stats->packets64; // non atomic operation + * tbytes = u64_stats_read(&stats->bytes64); // non atomic operation + * tpackets = u64_stats_read(&stats->packets64); // non atomic operation * } while (u64_stats_fetch_retry(&stats->syncp, start)); * * @@ -68,6 +68,49 @@ struct u64_stats_sync { #endif }; +#if BITS_PER_LONG == 64 +#include + +typedef struct { + local64_t v; +} u64_stats_t ; + +static inline u64 u64_stats_read(const u64_stats_t *p) +{ + return local64_read(&p->v); +} + +static inline void u64_stats_add(u64_stats_t *p, unsigned long val) +{ + local64_add(val, &p->v); +} + +static inline void u64_stats_inc(u64_stats_t *p) +{ + local64_inc(&p->v); +} + +#else + +typedef struct { + u64 v; +} u64_stats_t; + +static inline u64 u64_stats_read(const u64_stats_t *p) +{ + return p->v; +} + +static inline void u64_stats_add(u64_stats_t *p, unsigned long val) +{ + p->v += val; +} + +static inline void u64_stats_inc(u64_stats_t *p) +{ + p->v++; +} +#endif #if BITS_PER_LONG == 32 && defined(CONFIG_SMP) #define u64_stats_init(syncp) \ From patchwork Mon Mar 3 22:52:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Zanussi X-Patchwork-Id: 870033 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 15FDB23AE9A; Mon, 3 Mar 2025 22:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741042384; cv=none; b=J32G0y/SqEMK6a5WGttwJ93o2B3/rJL5C8mAfdffJvn1c4AIt6gULmHc/Zi3ggfIyg8wwdpitLSHGEeDvLz5DLOQBZ20slFxZKGTF61pfBbdfnrrYfSybORrhK2oQLjMJ/xd6mNpCt8XU1MMH3igm/isrEE/6mRN7gxLK0TiDLY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741042384; c=relaxed/simple; bh=5PDd9P7Q48zvxj9nWm103R4PqBL3obiE2ckN/i5QNBQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ckW1xWELEkjuaoHIKlRvbejGv98x2r3yWbhuT0/2Cc8hU1G5iEKghrCAazqxPJR0oOkbUdPhMHVcbLucloAEU/cSDQqpEIdHiziTVmyCAJE44zDwVngXtYaymq7ohMJYL5RS+BXyd9xV4dzY5LxE3y8md6O9JoRykPbxMTMdP70= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UuTsYsz/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UuTsYsz/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CD43C4CEEB; Mon, 3 Mar 2025 22:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741042383; bh=5PDd9P7Q48zvxj9nWm103R4PqBL3obiE2ckN/i5QNBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UuTsYsz/bGnrF+Anbf4aEisFt2efzFY0cZk4PFv7cq9bZ9IfuLVXocAjpcQBl6M92 4YZzVW7kN5GVzbxmhCmteT58yUdb/ChZkzJFR4t+yOtyPJcNUZ4HKlQ2Bbflqp8cgT szEP5E34V2qRtBpcnzvFVGD8UMQTEPCRoqWYSLjXrzHJEUnRIeEV4B7qwP/gQ5M8kU BUeb4cKgqzlc5/EZ7xyrFhIPLqzZz9EwJvDOP/RTmRzENK3g8qB8Ca3tq/fACWrPB4 WoXJfntzI4CCsUfTgAr2q8u2SmiYMxo+BVqg+j/fidgKdrrixkayUytVh0wHizpP+K US3e09Kh3d6Ew== From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Clark Williams , "Luis Claudio R. Goncalves" , Joseph Salisbury , Tom Zanussi Cc: "Ahmed S. Darwish" , "David S . Miller" Subject: [PATCH RT 2/4] u64_stats: Introduce u64_stats_set() Date: Mon, 3 Mar 2025 16:52:56 -0600 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-rt-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Ahmed S. Darwish" v5.4.290-rt96-rc1 stable review patch. If anyone has any objections, please let me know. ----------- [ Upstream commit f2efdb17928924c9c935c136dea764a081032006 ] Allow to directly set a u64_stats_t value which is used to provide an init function which sets it directly to zero intead of memset() the value. Add u64_stats_set() to the u64_stats API. [bigeasy: commit message. ] Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: David S. Miller Signed-off-by: Tom Zanussi --- include/linux/u64_stats_sync.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/u64_stats_sync.h b/include/linux/u64_stats_sync.h index a1f656fc317e6..cae87feb82d6e 100644 --- a/include/linux/u64_stats_sync.h +++ b/include/linux/u64_stats_sync.h @@ -80,6 +80,11 @@ static inline u64 u64_stats_read(const u64_stats_t *p) return local64_read(&p->v); } +static inline void u64_stats_set(u64_stats_t *p, u64 val) +{ + local64_set(&p->v, val); +} + static inline void u64_stats_add(u64_stats_t *p, unsigned long val) { local64_add(val, &p->v); @@ -101,6 +106,11 @@ static inline u64 u64_stats_read(const u64_stats_t *p) return p->v; } +static inline void u64_stats_set(u64_stats_t *p, u64 val) +{ + p->v = val; +} + static inline void u64_stats_add(u64_stats_t *p, unsigned long val) { p->v += val; From patchwork Mon Mar 3 22:52:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Zanussi X-Patchwork-Id: 870745 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 7C55623C8AD; Mon, 3 Mar 2025 22:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741042385; cv=none; b=LJsn/429Qjld1u3Q0DXHMP2/nRg8lwQz337DU/wGgsp/AYqdIyOLlIWq+e81PXfAlJAXt/OFC/hk+6SrHlKDlvsc0ohAgs4JNKPSuCo9hqrVnXFCdVTUvyqQJj4mvjeHIA/ce2ypw6recKZREx98tuTF27IdDShQntcZTS6U9lE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741042385; c=relaxed/simple; bh=todK3bY9z826RJDzKx4uUYTLuZrnQc6OWFYWpEA2/Xk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Aa13H+QwhKKFLguKCgsOFtL8gYb2uIauteUDBnOegwtKwEHS06kyXrSLebOCsgRu69bWatE3C2tEQIRKcjimzF0n72omMZ7bF6Rtr4kiSZjqCFtfuVYTsrqTW644OYbnhs8D6Nhvl7EVuPhL9l3I7vnS3Db0ntmZuUxB2bNVbY4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eVqXiT3E; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eVqXiT3E" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6681C4CEED; Mon, 3 Mar 2025 22:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741042385; bh=todK3bY9z826RJDzKx4uUYTLuZrnQc6OWFYWpEA2/Xk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eVqXiT3EVw+XiIeDU8E4JN+EfIrWcVa/4YjbSacqIjkEUV18TXz/yn6DYxFEqrGZu akSGTHM86ksKCP+pF7N5LtXj+9i6iz9c6ugvnfckveYFaARp6JYof5W8GvpvTi4ndT 3G5NIXa+Zen36jNypnT//cLs4Bx7L0UP4+DtlF1iZRHHJgJg/IOXmxusHs2x9CGYPM eqS9f7YKgyCet9/Ut4cFbkkXKhdZSW1fmvzm4VMSp4Lv/Pf2LfzhEm+7fHzAWl4/uC jbHIaOwFtqN+oei+2xCVUv705ClkOkQrZ4Rl7PLamGrk8TScwzZK92k/1UFQ1AwtDk vsANEczEdpelQ== From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Clark Williams , "Luis Claudio R. Goncalves" , Joseph Salisbury , Tom Zanussi Cc: Eric Dumazet , Pablo Neira Ayuso Subject: [PATCH RT 3/4] netfilter: nft_counter: Use u64_stats_t for statistic. Date: Mon, 3 Mar 2025 16:52:57 -0600 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-rt-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Sebastian Andrzej Siewior v5.4.290-rt96-rc1 stable review patch. If anyone has any objections, please let me know. ----------- [ Upstream commit 4a1d3acd6ea86075e77fcc1188c3fc372833ba73 ] The nft_counter uses two s64 counters for statistics. Those two are protected by a seqcount to ensure that the 64bit variable is always properly seen during updates even on 32bit architectures where the store is performed by two writes. A side effect is that the two counter (bytes and packet) are written and read together in the same window. This can be replaced with u64_stats_t. write_seqcount_begin()/ end() is replaced with u64_stats_update_begin()/ end() and behaves the same way as with seqcount_t on 32bit architectures. Additionally there is a preempt_disable on PREEMPT_RT to ensure that a reader does not preempt a writer. On 64bit architectures the macros are removed and the reads happen without any retries. This also means that the reader can observe one counter (bytes) from before the update and the other counter (packets) but that is okay since there is no requirement to have both counter from the same update window. Convert the statistic to u64_stats_t. There is one optimisation: nft_counter_do_init() and nft_counter_clone() allocate a new per-CPU counter and assign a value to it. During this assignment preemption is disabled which is not needed because the counter is not yet exposed to the system so there can not be another writer or reader. Therefore disabling preemption is omitted and raw_cpu_ptr() is used to obtain a pointer to a counter for the assignment. Cc: Eric Dumazet Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Pablo Neira Ayuso Signed-off-by: Tom Zanussi --- net/netfilter/nft_counter.c | 78 +++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/net/netfilter/nft_counter.c b/net/netfilter/nft_counter.c index bf829fabf2785..2b3ae0fd25619 100644 --- a/net/netfilter/nft_counter.c +++ b/net/netfilter/nft_counter.c @@ -8,13 +8,18 @@ #include #include #include -#include +#include #include #include #include #include struct nft_counter { + u64_stats_t bytes; + u64_stats_t packets; +}; + +struct nft_counter_tot { s64 bytes; s64 packets; }; @@ -23,25 +28,24 @@ struct nft_counter_percpu_priv { struct nft_counter __percpu *counter; }; -static DEFINE_PER_CPU(seqcount_t, nft_counter_seq); +static DEFINE_PER_CPU(struct u64_stats_sync, nft_counter_sync); static inline void nft_counter_do_eval(struct nft_counter_percpu_priv *priv, struct nft_regs *regs, const struct nft_pktinfo *pkt) { + struct u64_stats_sync *nft_sync; struct nft_counter *this_cpu; - seqcount_t *myseq; local_bh_disable(); this_cpu = this_cpu_ptr(priv->counter); - myseq = this_cpu_ptr(&nft_counter_seq); - - write_seqcount_begin(myseq); + nft_sync = this_cpu_ptr(&nft_counter_sync); - this_cpu->bytes += pkt->skb->len; - this_cpu->packets++; + u64_stats_update_begin(nft_sync); + u64_stats_add(&this_cpu->bytes, pkt->skb->len); + u64_stats_inc(&this_cpu->packets); + u64_stats_update_end(nft_sync); - write_seqcount_end(myseq); local_bh_enable(); } @@ -64,17 +68,16 @@ static int nft_counter_do_init(const struct nlattr * const tb[], if (cpu_stats == NULL) return -ENOMEM; - preempt_disable(); - this_cpu = this_cpu_ptr(cpu_stats); + this_cpu = raw_cpu_ptr(cpu_stats); if (tb[NFTA_COUNTER_PACKETS]) { - this_cpu->packets = - be64_to_cpu(nla_get_be64(tb[NFTA_COUNTER_PACKETS])); + u64_stats_set(&this_cpu->packets, + be64_to_cpu(nla_get_be64(tb[NFTA_COUNTER_PACKETS]))); } if (tb[NFTA_COUNTER_BYTES]) { - this_cpu->bytes = - be64_to_cpu(nla_get_be64(tb[NFTA_COUNTER_BYTES])); + u64_stats_set(&this_cpu->bytes, + be64_to_cpu(nla_get_be64(tb[NFTA_COUNTER_BYTES]))); } - preempt_enable(); + priv->counter = cpu_stats; return 0; } @@ -102,40 +105,41 @@ static void nft_counter_obj_destroy(const struct nft_ctx *ctx, } static void nft_counter_reset(struct nft_counter_percpu_priv *priv, - struct nft_counter *total) + struct nft_counter_tot *total) { + struct u64_stats_sync *nft_sync; struct nft_counter *this_cpu; - seqcount_t *myseq; local_bh_disable(); this_cpu = this_cpu_ptr(priv->counter); - myseq = this_cpu_ptr(&nft_counter_seq); + nft_sync = this_cpu_ptr(&nft_counter_sync); + + u64_stats_update_begin(nft_sync); + u64_stats_add(&this_cpu->packets, -total->packets); + u64_stats_add(&this_cpu->bytes, -total->bytes); + u64_stats_update_end(nft_sync); - write_seqcount_begin(myseq); - this_cpu->packets -= total->packets; - this_cpu->bytes -= total->bytes; - write_seqcount_end(myseq); local_bh_enable(); } static void nft_counter_fetch(struct nft_counter_percpu_priv *priv, - struct nft_counter *total) + struct nft_counter_tot *total) { struct nft_counter *this_cpu; - const seqcount_t *myseq; u64 bytes, packets; unsigned int seq; int cpu; memset(total, 0, sizeof(*total)); for_each_possible_cpu(cpu) { - myseq = per_cpu_ptr(&nft_counter_seq, cpu); + struct u64_stats_sync *nft_sync = per_cpu_ptr(&nft_counter_sync, cpu); + this_cpu = per_cpu_ptr(priv->counter, cpu); do { - seq = read_seqcount_begin(myseq); - bytes = this_cpu->bytes; - packets = this_cpu->packets; - } while (read_seqcount_retry(myseq, seq)); + seq = u64_stats_fetch_begin(nft_sync); + bytes = u64_stats_read(&this_cpu->bytes); + packets = u64_stats_read(&this_cpu->packets); + } while (u64_stats_fetch_retry(nft_sync, seq)); total->bytes += bytes; total->packets += packets; @@ -146,7 +150,7 @@ static int nft_counter_do_dump(struct sk_buff *skb, struct nft_counter_percpu_priv *priv, bool reset) { - struct nft_counter total; + struct nft_counter_tot total; nft_counter_fetch(priv, &total); @@ -235,7 +239,7 @@ static int nft_counter_clone(struct nft_expr *dst, const struct nft_expr *src) struct nft_counter_percpu_priv *priv_clone = nft_expr_priv(dst); struct nft_counter __percpu *cpu_stats; struct nft_counter *this_cpu; - struct nft_counter total; + struct nft_counter_tot total; nft_counter_fetch(priv, &total); @@ -243,11 +247,9 @@ static int nft_counter_clone(struct nft_expr *dst, const struct nft_expr *src) if (cpu_stats == NULL) return -ENOMEM; - preempt_disable(); - this_cpu = this_cpu_ptr(cpu_stats); - this_cpu->packets = total.packets; - this_cpu->bytes = total.bytes; - preempt_enable(); + this_cpu = raw_cpu_ptr(cpu_stats); + u64_stats_set(&this_cpu->packets, total.packets); + u64_stats_set(&this_cpu->bytes, total.bytes); priv_clone->counter = cpu_stats; return 0; @@ -279,7 +281,7 @@ static int __init nft_counter_module_init(void) int cpu, err; for_each_possible_cpu(cpu) - seqcount_init(per_cpu_ptr(&nft_counter_seq, cpu)); + u64_stats_init(per_cpu_ptr(&nft_counter_sync, cpu)); err = nft_register_obj(&nft_counter_obj_type); if (err < 0) From patchwork Mon Mar 3 22:52:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Zanussi X-Patchwork-Id: 870032 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 B4B3023C8DB; Mon, 3 Mar 2025 22:53:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741042386; cv=none; b=FaCXLzm5Ok/necVs1s26yXppl+9+SHJWC6KKeRGxuH2cr7rvfGeIBy25y5O73pT6zjJogA25ueSFuf0uy0uPwI3aFvX/30jouKXGVGQespjjR1//8+bXsZujWaYq8BuYLXUUFXPKvQ+8kcI/DEjvQDd0dkXrm7h2AwPJpiRkdC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741042386; c=relaxed/simple; bh=coceC9UTK61k9swoVPzDZ3N9VLAgHoOsmfQVKBqVgaE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E9K3uh6j/e8vuX/lOqdOGCEdFI4lW2cygaM6wDI7OZMPsCEnunqoJYmpldsJOJSn9+u4OBpBvODYK9yFpuNuNd4j+NpytXBKM3qdLvBnQ5K68BkyAKepF2BDLESqpCUMLa9FHpJ2J3nzcNyjCVVE4+WjG6o3BX3B0fFK7/6/acw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NRkXeNp1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NRkXeNp1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 316BEC4CEEE; Mon, 3 Mar 2025 22:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741042386; bh=coceC9UTK61k9swoVPzDZ3N9VLAgHoOsmfQVKBqVgaE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NRkXeNp1y71VfTZ7PoGhcVSPzGEmdoX4EHCW2V/ZdsZZk1LM98PlncFhmIffhbOzC hqfwKoUFoDvrgT+eIRUQ+RtQU9Mwdl4lSA8Vuk2Clo275vu6HhmsOrqPpmpbygaBGM 9DCDTpjUOCfdHTbf9z4GxnJ6gPoQUle1msUIG5boi6KWdxIgV9hn3paOK/OeaT55pX IcPgt0pD/OJBlwV75kSjSJ2pO8N61ht8GJtleMyBV316u0D9wSL4AEm4b9YiBtRgoK faNPH5Pqz8i9ZXVm/KF6PKUhaOpbz3f2XefFuer8DOb8UMrT/7Z8f1sN3hO864AKMg OwppXA/S8GUGg== From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Clark Williams , "Luis Claudio R. Goncalves" , Joseph Salisbury , Tom Zanussi Subject: [PATCH RT 4/4] Linux 5.4.290-rt96-rc1 Date: Mon, 3 Mar 2025 16:52:58 -0600 Message-ID: <7895cdb7a6e92feeeefab88d74b48f20b0b9fd1e.1741042351.git.zanussi@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-rt-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Tom Zanussi v5.4.290-rt96-rc1 stable review patch. If anyone has any objections, please let me know. ----------- Signed-off-by: Tom Zanussi --- localversion-rt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/localversion-rt b/localversion-rt index 5a28f0a65d160..02183db2728ee 100644 --- a/localversion-rt +++ b/localversion-rt @@ -1 +1 @@ --rt95 +-rt96-rc1