netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Wen Gu <guwen@linux.alibaba.com>
Cc: wenjia@linux.ibm.com, jaka@linux.ibm.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	alibuda@linux.alibaba.com, tonylu@linux.alibaba.com,
	linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next 2/2] net/smc: introduce statistics for ringbufs usage of net namespace
Date: Tue, 6 Aug 2024 16:26:32 +0100	[thread overview]
Message-ID: <20240806152632.GB2636630@kernel.org> (raw)
In-Reply-To: <9fbf960d-f279-4e31-90f0-0243eeb7298f@linux.alibaba.com>

On Tue, Aug 06, 2024 at 09:07:40PM +0800, Wen Gu wrote:
> 
> 
> On 2024/8/6 18:49, Simon Horman wrote:
> > On Mon, Aug 05, 2024 at 05:05:51PM +0800, Wen Gu wrote:
> > > The buffer size histograms in smc_stats, namely rx/tx_rmbsize, record
> > > the sizes of ringbufs for all connections that have ever appeared in
> > > the net namespace. They are incremental and we cannot know the actual
> > > ringbufs usage from these. So here introduces statistics for current
> > > ringbufs usage of existing smc connections in the net namespace into
> > > smc_stats, it will be incremented when new connection uses a ringbuf
> > > and decremented when the ringbuf is unused.
> > > 
> > > Signed-off-by: Wen Gu <guwen@linux.alibaba.com>
> > 
> > ...
> > 
> > > diff --git a/net/smc/smc_stats.h b/net/smc/smc_stats.h
> > 
> > ...
> > 
> > > @@ -135,38 +137,45 @@ do { \
> > >   } \
> > >   while (0)
> > > -#define SMC_STAT_RMB_SIZE_SUB(_smc_stats, _tech, k, _len) \
> > > +#define SMC_STAT_RMB_SIZE_SUB(_smc_stats, _tech, k, _is_add, _len) \
> > >   do { \
> > > +	typeof(_is_add) is_a = (_is_add); \
> > >   	typeof(_len) _l = (_len); \
> > >   	typeof(_tech) t = (_tech); \
> > >   	int _pos; \
> > >   	int m = SMC_BUF_MAX - 1; \
> > >   	if (_l <= 0) \
> > >   		break; \
> > > -	_pos = fls((_l - 1) >> 13); \
> > > -	_pos = (_pos <= m) ? _pos : m; \
> > > -	this_cpu_inc((*(_smc_stats)).smc[t].k ## _rmbsize.buf[_pos]); \
> > > +	if (is_a) { \
> > > +		_pos = fls((_l - 1) >> 13); \
> > > +		_pos = (_pos <= m) ? _pos : m; \
> > > +		this_cpu_inc((*(_smc_stats)).smc[t].k ## _rmbsize.buf[_pos]); \
> > > +		this_cpu_add((*(_smc_stats)).smc[t].k ## _rmbuse, _l); \
> > 
> > Nit:
> > 
> > I see that due to the construction of the caller, SMC_STAT_RMB_SIZE(),
> > it will not occur. But checkpatch warns of possible side effects
> > from reuse of _smc_stats.
> > 
> > As great care seems to have been taken in these macros to avoid such
> > problems, even if theoretical, perhaps it is worth doing so here too.
> > 
> > f.e. A macro-local variable could store (*(_smc_stats)).smc[t] which
> >       I think would both resolve the problem mentioned, and make some
> >       lines shorter (and maybe easier to read).
> > 
> 
> It makes sense. I will use a macro-local variable of smc_stats. Thank you!

Great, thanks.

  reply	other threads:[~2024-08-06 15:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-05  9:05 [PATCH net-next 0/2] net/smc: introduce ringbufs usage statistics Wen Gu
2024-08-05  9:05 ` [PATCH net-next 1/2] net/smc: introduce statistics for allocated ringbufs of link group Wen Gu
2024-08-06 10:49   ` Simon Horman
2024-08-06 12:23     ` Wen Gu
2024-08-05  9:05 ` [PATCH net-next 2/2] net/smc: introduce statistics for ringbufs usage of net namespace Wen Gu
2024-08-06 10:49   ` Simon Horman
2024-08-06 13:07     ` Wen Gu
2024-08-06 15:26       ` Simon Horman [this message]
2024-08-06  3:52 ` [PATCH net-next 0/2] net/smc: introduce ringbufs usage statistics shaozhengchao
2024-08-06 11:54   ` Wen Gu

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=20240806152632.GB2636630@kernel.org \
    --to=horms@kernel.org \
    --cc=alibuda@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=guwen@linux.alibaba.com \
    --cc=jaka@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tonylu@linux.alibaba.com \
    --cc=wenjia@linux.ibm.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).