* [PATCH 0/3] net: core: Unify dstats with tstats and lstats, add generic collection helper
@ 2024-06-05 6:37 Jeremy Kerr
2024-06-05 6:37 ` [PATCH 1/3] net: core,vrf: Change pcpu_dstat fields to u64_stats_t Jeremy Kerr
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Jeremy Kerr @ 2024-06-05 6:37 UTC (permalink / raw)
To: David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: netdev
The struct pcpu_dstats ("dstats") has a few variations from the other
two stats types (struct pcpu_sw_netstats and struct pcpu_lstats), and
doesn't have generic helpers for collecting the per-cpu stats into a
struct rtnl_link_stats64.
This change unifies dstats with the other types, adds a collection
helper (dev_get_dstats64) for ->ndo_get_stats64, and updates the single
driver (vrf) to use this helper.
Of course, questions/comments/etc are most welcome!
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
---
Jeremy Kerr (3):
net: core,vrf: Change pcpu_dstat fields to u64_stats_t
net: core: Implement dstats-type stats collections
net: vrf: move to generic dstat helpers
drivers/net/vrf.c | 48 ++++++++++------------------------------
include/linux/netdevice.h | 15 ++++++++-----
net/core/dev.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 76 insertions(+), 43 deletions(-)
---
base-commit: 32f88d65f01bf6f45476d7edbe675e44fb9e1d58
change-id: 20240605-dstats-b6e08c318555
Best regards,
--
Jeremy Kerr <jk@codeconstruct.com.au>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] net: core,vrf: Change pcpu_dstat fields to u64_stats_t
2024-06-05 6:37 [PATCH 0/3] net: core: Unify dstats with tstats and lstats, add generic collection helper Jeremy Kerr
@ 2024-06-05 6:37 ` Jeremy Kerr
2024-06-06 21:06 ` kernel test robot
2024-06-05 6:37 ` [PATCH 2/3] net: core: Implement dstats-type stats collections Jeremy Kerr
2024-06-05 6:37 ` [PATCH 3/3] net: vrf: move to generic dstat helpers Jeremy Kerr
2 siblings, 1 reply; 9+ messages in thread
From: Jeremy Kerr @ 2024-06-05 6:37 UTC (permalink / raw)
To: David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: netdev
The pcpu_sw_netstats and pcpu_lstats structs both contain a set of
u64_stats_t fields for individual stats, but pcpu_dstats uses u64s
instead.
Make this consistent by using u64_stats_t across all stats types.
The per-cpu dstats are only used by the vrf driver at present, so update
that driver as part of this change.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
---
drivers/net/vrf.c | 29 +++++++++++++++--------------
include/linux/netdevice.h | 12 ++++++------
2 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 3a252ac5dd28..088732871b27 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -126,8 +126,8 @@ static void vrf_rx_stats(struct net_device *dev, int len)
struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats);
u64_stats_update_begin(&dstats->syncp);
- dstats->rx_packets++;
- dstats->rx_bytes += len;
+ u64_stats_inc(&dstats->rx_packets);
+ u64_stats_add(&dstats->rx_bytes, len);
u64_stats_update_end(&dstats->syncp);
}
@@ -150,11 +150,11 @@ static void vrf_get_stats64(struct net_device *dev,
dstats = per_cpu_ptr(dev->dstats, i);
do {
start = u64_stats_fetch_begin(&dstats->syncp);
- tbytes = dstats->tx_bytes;
- tpkts = dstats->tx_packets;
- tdrops = dstats->tx_drops;
- rbytes = dstats->rx_bytes;
- rpkts = dstats->rx_packets;
+ tbytes = u64_stats_read(&dstats->tx_bytes);
+ tpkts = u64_stats_read(&dstats->tx_packets);
+ tdrops = u64_stats_read(&dstats->tx_drops);
+ rbytes = u64_stats_read(&dstats->rx_bytes);
+ rpkts = u64_stats_read(&dstats->rx_packets);
} while (u64_stats_fetch_retry(&dstats->syncp, start));
stats->tx_bytes += tbytes;
stats->tx_packets += tpkts;
@@ -411,7 +411,7 @@ static int vrf_local_xmit(struct sk_buff *skb, struct net_device *dev,
if (likely(__netif_rx(skb) == NET_RX_SUCCESS))
vrf_rx_stats(dev, len);
else
- this_cpu_inc(dev->dstats->rx_drops);
+ u64_stats_inc(&dev->dstats->rx_drops);
return NETDEV_TX_OK;
}
@@ -599,19 +599,20 @@ static netdev_tx_t is_ip_tx_frame(struct sk_buff *skb, struct net_device *dev)
static netdev_tx_t vrf_xmit(struct sk_buff *skb, struct net_device *dev)
{
+ struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats);
+
int len = skb->len;
netdev_tx_t ret = is_ip_tx_frame(skb, dev);
+ u64_stats_update_begin(&dstats->syncp);
if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) {
- struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats);
- u64_stats_update_begin(&dstats->syncp);
- dstats->tx_packets++;
- dstats->tx_bytes += len;
- u64_stats_update_end(&dstats->syncp);
+ u64_stats_inc(&dstats->tx_packets);
+ u64_stats_add(&dstats->tx_bytes, len);
} else {
- this_cpu_inc(dev->dstats->tx_drops);
+ u64_stats_inc(&dstats->tx_drops);
}
+ u64_stats_update_end(&dstats->syncp);
return ret;
}
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d20c6c99eb88..f148a01dd1d1 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2731,12 +2731,12 @@ struct pcpu_sw_netstats {
} __aligned(4 * sizeof(u64));
struct pcpu_dstats {
- u64 rx_packets;
- u64 rx_bytes;
- u64 rx_drops;
- u64 tx_packets;
- u64 tx_bytes;
- u64 tx_drops;
+ u64_stats_t rx_packets;
+ u64_stats_t rx_bytes;
+ u64_stats_t rx_drops;
+ u64_stats_t tx_packets;
+ u64_stats_t tx_bytes;
+ u64_stats_t tx_drops;
struct u64_stats_sync syncp;
} __aligned(8 * sizeof(u64));
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] net: core: Implement dstats-type stats collections
2024-06-05 6:37 [PATCH 0/3] net: core: Unify dstats with tstats and lstats, add generic collection helper Jeremy Kerr
2024-06-05 6:37 ` [PATCH 1/3] net: core,vrf: Change pcpu_dstat fields to u64_stats_t Jeremy Kerr
@ 2024-06-05 6:37 ` Jeremy Kerr
2024-06-05 9:36 ` kernel test robot
` (3 more replies)
2024-06-05 6:37 ` [PATCH 3/3] net: vrf: move to generic dstat helpers Jeremy Kerr
2 siblings, 4 replies; 9+ messages in thread
From: Jeremy Kerr @ 2024-06-05 6:37 UTC (permalink / raw)
To: David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: netdev
We currently have dev_get_tstats64() for collecting per-cpu stats of
type pcpu_sw_netstats ("tstats"). However, tstats doesn't allow for
accounting tx/rx drops. We do have a stats variant that does have stats
for dropped packets: struct pcpu_dstats, but there are no core helpers
for using those stats.
The VRF driver uses dstats, by providing its own collation/fetch
functions to do so.
This change adds a common helpers for dstats-type collection, based on
the VRF driver's own (plus the unused tx_drops stat from there). We
will switch the VRF driver to use this in the next change.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
---
include/linux/netdevice.h | 3 +++
net/core/dev.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f148a01dd1d1..fdc3d8a6c0f4 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -4690,6 +4690,9 @@ void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64,
void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s,
const struct pcpu_sw_netstats __percpu *netstats);
void dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s);
+void dev_fetch_dstats(struct rtnl_link_stats64 *s,
+ const struct pcpu_dstats __percpu *dstats);
+void dev_get_dstats64(struct net_device *dev, struct rtnl_link_stats64 *s);
enum {
NESTED_SYNC_IMM_BIT,
diff --git a/net/core/dev.c b/net/core/dev.c
index e1bb6d7856d9..dc77529600ce 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10849,6 +10849,62 @@ void dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s)
}
EXPORT_SYMBOL_GPL(dev_get_tstats64);
+/**
+ * dev_fetch_dstats - collate per-cpu network dstats statistics
+ * @s: place to store stats
+ * @dstats: per-cpu network stats to read from
+ *
+ * Read per-cpu network statistics from dev->dstats and populate the
+ * related fields in @s.
+ */
+void dev_fetch_dstats(struct rtnl_link_stats64 *s,
+ const struct pcpu_dstats __percpu *dstats)
+{
+ int cpu;
+
+ for_each_possible_cpu(cpu) {
+ u64 rx_packets, rx_bytes, rx_drops;
+ u64 tx_packets, tx_bytes, tx_drops;
+ const struct pcpu_dstats *dstats;
+ unsigned int start;
+
+ dstats = per_cpu_ptr(dstats, cpu);
+ do {
+ start = u64_stats_fetch_begin(&dstats->syncp);
+ rx_packets = u64_stats_read(&dstats->rx_packets);
+ rx_bytes = u64_stats_read(&dstats->rx_bytes);
+ rx_drops = u64_stats_read(&dstats->rx_drops);
+ tx_packets = u64_stats_read(&dstats->tx_packets);
+ tx_bytes = u64_stats_read(&dstats->tx_bytes);
+ tx_drops = u64_stats_read(&dstats->tx_drops);
+ } while (u64_stats_fetch_retry(&dstats->syncp, start));
+
+ s->rx_packets += rx_packets;
+ s->rx_bytes += rx_bytes;
+ s->rx_dropped += rx_drops;
+ s->tx_packets += tx_packets;
+ s->tx_bytes += tx_bytes;
+ s->tx_dropped += tx_drops;
+ }
+}
+EXPORT_SYMBOL_GPL(dev_fetch_dstats);
+
+/**
+ * dev_get_dstats64 - ndo_get_stats64 implementation for dtstats-based
+ * account.
+ * @dev: device to get statistics from
+ * @s: place to store stats
+ *
+ * Populate @s from dev->stats and dev->dstats. Can be used as
+ * ndo_get_stats64() callback.
+ */
+void dev_get_dstats64(struct net_device *dev, struct rtnl_link_stats64 *s)
+{
+ netdev_stats_to_stats64(s, &dev->stats);
+ dev_fetch_dstats(s, dev->dstats);
+}
+EXPORT_SYMBOL_GPL(dev_get_dstats64);
+
struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
{
struct netdev_queue *queue = dev_ingress_queue(dev);
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] net: vrf: move to generic dstat helpers
2024-06-05 6:37 [PATCH 0/3] net: core: Unify dstats with tstats and lstats, add generic collection helper Jeremy Kerr
2024-06-05 6:37 ` [PATCH 1/3] net: core,vrf: Change pcpu_dstat fields to u64_stats_t Jeremy Kerr
2024-06-05 6:37 ` [PATCH 2/3] net: core: Implement dstats-type stats collections Jeremy Kerr
@ 2024-06-05 6:37 ` Jeremy Kerr
2 siblings, 0 replies; 9+ messages in thread
From: Jeremy Kerr @ 2024-06-05 6:37 UTC (permalink / raw)
To: David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: netdev
The vrf driver has its own dstats-to-rtnl_link_stats64 collection, but
we now have a generic helper for this.
Switch to the generic helper.
In doing so, we fix a minor issue where the (non-percpu)
dev->stats->tx_errors value was never collected into rtnl_link_stats64,
as the generic dev_get_dstats64() consumes the starting values from
dev->stats.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
---
drivers/net/vrf.c | 29 +----------------------------
1 file changed, 1 insertion(+), 28 deletions(-)
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 088732871b27..19d4bd25aca6 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -137,33 +137,6 @@ static void vrf_tx_error(struct net_device *vrf_dev, struct sk_buff *skb)
kfree_skb(skb);
}
-static void vrf_get_stats64(struct net_device *dev,
- struct rtnl_link_stats64 *stats)
-{
- int i;
-
- for_each_possible_cpu(i) {
- const struct pcpu_dstats *dstats;
- u64 tbytes, tpkts, tdrops, rbytes, rpkts;
- unsigned int start;
-
- dstats = per_cpu_ptr(dev->dstats, i);
- do {
- start = u64_stats_fetch_begin(&dstats->syncp);
- tbytes = u64_stats_read(&dstats->tx_bytes);
- tpkts = u64_stats_read(&dstats->tx_packets);
- tdrops = u64_stats_read(&dstats->tx_drops);
- rbytes = u64_stats_read(&dstats->rx_bytes);
- rpkts = u64_stats_read(&dstats->rx_packets);
- } while (u64_stats_fetch_retry(&dstats->syncp, start));
- stats->tx_bytes += tbytes;
- stats->tx_packets += tpkts;
- stats->tx_dropped += tdrops;
- stats->rx_bytes += rbytes;
- stats->rx_packets += rpkts;
- }
-}
-
static struct vrf_map *netns_vrf_map(struct net *net)
{
struct netns_vrf *nn_vrf = net_generic(net, vrf_net_id);
@@ -1196,7 +1169,7 @@ static const struct net_device_ops vrf_netdev_ops = {
.ndo_uninit = vrf_dev_uninit,
.ndo_start_xmit = vrf_xmit,
.ndo_set_mac_address = eth_mac_addr,
- .ndo_get_stats64 = vrf_get_stats64,
+ .ndo_get_stats64 = dev_get_dstats64,
.ndo_add_slave = vrf_add_slave,
.ndo_del_slave = vrf_del_slave,
};
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] net: core: Implement dstats-type stats collections
2024-06-05 6:37 ` [PATCH 2/3] net: core: Implement dstats-type stats collections Jeremy Kerr
@ 2024-06-05 9:36 ` kernel test robot
2024-06-05 9:59 ` kernel test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2024-06-05 9:36 UTC (permalink / raw)
To: Jeremy Kerr, David Ahern, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: oe-kbuild-all, netdev
Hi Jeremy,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 32f88d65f01bf6f45476d7edbe675e44fb9e1d58]
url: https://github.com/intel-lab-lkp/linux/commits/Jeremy-Kerr/net-core-vrf-Change-pcpu_dstat-fields-to-u64_stats_t/20240605-143942
base: 32f88d65f01bf6f45476d7edbe675e44fb9e1d58
patch link: https://lore.kernel.org/r/20240605-dstats-v1-2-1024396e1670%40codeconstruct.com.au
patch subject: [PATCH 2/3] net: core: Implement dstats-type stats collections
config: openrisc-defconfig (https://download.01.org/0day-ci/archive/20240605/202406051725.14UkSYbV-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240605/202406051725.14UkSYbV-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406051725.14UkSYbV-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from ./arch/openrisc/include/generated/asm/rwonce.h:1,
from include/linux/compiler.h:299,
from include/linux/instrumented.h:10,
from include/linux/uaccess.h:6,
from net/core/dev.c:71:
In function '__seqprop_sequence',
inlined from '__u64_stats_fetch_begin' at include/linux/u64_stats_sync.h:171:9,
inlined from 'u64_stats_fetch_begin' at include/linux/u64_stats_sync.h:208:9,
inlined from 'dev_fetch_dstats' at net/core/dev.c:10873:12:
>> include/asm-generic/rwonce.h:44:26: warning: 'dstats' is used uninitialized [-Wuninitialized]
44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/rwonce.h:50:9: note: in expansion of macro '__READ_ONCE'
50 | __READ_ONCE(x); \
| ^~~~~~~~~~~
include/linux/seqlock.h:211:16: note: in expansion of macro 'READ_ONCE'
211 | return READ_ONCE(s->sequence);
| ^~~~~~~~~
net/core/dev.c: In function 'dev_fetch_dstats':
net/core/dev.c:10868:43: note: 'dstats' was declared here
10868 | const struct pcpu_dstats *dstats;
| ^~~~~~
vim +/dstats +44 include/asm-generic/rwonce.h
e506ea451254ab Will Deacon 2019-10-15 28
e506ea451254ab Will Deacon 2019-10-15 29 /*
e506ea451254ab Will Deacon 2019-10-15 30 * Yes, this permits 64-bit accesses on 32-bit architectures. These will
e506ea451254ab Will Deacon 2019-10-15 31 * actually be atomic in some cases (namely Armv7 + LPAE), but for others we
e506ea451254ab Will Deacon 2019-10-15 32 * rely on the access being split into 2x32-bit accesses for a 32-bit quantity
e506ea451254ab Will Deacon 2019-10-15 33 * (e.g. a virtual address) and a strong prevailing wind.
e506ea451254ab Will Deacon 2019-10-15 34 */
e506ea451254ab Will Deacon 2019-10-15 35 #define compiletime_assert_rwonce_type(t) \
e506ea451254ab Will Deacon 2019-10-15 36 compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
e506ea451254ab Will Deacon 2019-10-15 37 "Unsupported access size for {READ,WRITE}_ONCE().")
e506ea451254ab Will Deacon 2019-10-15 38
e506ea451254ab Will Deacon 2019-10-15 39 /*
e506ea451254ab Will Deacon 2019-10-15 40 * Use __READ_ONCE() instead of READ_ONCE() if you do not require any
3c9184109e78ea Will Deacon 2019-10-30 41 * atomicity. Note that this may result in tears!
e506ea451254ab Will Deacon 2019-10-15 42 */
b78b331a3f5c07 Will Deacon 2019-10-15 43 #ifndef __READ_ONCE
e506ea451254ab Will Deacon 2019-10-15 @44 #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
b78b331a3f5c07 Will Deacon 2019-10-15 45 #endif
e506ea451254ab Will Deacon 2019-10-15 46
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] net: core: Implement dstats-type stats collections
2024-06-05 6:37 ` [PATCH 2/3] net: core: Implement dstats-type stats collections Jeremy Kerr
2024-06-05 9:36 ` kernel test robot
@ 2024-06-05 9:59 ` kernel test robot
2024-06-05 19:48 ` kernel test robot
2024-06-06 9:02 ` Dan Carpenter
3 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2024-06-05 9:59 UTC (permalink / raw)
To: Jeremy Kerr, David Ahern, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: llvm, oe-kbuild-all, netdev
Hi Jeremy,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 32f88d65f01bf6f45476d7edbe675e44fb9e1d58]
url: https://github.com/intel-lab-lkp/linux/commits/Jeremy-Kerr/net-core-vrf-Change-pcpu_dstat-fields-to-u64_stats_t/20240605-143942
base: 32f88d65f01bf6f45476d7edbe675e44fb9e1d58
patch link: https://lore.kernel.org/r/20240605-dstats-v1-2-1024396e1670%40codeconstruct.com.au
patch subject: [PATCH 2/3] net: core: Implement dstats-type stats collections
config: um-allmodconfig (https://download.01.org/0day-ci/archive/20240605/202406051710.KozBBK8o-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project d7d2d4f53fc79b4b58e8d8d08151b577c3699d4a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240605/202406051710.KozBBK8o-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406051710.KozBBK8o-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from net/core/dev.c:80:
In file included from include/linux/sched/isolation.h:5:
In file included from include/linux/cpuset.h:17:
In file included from include/linux/mm.h:2253:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from net/core/dev.c:80:
In file included from include/linux/sched/isolation.h:7:
In file included from include/linux/tick.h:8:
In file included from include/linux/clockchips.h:14:
In file included from include/linux/clocksource.h:22:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from net/core/dev.c:80:
In file included from include/linux/sched/isolation.h:7:
In file included from include/linux/tick.h:8:
In file included from include/linux/clockchips.h:14:
In file included from include/linux/clocksource.h:22:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from net/core/dev.c:80:
In file included from include/linux/sched/isolation.h:7:
In file included from include/linux/tick.h:8:
In file included from include/linux/clockchips.h:14:
In file included from include/linux/clocksource.h:22:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
693 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
701 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
709 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
718 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
727 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
736 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
>> net/core/dev.c:10871:24: warning: variable 'dstats' is uninitialized when used here [-Wuninitialized]
10871 | dstats = per_cpu_ptr(dstats, cpu);
| ^~~~~~
include/linux/percpu-defs.h:263:65: note: expanded from macro 'per_cpu_ptr'
263 | #define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
| ^~~
include/linux/percpu-defs.h:260:38: note: expanded from macro 'VERIFY_PERCPU_PTR'
260 | (typeof(*(__p)) __kernel __force *)(__p); \
| ^~~
net/core/dev.c:10868:35: note: initialize the variable 'dstats' to silence this warning
10868 | const struct pcpu_dstats *dstats;
| ^
| = NULL
net/core/dev.c:4128:1: warning: unused function 'sch_handle_ingress' [-Wunused-function]
4128 | sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
| ^~~~~~~~~~~~~~~~~~
net/core/dev.c:4135:1: warning: unused function 'sch_handle_egress' [-Wunused-function]
4135 | sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)
| ^~~~~~~~~~~~~~~~~
net/core/dev.c:5392:19: warning: unused function 'nf_ingress' [-Wunused-function]
5392 | static inline int nf_ingress(struct sk_buff *skb, struct packet_type **pt_prev,
| ^~~~~~~~~~
17 warnings generated.
vim +/dstats +10871 net/core/dev.c
10851
10852 /**
10853 * dev_fetch_dstats - collate per-cpu network dstats statistics
10854 * @s: place to store stats
10855 * @dstats: per-cpu network stats to read from
10856 *
10857 * Read per-cpu network statistics from dev->dstats and populate the
10858 * related fields in @s.
10859 */
10860 void dev_fetch_dstats(struct rtnl_link_stats64 *s,
10861 const struct pcpu_dstats __percpu *dstats)
10862 {
10863 int cpu;
10864
10865 for_each_possible_cpu(cpu) {
10866 u64 rx_packets, rx_bytes, rx_drops;
10867 u64 tx_packets, tx_bytes, tx_drops;
10868 const struct pcpu_dstats *dstats;
10869 unsigned int start;
10870
10871 dstats = per_cpu_ptr(dstats, cpu);
10872 do {
10873 start = u64_stats_fetch_begin(&dstats->syncp);
10874 rx_packets = u64_stats_read(&dstats->rx_packets);
10875 rx_bytes = u64_stats_read(&dstats->rx_bytes);
10876 rx_drops = u64_stats_read(&dstats->rx_drops);
10877 tx_packets = u64_stats_read(&dstats->tx_packets);
10878 tx_bytes = u64_stats_read(&dstats->tx_bytes);
10879 tx_drops = u64_stats_read(&dstats->tx_drops);
10880 } while (u64_stats_fetch_retry(&dstats->syncp, start));
10881
10882 s->rx_packets += rx_packets;
10883 s->rx_bytes += rx_bytes;
10884 s->rx_dropped += rx_drops;
10885 s->tx_packets += tx_packets;
10886 s->tx_bytes += tx_bytes;
10887 s->tx_dropped += tx_drops;
10888 }
10889 }
10890 EXPORT_SYMBOL_GPL(dev_fetch_dstats);
10891
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] net: core: Implement dstats-type stats collections
2024-06-05 6:37 ` [PATCH 2/3] net: core: Implement dstats-type stats collections Jeremy Kerr
2024-06-05 9:36 ` kernel test robot
2024-06-05 9:59 ` kernel test robot
@ 2024-06-05 19:48 ` kernel test robot
2024-06-06 9:02 ` Dan Carpenter
3 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2024-06-05 19:48 UTC (permalink / raw)
To: Jeremy Kerr, David Ahern, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: oe-kbuild-all, netdev
Hi Jeremy,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 32f88d65f01bf6f45476d7edbe675e44fb9e1d58]
url: https://github.com/intel-lab-lkp/linux/commits/Jeremy-Kerr/net-core-vrf-Change-pcpu_dstat-fields-to-u64_stats_t/20240605-143942
base: 32f88d65f01bf6f45476d7edbe675e44fb9e1d58
patch link: https://lore.kernel.org/r/20240605-dstats-v1-2-1024396e1670%40codeconstruct.com.au
patch subject: [PATCH 2/3] net: core: Implement dstats-type stats collections
config: x86_64-randconfig-121-20240606 (https://download.01.org/0day-ci/archive/20240606/202406060345.LfJ8GAJM-lkp@intel.com/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240606/202406060345.LfJ8GAJM-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406060345.LfJ8GAJM-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
net/core/dev.c:3379:23: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
net/core/dev.c:3379:23: sparse: expected restricted __wsum [usertype] csum
net/core/dev.c:3379:23: sparse: got unsigned int
net/core/dev.c:3379:23: sparse: sparse: cast from restricted __wsum
>> net/core/dev.c:10871:26: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got struct pcpu_dstats const * @@
net/core/dev.c:10871:26: sparse: expected void const [noderef] __percpu *__vpp_verify
net/core/dev.c:10871:26: sparse: got struct pcpu_dstats const *
net/core/dev.c:3819:17: sparse: sparse: context imbalance in '__dev_queue_xmit' - different lock contexts for basic block
net/core/dev.c:5257:17: sparse: sparse: context imbalance in 'net_tx_action' - different lock contexts for basic block
vim +10871 net/core/dev.c
10851
10852 /**
10853 * dev_fetch_dstats - collate per-cpu network dstats statistics
10854 * @s: place to store stats
10855 * @dstats: per-cpu network stats to read from
10856 *
10857 * Read per-cpu network statistics from dev->dstats and populate the
10858 * related fields in @s.
10859 */
10860 void dev_fetch_dstats(struct rtnl_link_stats64 *s,
10861 const struct pcpu_dstats __percpu *dstats)
10862 {
10863 int cpu;
10864
10865 for_each_possible_cpu(cpu) {
10866 u64 rx_packets, rx_bytes, rx_drops;
10867 u64 tx_packets, tx_bytes, tx_drops;
10868 const struct pcpu_dstats *dstats;
10869 unsigned int start;
10870
10871 dstats = per_cpu_ptr(dstats, cpu);
10872 do {
10873 start = u64_stats_fetch_begin(&dstats->syncp);
10874 rx_packets = u64_stats_read(&dstats->rx_packets);
10875 rx_bytes = u64_stats_read(&dstats->rx_bytes);
10876 rx_drops = u64_stats_read(&dstats->rx_drops);
10877 tx_packets = u64_stats_read(&dstats->tx_packets);
10878 tx_bytes = u64_stats_read(&dstats->tx_bytes);
10879 tx_drops = u64_stats_read(&dstats->tx_drops);
10880 } while (u64_stats_fetch_retry(&dstats->syncp, start));
10881
10882 s->rx_packets += rx_packets;
10883 s->rx_bytes += rx_bytes;
10884 s->rx_dropped += rx_drops;
10885 s->tx_packets += tx_packets;
10886 s->tx_bytes += tx_bytes;
10887 s->tx_dropped += tx_drops;
10888 }
10889 }
10890 EXPORT_SYMBOL_GPL(dev_fetch_dstats);
10891
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] net: core: Implement dstats-type stats collections
2024-06-05 6:37 ` [PATCH 2/3] net: core: Implement dstats-type stats collections Jeremy Kerr
` (2 preceding siblings ...)
2024-06-05 19:48 ` kernel test robot
@ 2024-06-06 9:02 ` Dan Carpenter
3 siblings, 0 replies; 9+ messages in thread
From: Dan Carpenter @ 2024-06-06 9:02 UTC (permalink / raw)
To: oe-kbuild, Jeremy Kerr, David Ahern, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: lkp, oe-kbuild-all, netdev
Hi Jeremy,
kernel test robot noticed the following build warnings:
url: https://github.com/intel-lab-lkp/linux/commits/Jeremy-Kerr/net-core-vrf-Change-pcpu_dstat-fields-to-u64_stats_t/20240605-143942
base: 32f88d65f01bf6f45476d7edbe675e44fb9e1d58
patch link: https://lore.kernel.org/r/20240605-dstats-v1-2-1024396e1670%40codeconstruct.com.au
patch subject: [PATCH 2/3] net: core: Implement dstats-type stats collections
config: x86_64-randconfig-161-20240606 (https://download.01.org/0day-ci/archive/20240606/202406061253.ZgaLHWWp-lkp@intel.com/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202406061253.ZgaLHWWp-lkp@intel.com/
smatch warnings:
net/core/dev.c:10871 dev_fetch_dstats() error: uninitialized symbol 'dstats'.
vim +/dstats +10871 net/core/dev.c
85bc70c64e8362d Jeremy Kerr 2024-06-05 10860 void dev_fetch_dstats(struct rtnl_link_stats64 *s,
85bc70c64e8362d Jeremy Kerr 2024-06-05 10861 const struct pcpu_dstats __percpu *dstats)
^^^^^^
85bc70c64e8362d Jeremy Kerr 2024-06-05 10862 {
85bc70c64e8362d Jeremy Kerr 2024-06-05 10863 int cpu;
85bc70c64e8362d Jeremy Kerr 2024-06-05 10864
85bc70c64e8362d Jeremy Kerr 2024-06-05 10865 for_each_possible_cpu(cpu) {
85bc70c64e8362d Jeremy Kerr 2024-06-05 10866 u64 rx_packets, rx_bytes, rx_drops;
85bc70c64e8362d Jeremy Kerr 2024-06-05 10867 u64 tx_packets, tx_bytes, tx_drops;
85bc70c64e8362d Jeremy Kerr 2024-06-05 10868 const struct pcpu_dstats *dstats;
^^^^^^
Don't declare a local dstats which shadows the function scope variable.
85bc70c64e8362d Jeremy Kerr 2024-06-05 10869 unsigned int start;
85bc70c64e8362d Jeremy Kerr 2024-06-05 10870
85bc70c64e8362d Jeremy Kerr 2024-06-05 @10871 dstats = per_cpu_ptr(dstats, cpu);
85bc70c64e8362d Jeremy Kerr 2024-06-05 10872 do {
85bc70c64e8362d Jeremy Kerr 2024-06-05 10873 start = u64_stats_fetch_begin(&dstats->syncp);
85bc70c64e8362d Jeremy Kerr 2024-06-05 10874 rx_packets = u64_stats_read(&dstats->rx_packets);
85bc70c64e8362d Jeremy Kerr 2024-06-05 10875 rx_bytes = u64_stats_read(&dstats->rx_bytes);
85bc70c64e8362d Jeremy Kerr 2024-06-05 10876 rx_drops = u64_stats_read(&dstats->rx_drops);
85bc70c64e8362d Jeremy Kerr 2024-06-05 10877 tx_packets = u64_stats_read(&dstats->tx_packets);
85bc70c64e8362d Jeremy Kerr 2024-06-05 10878 tx_bytes = u64_stats_read(&dstats->tx_bytes);
85bc70c64e8362d Jeremy Kerr 2024-06-05 10879 tx_drops = u64_stats_read(&dstats->tx_drops);
85bc70c64e8362d Jeremy Kerr 2024-06-05 10880 } while (u64_stats_fetch_retry(&dstats->syncp, start));
85bc70c64e8362d Jeremy Kerr 2024-06-05 10881
85bc70c64e8362d Jeremy Kerr 2024-06-05 10882 s->rx_packets += rx_packets;
85bc70c64e8362d Jeremy Kerr 2024-06-05 10883 s->rx_bytes += rx_bytes;
85bc70c64e8362d Jeremy Kerr 2024-06-05 10884 s->rx_dropped += rx_drops;
85bc70c64e8362d Jeremy Kerr 2024-06-05 10885 s->tx_packets += tx_packets;
85bc70c64e8362d Jeremy Kerr 2024-06-05 10886 s->tx_bytes += tx_bytes;
85bc70c64e8362d Jeremy Kerr 2024-06-05 10887 s->tx_dropped += tx_drops;
85bc70c64e8362d Jeremy Kerr 2024-06-05 10888 }
85bc70c64e8362d Jeremy Kerr 2024-06-05 10889 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] net: core,vrf: Change pcpu_dstat fields to u64_stats_t
2024-06-05 6:37 ` [PATCH 1/3] net: core,vrf: Change pcpu_dstat fields to u64_stats_t Jeremy Kerr
@ 2024-06-06 21:06 ` kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2024-06-06 21:06 UTC (permalink / raw)
To: Jeremy Kerr, David Ahern, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: oe-kbuild-all, netdev
Hi Jeremy,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 32f88d65f01bf6f45476d7edbe675e44fb9e1d58]
url: https://github.com/intel-lab-lkp/linux/commits/Jeremy-Kerr/net-core-vrf-Change-pcpu_dstat-fields-to-u64_stats_t/20240605-143942
base: 32f88d65f01bf6f45476d7edbe675e44fb9e1d58
patch link: https://lore.kernel.org/r/20240605-dstats-v1-1-1024396e1670%40codeconstruct.com.au
patch subject: [PATCH 1/3] net: core,vrf: Change pcpu_dstat fields to u64_stats_t
config: i386-randconfig-062-20240607 (https://download.01.org/0day-ci/archive/20240607/202406070424.JtWImJfu-lkp@intel.com/config)
compiler: gcc-10 (Ubuntu 10.5.0-1ubuntu1) 10.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240607/202406070424.JtWImJfu-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406070424.JtWImJfu-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> drivers/net/vrf.c:414:35: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct u64_stats_t [usertype] *p @@ got struct u64_stats_t [noderef] __percpu * @@
drivers/net/vrf.c:414:35: sparse: expected struct u64_stats_t [usertype] *p
drivers/net/vrf.c:414:35: sparse: got struct u64_stats_t [noderef] __percpu *
drivers/net/vrf.c: note: in included file (through include/linux/smp.h, include/linux/alloc_tag.h, include/linux/percpu.h, ...):
include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true
vim +414 drivers/net/vrf.c
391
392 /* Local traffic destined to local address. Reinsert the packet to rx
393 * path, similar to loopback handling.
394 */
395 static int vrf_local_xmit(struct sk_buff *skb, struct net_device *dev,
396 struct dst_entry *dst)
397 {
398 int len = skb->len;
399
400 skb_orphan(skb);
401
402 skb_dst_set(skb, dst);
403
404 /* set pkt_type to avoid skb hitting packet taps twice -
405 * once on Tx and again in Rx processing
406 */
407 skb->pkt_type = PACKET_LOOPBACK;
408
409 skb->protocol = eth_type_trans(skb, dev);
410
411 if (likely(__netif_rx(skb) == NET_RX_SUCCESS))
412 vrf_rx_stats(dev, len);
413 else
> 414 u64_stats_inc(&dev->dstats->rx_drops);
415
416 return NETDEV_TX_OK;
417 }
418
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-06-06 21:06 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-05 6:37 [PATCH 0/3] net: core: Unify dstats with tstats and lstats, add generic collection helper Jeremy Kerr
2024-06-05 6:37 ` [PATCH 1/3] net: core,vrf: Change pcpu_dstat fields to u64_stats_t Jeremy Kerr
2024-06-06 21:06 ` kernel test robot
2024-06-05 6:37 ` [PATCH 2/3] net: core: Implement dstats-type stats collections Jeremy Kerr
2024-06-05 9:36 ` kernel test robot
2024-06-05 9:59 ` kernel test robot
2024-06-05 19:48 ` kernel test robot
2024-06-06 9:02 ` Dan Carpenter
2024-06-05 6:37 ` [PATCH 3/3] net: vrf: move to generic dstat helpers Jeremy Kerr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).