All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: martin.lau@kernel.org, kuba@kernel.org, razor@blackwall.org,
	sdf@google.com, netdev@vger.kernel.org, bpf@vger.kernel.org,
	David Ahern <dsahern@kernel.org>
Subject: Re: [PATCH bpf v2 2/8] net: Move {l,t,d}stats allocation to core and convert veth & vrf
Date: Mon, 13 Nov 2023 10:03:05 +0000	[thread overview]
Message-ID: <20231113100305.GO705326@kernel.org> (raw)
In-Reply-To: <20231112203009.26073-3-daniel@iogearbox.net>

On Sun, Nov 12, 2023 at 09:30:03PM +0100, Daniel Borkmann wrote:
> Move {l,t,d}stats allocation to the core and let netdevs pick the stats
> type they need. That way the driver doesn't have to bother with error
> handling (allocation failure checking, making sure free happens in the
> right spot, etc) - all happening in the core.
> 
> Co-developed-by: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Cc: David Ahern <dsahern@kernel.org>

Hi Daniel,

sorry I was a bit to hasty in hitting the send button for my previous
message. I have a some more minor feedback on this series.

> diff --git a/net/core/dev.c b/net/core/dev.c
> index 0d548431f3fa..75db81496db5 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -10049,6 +10049,44 @@ void netif_tx_stop_all_queues(struct net_device *dev)
>  }
>  EXPORT_SYMBOL(netif_tx_stop_all_queues);
>  
> +static int netdev_do_alloc_pcpu_stats(struct net_device *dev)
> +{
> +	void __percpu *v;
> +
> +	switch (dev->pcpu_stat_type) {
> +	case NETDEV_PCPU_STAT_NONE:
> +		return 0;
> +	case NETDEV_PCPU_STAT_LSTATS:
> +		v = dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats);
> +		break;
> +	case NETDEV_PCPU_STAT_TSTATS:
> +		v = dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
> +		break;
> +	case NETDEV_PCPU_STAT_DSTATS:
> +		v = dev->dstats = netdev_alloc_pcpu_stats(struct pcpu_dstats);
> +		break;
> +	}
> +
> +	return v ? 0 : -ENOMEM;

Perhaps this cannot happen, but if none of the cases in the switch
statement are met, then v will be uninitialised here.

As flagged by Smatch.

> +}
> +

...

> @@ -10469,6 +10513,7 @@ void netdev_run_todo(void)
>  		WARN_ON(rcu_access_pointer(dev->ip_ptr));
>  		WARN_ON(rcu_access_pointer(dev->ip6_ptr));
>  
> +		netdev_do_free_pcpu_stats(dev);
>  		if (dev->priv_destructor)
>  			dev->priv_destructor(dev);
>  		if (dev->needs_free_netdev)

nit: the hunk above seems unnecessary; one blank line is enough.

  parent reply	other threads:[~2023-11-13 10:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-12 20:30 [PATCH bpf v2 0/8] bpf_redirect_peer fixes Daniel Borkmann
2023-11-12 20:30 ` [PATCH bpf v2 1/8] net, vrf: Move dstats structure to core Daniel Borkmann
2023-11-13  8:51   ` Nikolay Aleksandrov
2023-11-12 20:30 ` [PATCH bpf v2 2/8] net: Move {l,t,d}stats allocation to core and convert veth & vrf Daniel Borkmann
2023-11-13  8:52   ` Nikolay Aleksandrov
2023-11-13  9:57   ` Simon Horman
2023-11-13 13:04     ` Daniel Borkmann
2023-11-13 10:03   ` Simon Horman [this message]
2023-11-13 13:05     ` Daniel Borkmann
2023-11-13 16:15       ` Simon Horman
2023-11-12 20:30 ` [PATCH bpf v2 3/8] netkit: Add tstats per-CPU traffic counters Daniel Borkmann
2023-11-12 20:30 ` [PATCH bpf v2 4/8] veth: Use " Daniel Borkmann
2023-11-12 22:09   ` Peilin Ye
2023-11-12 22:12     ` Daniel Borkmann
2023-11-13  8:53   ` Nikolay Aleksandrov
2023-11-12 20:30 ` [PATCH bpf v2 5/8] bpf: Fix dev's rx stats for bpf_redirect_peer traffic Daniel Borkmann
2023-11-13  8:54   ` Nikolay Aleksandrov
2023-11-12 20:30 ` [PATCH bpf v2 6/8] bpf, netkit: Add indirect call wrapper for fetching peer dev Daniel Borkmann
2023-11-12 20:30 ` [PATCH bpf v2 7/8] selftests/bpf: De-veth-ize the tc_redirect test case Daniel Borkmann
2023-11-13  8:55   ` Nikolay Aleksandrov
2023-11-12 20:30 ` [PATCH bpf v2 8/8] selftests/bpf: Add netkit to tc_redirect selftest Daniel Borkmann
2023-11-13  8:55   ` Nikolay Aleksandrov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231113100305.GO705326@kernel.org \
    --to=horms@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dsahern@kernel.org \
    --cc=kuba@kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=razor@blackwall.org \
    --cc=sdf@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.