netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Maksym Kutsevol <max@kutsevol.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] netcons: Add udp send fail statistics to netconsole
Date: Fri, 30 Aug 2024 01:45:27 -0700	[thread overview]
Message-ID: <ZtGGp9DRTy6X+PLv@gmail.com> (raw)
In-Reply-To: <20240828214524.1867954-2-max@kutsevol.com>

Hello Maksym,

On Wed, Aug 28, 2024 at 02:33:49PM -0700, Maksym Kutsevol wrote:
> diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
> index 9c09293b5258..e14b13a8e0d2 100644
> --- a/drivers/net/netconsole.c
> +++ b/drivers/net/netconsole.c
> @@ -36,6 +36,7 @@
>  #include <linux/inet.h>
>  #include <linux/configfs.h>
>  #include <linux/etherdevice.h>
> +#include <linux/u64_stats_sync.h>
>  #include <linux/utsname.h>
>  
>  MODULE_AUTHOR("Maintainer: Matt Mackall <mpm@selenic.com>");

I am afraid that you are not build the patch against net-next, since
this line was changed a while ago.

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=10a6545f0bdc

Please develop on top of net-next, otherwise the patch might not apply
on top of net-next.

> +/**
> + * netpoll_send_udp_count_errs - Wrapper for netpoll_send_udp that counts errors
> + * @nt: target to send message to
> + * @msg: message to send
> + * @len: length of message
> + *
> + * Calls netpoll_send_udp and classifies the return value. If an error
> + * occurred it increments statistics in nt->stats accordingly.
> + * Noop if CONFIG_NETCONSOLE_DYNAMIC is disabled.
> + */
> +// static void netpoll_send_udp_count_errs(struct netpoll *np, const char *msg, int len)

Have you forgot to remove the line above?

> +static void netpoll_send_udp_count_errs(struct netconsole_target *nt, const char *msg, int len)
> +{
> +#ifdef CONFIG_NETCONSOLE_DYNAMIC
> +	int result = netpoll_send_udp(&nt->np, msg, len);
> +	result = NET_XMIT_DROP;

Could you please clarify why do you want to overwrite `result` here with
NET_XMIT_DROP? It seems wrong.

> +	if (result == NET_XMIT_DROP) {
> +		u64_stats_update_begin(&nt->stats.syncp);
> +		u64_stats_inc(&nt->stats.xmit_drop_count);
> +		u64_stats_update_end(&nt->stats.syncp);
> +	} else if (result == -ENOMEM) {
> +		u64_stats_update_begin(&nt->stats.syncp);
> +		u64_stats_inc(&nt->stats.enomem_count);
> +		u64_stats_update_end(&nt->stats.syncp);
> +	};
> +#else
> +	netpoll_send_udp(&nt->np, msg, len);
> +#endif

I am not sure this if/else/endif is the best way. I am wondering if
something like this would make the code simpler (uncompiled/untested):

static void netpoll_send_udp_count_errs(struct netconsole_target *nt, const char *msg, int len)
{
        int __maybe_unused result;

        result = netpoll_send_udp(&nt->np, msg, len);
#ifdef CONFIG_NETCONSOLE_DYNAMIC
	switch (result) {
	case NET_XMIT_DROP:
                u64_stats_update_begin(&nt->stats.syncp);
                u64_stats_inc(&nt->stats.xmit_drop_count);
                u64_stats_update_end(&nt->stats.syncp);
		breadk;
        case ENOMEM:
                u64_stats_update_begin(&nt->stats.syncp);
                u64_stats_inc(&nt->stats.enomem_count);
                u64_stats_update_end(&nt->stats.syncp);
		break;
        };
#endif

Thanks for working on it.
--breno

  reply	other threads:[~2024-08-30  8:45 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-24 21:50 [PATCH 1/2] netpoll: Make netpoll_send_udp return status instead of void Maksym Kutsevol
2024-08-24 21:50 ` [PATCH 2/2] netcons: Add udp send fail statistics to netconsole Maksym Kutsevol
2024-08-26 21:35   ` Jakub Kicinski
2024-08-26 23:55     ` Maksym Kutsevol
2024-08-27 13:59       ` Jakub Kicinski
2024-08-28 15:03         ` Maksym Kutsevol
2024-08-28 15:24           ` Breno Leitao
2024-08-28 15:33             ` Maksym Kutsevol
2024-08-27  6:32   ` kernel test robot
2024-08-27  9:36   ` kernel test robot
2024-08-27 12:18   ` Breno Leitao
2024-08-28 15:04     ` Maksym Kutsevol
     [not found]     ` <CAO6EAnVXXfQRK1xWoxO+dQwQsftw3bhOz27cQPNX=TzCutkrQQ@mail.gmail.com>
     [not found]       ` <Zs8//o3EDLtt+eTY@gmail.com>
2024-08-28 15:31         ` Maksym Kutsevol
2024-08-28 21:33 ` [PATCH v2 1/2] netpoll: Make netpoll_send_udp return status instead of void Maksym Kutsevol
2024-08-28 21:33   ` [PATCH v2 2/2] netcons: Add udp send fail statistics to netconsole Maksym Kutsevol
2024-08-30  8:45     ` Breno Leitao [this message]
2024-08-30 12:58       ` Maksym Kutsevol
2024-08-30 14:12         ` Breno Leitao
2024-08-30 15:37           ` Maksym Kutsevol
2024-08-28 22:57   ` [PATCH v2 1/2] netpoll: Make netpoll_send_udp return status instead of void Jakub Kicinski
2024-08-28 23:16     ` Maksym Kutsevol
2024-08-30  8:46   ` Breno Leitao

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=ZtGGp9DRTy6X+PLv@gmail.com \
    --to=leitao@debian.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=max@kutsevol.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 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).