Re: [PATCN v2 net-next] net_sched: gen_estimator: complete rewrite of rate estimators

2016-12-04 Thread kbuild test robot
Hi Eric,

[auto build test WARNING on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Eric-Dumazet/net_sched-gen_estimator-complete-rewrite-of-rate-estimators/20161204-182009
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   include/net/sock.h:467: warning: No description found for parameter 
'__sk_flags_offset[0]'
   include/net/sock.h:467: warning: No description found for parameter 'sk_uid'
>> net/core/gen_stats.c:209: warning: No description found for parameter 'ptr'
>> net/core/gen_stats.c:209: warning: Excess function parameter 'b' description 
>> in 'gnet_stats_copy_rate_est'
>> net/core/gen_stats.c:209: warning: Excess function parameter 'r' description 
>> in 'gnet_stats_copy_rate_est'

vim +/ptr +209 net/core/gen_stats.c

^1da177e Linus Torvalds 2005-04-16  193  
^1da177e Linus Torvalds 2005-04-16  194  /**
^1da177e Linus Torvalds 2005-04-16  195   * gnet_stats_copy_rate_est - copy 
rate estimator statistics into statistics TLV
^1da177e Linus Torvalds 2005-04-16  196   * @d: dumping handle
d250a5f9 Eric Dumazet   2009-10-02  197   * @b: basic statistics
^1da177e Linus Torvalds 2005-04-16  198   * @r: rate estimator statistics
^1da177e Linus Torvalds 2005-04-16  199   *
^1da177e Linus Torvalds 2005-04-16  200   * Appends the rate estimator 
statistics to the top level TLV created by
^1da177e Linus Torvalds 2005-04-16  201   * gnet_stats_start_copy().
^1da177e Linus Torvalds 2005-04-16  202   *
^1da177e Linus Torvalds 2005-04-16  203   * Returns 0 on success or -1 with the 
statistic lock released
^1da177e Linus Torvalds 2005-04-16  204   * if the room in the socket buffer 
was not sufficient.
^1da177e Linus Torvalds 2005-04-16  205   */
^1da177e Linus Torvalds 2005-04-16  206  int
d250a5f9 Eric Dumazet   2009-10-02  207  gnet_stats_copy_rate_est(struct 
gnet_dump *d,
f96b940b Eric Dumazet   2016-12-03  208  struct 
net_rate_estimator __rcu **ptr)
^1da177e Linus Torvalds 2005-04-16 @209  {
f96b940b Eric Dumazet   2016-12-03  210 struct gnet_stats_rate_est64 
sample;
45203a3b Eric Dumazet   2013-06-06  211 struct gnet_stats_rate_est est;
45203a3b Eric Dumazet   2013-06-06  212 int res;
45203a3b Eric Dumazet   2013-06-06  213  
f96b940b Eric Dumazet   2016-12-03  214 if (!gen_estimator_read(ptr, 
))
d250a5f9 Eric Dumazet   2009-10-02  215 return 0;
f96b940b Eric Dumazet   2016-12-03  216 est.bps = min_t(u64, UINT_MAX, 
sample.bps);
45203a3b Eric Dumazet   2013-06-06  217 /* we have some time before 
reaching 2^32 packets per second */

:: The code at line 209 was first introduced by commit
:: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:: TO: Linus Torvalds 
:: CC: Linus Torvalds 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCN v2 net-next] net_sched: gen_estimator: complete rewrite of rate estimators

2016-12-03 Thread Eric Dumazet
From: Eric Dumazet 

1) Old code was hard to maintain, due to complex lock chains.
   (We probably will be able to remove some kfree_rcu() in callers)

2) Using a single timer to update all estimators does not scale.

3) Code was buggy on 32bit kernel (WRITE_ONCE() on 64bit quantity
   is not supposed to work well)

In this rewrite :

- I removed the RB tree that had to be scanned in
gen_estimator_active(). qdisc dumps should be much faster.

- Each estimator has its own timer.

- Estimations are maintained in net_rate_estimator structure,
  instead of dirtying the qdisc. Minor, but part of the simplification.

- Reading the estimator uses RCU and a seqcount to provide proper
  support for 32bit kernels.

- We reduce memory need when estimators are not used, since
  we store a pointer, instead of the bytes/packets counters.

