Netdev List
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: dcaratti@redhat.com
Cc: edumazet@google.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com,
	jiri@resnulli.us, netdev@vger.kernel.org, ivecera@redhat.com
Subject: Re: [PATCH net v2] net/sched: act_police: fix race condition on state variables
Date: Tue, 20 Nov 2018 15:01:22 -0800 (PST)	[thread overview]
Message-ID: <20181120.150122.966909501495254169.davem@davemloft.net> (raw)
In-Reply-To: <541a3b91af953326fa8f8fe046f0c284274377ff.1542748323.git.dcaratti@redhat.com>

From: Davide Caratti <dcaratti@redhat.com>
Date: Tue, 20 Nov 2018 22:18:44 +0100

> after 'police' configuration parameters were converted to use RCU instead
> of spinlock, the state variables used to compute the traffic rate (namely
> 'tcfp_toks', 'tcfp_ptoks' and 'tcfp_t_c') are erroneously read/updated in
> the traffic path without any protection.
> 
> Use a dedicated spinlock to avoid race conditions on these variables, and
> ensure proper cache-line alignment. In this way, 'police' is still faster
> than what we observed when 'tcf_lock' was used in the traffic path _ i.e.
> reverting commit 2d550dbad83c ("net/sched: act_police: don't use spinlock
> in the data path"). Moreover, we preserve the throughput improvement that
> was obtained after 'police' started using per-cpu counters, when 'avrate'
> is used instead of 'rate'.
> 
> Changes since v1 (thanks to Eric Dumazet):
> - call ktime_get_ns() before acquiring the lock in the traffic path
> - use a dedicated spinlock instead of tcf_lock
> - improve cache-line usage
> 
> Fixes: 2d550dbad83c ("net/sched: act_police: don't use spinlock in the data path")
> Reported-and-suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Davide Caratti <dcaratti@redhat.com>

Applied.

  parent reply	other threads:[~2018-11-21 10:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-20 21:18 [PATCH net v2] net/sched: act_police: fix race condition on state variables Davide Caratti
2018-11-20 21:39 ` Eric Dumazet
2018-11-20 22:29 ` Cong Wang
2018-11-20 23:01 ` David Miller [this message]
2018-11-20 23:29   ` Eric Dumazet
2018-11-21  4:13     ` Cong Wang
2018-11-21  8:18       ` Davide Caratti
2018-11-21 18:05 ` Cong Wang

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=20181120.150122.966909501495254169.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=dcaratti@redhat.com \
    --cc=edumazet@google.com \
    --cc=ivecera@redhat.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.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