- xt_rateest_mt() no longer has to grab a spinlock.
  (In the future, xt_rateest_tg() could be switched to per cpu counters)

Signed-off-by: Eric Dumazet 
---
v2: removed unwanted changes to tcp_output.c
Renamed some parameters to please htmldoc

 include/net/act_api.h  |2 
 include/net/gen_stats.h|   17 -
 include/net/netfilter/xt_rateest.h |   10 
 include/net/sch_generic.h  |2 
 net/core/gen_estimator.c   |  299 +--
 net/core/gen_stats.c   |   17 -
 net/netfilter/xt_RATEEST.c |4 
 net/netfilter/xt_rateest.c |   28 +-
 net/sched/act_api.c|9 
 net/sched/act_police.c |   21 +
 net/sched/sch_api.c|2 
 net/sched/sch_cbq.c|6 
 net/sched/sch_drr.c|6 
 net/sched/sch_generic.c|2 
 net/sched/sch_hfsc.c   |6 
 net/sched/sch_htb.c|6 
 net/sched/sch_qfq.c|8 
 17 files changed, 181 insertions(+), 264 deletions(-)

diff --git a/include/net/act_api.h b/include/net/act_api.h
index 
9dddf77a69ccbcb003cfa66bcc0de337f78f3dae..1d716449209e4753a297c61a287077a1eb96e6d8
 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -36,7 +36,7 @@ struct tc_action {
struct tcf_ttcfa_tm;
struct gnet_stats_basic_packed  tcfa_bstats;
struct gnet_stats_queue tcfa_qstats;
-   struct gnet_stats_rate_est64tcfa_rate_est;
+   struct net_rate_estimator __rcu *tcfa_rate_est;
spinlock_t  tcfa_lock;
struct rcu_head tcfa_rcu;
struct gnet_stats_basic_cpu __percpu *cpu_bstats;
diff --git a/include/net/gen_stats.h b/include/net/gen_stats.h
index 
231e121cc7d9c72075e7e6dde3655d631f64a1c4..8b7aa370e7a4af61fcb71ed751dba72ebead6143
 100644
--- a/include/net/gen_stats.h
+++ b/include/net/gen_stats.h
@@ -11,6 +11,8 @@ struct gnet_stats_basic_cpu {
struct u64_stats_sync syncp;
 };
 
+struct net_rate_estimator;
+
 struct gnet_dump {
spinlock_t *  lock;
struct sk_buff *  skb;
@@ -42,8 +44,7 @@ void __gnet_stats_copy_basic(const seqcount_t *running,
 struct gnet_stats_basic_cpu __percpu *cpu,
 struct gnet_stats_basic_packed *b);
 int gnet_stats_copy_rate_est(struct gnet_dump *d,
-const struct gnet_stats_basic_packed *b,
-struct gnet_stats_rate_est64 *r);
+struct net_rate_estimator __rcu **ptr);
 int gnet_stats_copy_queue(struct gnet_dump *d,
  struct gnet_stats_queue __percpu *cpu_q,
  struct gnet_stats_queue *q, __u32 qlen);
@@ -53,16 +54,16 @@ int gnet_stats_finish_copy(struct gnet_dump *d);
 
 int gen_new_estimator(struct gnet_stats_basic_packed *bstats,
  struct gnet_stats_basic_cpu __percpu *cpu_bstats,
- struct gnet_stats_rate_est64 *rate_est,
+ struct net_rate_estimator __rcu **rate_est,
  spinlock_t *stats_lock,
  seqcount_t *running, struct nlattr *opt);
-void gen_kill_estimator(struct gnet_stats_basic_packed *bstats,
-   struct gnet_stats_rate_est64 *rate_est);
+void gen_kill_estimator(struct net_rate_estimator __rcu **ptr);
 int gen_replace_estimator(struct gnet_stats_basic_packed *bstats,
  struct gnet_stats_basic_cpu __percpu *cpu_bstats,
- struct gnet_stats_rate_est64 *rate_est,
+ struct net_rate_estimator __rcu **ptr,
  spinlock_t *stats_lock,
  seqcount_t *running, struct nlattr *opt);
-bool gen_estimator_active(const struct gnet_stats_basic_packed *bstats,
- const struct gnet_stats_rate_est64 *rate_est);
+bool gen_estimator_active(struct net_rate_estimator __rcu **ptr);
+bool gen_estimator_read(struct