* [PATCH net-next v5 2/3] net: introduce reciprocal_scale helper and convert users
From: Hannes Frederic Sowa @ 2014-01-22 1:29 UTC (permalink / raw)
To: netdev; +Cc: Daniel Borkmann, Jakub Zawadzki, Eric Dumazet, linux-kernel
In-Reply-To: <1390354181-5080-1-git-send-email-hannes@stressinduktion.org>
From: Daniel Borkmann <dborkman@redhat.com>
As David Laight suggests, we shouldn't necessarily call this
reciprocal_divide() when users didn't requested a reciprocal_value();
lets keep the basic idea and call it reciprocal_scale(). More
background information on this topic can be found in [1].
Joint work with Hannes Frederic Sowa.
[1] http://homepage.cs.uiowa.edu/~jones/bcd/divide.html
Suggested-by: David Laight <david.laight@aculab.com>
Cc: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
---
include/linux/kernel.h | 19 +++++++++++++++++++
include/net/codel.h | 4 +---
net/packet/af_packet.c | 3 +--
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index ecb8754..03d8a6b 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -193,6 +193,25 @@ extern int _cond_resched(void);
(__x < 0) ? -__x : __x; \
})
+/**
+ * reciprocal_scale - "scale" a value into range [0, ep_ro)
+ * @val: value
+ * @ep_ro: right open interval endpoint
+ *
+ * Perform a "reciprocal multiplication" in order to "scale" a value into
+ * range [0, ep_ro), where the upper interval endpoint is right-open.
+ * This is useful, e.g. for accessing a index of an array containing
+ * ep_ro elements, for example. Think of it as sort of modulus, only that
+ * the result isn't that of modulo. ;) Note that if initial input is a
+ * small value, then result will return 0.
+ *
+ * Return: a result based on val in interval [0, ep_ro).
+ */
+static inline u32 reciprocal_scale(u32 val, u32 ep_ro)
+{
+ return (u32)(((u64) val * ep_ro) >> 32);
+}
+
#if defined(CONFIG_MMU) && \
(defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP))
void might_fault(void);
diff --git a/include/net/codel.h b/include/net/codel.h
index 3b04ff5..fe0eab3 100644
--- a/include/net/codel.h
+++ b/include/net/codel.h
@@ -46,7 +46,6 @@
#include <linux/skbuff.h>
#include <net/pkt_sched.h>
#include <net/inet_ecn.h>
-#include <linux/reciprocal_div.h>
/* Controlling Queue Delay (CoDel) algorithm
* =========================================
@@ -211,10 +210,9 @@ static codel_time_t codel_control_law(codel_time_t t,
codel_time_t interval,
u32 rec_inv_sqrt)
{
- return t + reciprocal_divide(interval, rec_inv_sqrt << REC_INV_SQRT_SHIFT);
+ return t + reciprocal_scale(interval, rec_inv_sqrt << REC_INV_SQRT_SHIFT);
}
-
static bool codel_should_drop(const struct sk_buff *skb,
struct Qdisc *sch,
struct codel_vars *vars,
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index df3cbdd..9734616 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -88,7 +88,6 @@
#include <linux/virtio_net.h>
#include <linux/errqueue.h>
#include <linux/net_tstamp.h>
-#include <linux/reciprocal_div.h>
#include <linux/percpu.h>
#ifdef CONFIG_INET
#include <net/inet_common.h>
@@ -1262,7 +1261,7 @@ static unsigned int fanout_demux_hash(struct packet_fanout *f,
struct sk_buff *skb,
unsigned int num)
{
- return reciprocal_divide(skb->rxhash, num);
+ return reciprocal_scale(skb->rxhash, num);
}
static unsigned int fanout_demux_lb(struct packet_fanout *f,
--
1.8.4.2
^ permalink raw reply related
* [PATCH net-next v5 0/0] reciprocal_divide update
From: Hannes Frederic Sowa @ 2014-01-22 1:29 UTC (permalink / raw)
To: netdev
This patch is on top of aee636c4809fa5 ("bpf: do not use reciprocal
divide") from Eric that sits in net tree. It will not create a merge
conflict, but it depends on this one, so we suggest, if possible, to
merge net into net-next.
We are proposing this change with only small modifications from the
v2 version, namely updating the name of trim to reciprocal_scale
(as commented on by Ben Hutchings and Eric Dumazet, thanks!).
We thought about introducing the reciprocal_divide algorithm in
parallel to the one already used by the kernel but faced organizational
issues, leading us to the conclusion that it is best to just replace
the old one: We could not come up with names for the different
implementations and also with a way to describe the differences to
guide developers which one to choose in which situation. This is
because we cannot specify the correct semantics for the version
which is currently used by the kernel. Altough it seems to not be
causing problems in the kernel, we cannot surely say so in the
case of flex_array for the future. Current usage seems ok, but
future users could run into problems.
Changelog:
v1->v2:
- changed name to prandom_u32_max in p1
- changed name to trim in p2
- reworked code in p3
v2->v3:
- p1 and p3 stays unchanged, only small update in commit
message in p3
- changed name to reciprocal_scale in p2
- fixed kernel doc format
v3->v4:
- pseduo -> pseudo (thanks to Tilman Schmidt)
v4->v5:
- fix pseduo -> pseudo for real now, sorry for the noise
Thanks !
Daniel Borkmann (2):
random32: add prandom_u32_max and convert open coded users
net: introduce reciprocal_scale helper and convert users
Hannes Frederic Sowa (1):
reciprocal_divide: update/correction of the algorithm
drivers/net/bonding/bond_main.c | 24 ++++++++++++++++-------
drivers/net/bonding/bond_netlink.c | 4 ----
drivers/net/bonding/bond_options.c | 15 +++++++++-----
drivers/net/bonding/bond_sysfs.c | 5 -----
drivers/net/bonding/bonding.h | 3 +++
drivers/net/team/team_mode_random.c | 8 +-------
include/linux/flex_array.h | 3 ++-
include/linux/kernel.h | 19 ++++++++++++++++++
include/linux/random.h | 18 ++++++++++++++++-
include/linux/reciprocal_div.h | 39 ++++++++++++++++++++-----------------
include/linux/slab_def.h | 4 +++-
include/net/codel.h | 4 +---
include/net/red.h | 3 ++-
lib/flex_array.c | 7 ++++++-
lib/reciprocal_div.c | 24 +++++++++++++++++++----
net/packet/af_packet.c | 5 ++---
net/sched/sch_choke.c | 9 +--------
net/sched/sch_netem.c | 6 ++++--
18 files changed, 129 insertions(+), 71 deletions(-)
^ permalink raw reply
* [PATCH net-next v5 3/3] reciprocal_divide: update/correction of the algorithm
From: Hannes Frederic Sowa @ 2014-01-22 1:29 UTC (permalink / raw)
To: netdev
Cc: Eric Dumazet, Austin S Hemmelgarn, linux-kernel, Jesse Gross,
Jamal Hadi Salim, Stephen Hemminger, Matt Mackall, Pekka Enberg,
Christoph Lameter, Andy Gospodarek, Veaceslav Falico,
Jay Vosburgh, Jakub Zawadzki, Daniel Borkmann
In-Reply-To: <1390354181-5080-1-git-send-email-hannes@stressinduktion.org>
Jakub Zawadzki noticed that some divisions by reciprocal_divide()
were not correct [1][2], which he could also show with BPF code
after divisions are transformed into reciprocal_value() for runtime
invariance which can be passed to reciprocal_divide() later on;
reverse in BPF dump ended up with a different, off-by-one K in
some situations.
This has been fixed by Eric Dumazet in commit aee636c4809fa5
("bpf: do not use reciprocal divide"). This follow-up patch
improves reciprocal_value() and reciprocal_divide() to work in
all cases by using Granlund and Montgomery method, so that also
future use is safe and without any non-obvious side-effects.
Known problems with the old implementation were that division by 1
always returned 0 and some off-by-ones when the dividend and divisor
where very large. This seemed to not be problematic with its
current users, as far as we can tell. Eric Dumazet checked for
the slab usage, we cannot surely say so in the case of flex_array.
Still, in order to fix that, we propose an extension from the
original implementation from commit 6a2d7a955d8d resp. [3][4],
by using the algorithm proposed in "Division by Invariant Integers
Using Multiplication" [5], Torbjörn Granlund and Peter L.
Montgomery, that is, pseudocode for q = n/d where q, n, d is in
u32 universe:
1) Initialization:
int l = ceil(log_2 d)
uword m' = floor((1<<32)*((1<<l)-d)/d)+1
int sh_1 = min(l,1)
int sh_2 = max(l-1,0)
2) For q = n/d, all uword:
uword t = (n*m')>>32
q = (t+((n-t)>>sh_1))>>sh_2
The assembler implementation from Agner Fog [6] also helped a lot
while implementing. We have tested the implementation on x86_64,
ppc64, i686, s390x; on x86_64/haswell we're still half the latency
compared to normal divide.
Joint work with Daniel Borkmann.
[1] http://www.wireshark.org/~darkjames/reciprocal-buggy.c
[2] http://www.wireshark.org/~darkjames/set-and-dump-filter-k-bug.c
[3] https://gmplib.org/~tege/division-paper.pdf
[4] http://homepage.cs.uiowa.edu/~jones/bcd/divide.html
[5] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.1.2556
[6] http://www.agner.org/optimize/asmlib.zip
Reported-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Austin S Hemmelgarn <ahferroin7@gmail.com>
Cc: linux-kernel@vger.kernel.org
Cc: Jesse Gross <jesse@nicira.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: Andy Gospodarek <andy@greyhouse.net>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
drivers/net/bonding/bond_main.c | 24 ++++++++++++++++-------
drivers/net/bonding/bond_netlink.c | 4 ----
drivers/net/bonding/bond_options.c | 15 ++++++++++-----
drivers/net/bonding/bond_sysfs.c | 5 -----
drivers/net/bonding/bonding.h | 3 +++
include/linux/flex_array.h | 3 ++-
include/linux/reciprocal_div.h | 39 ++++++++++++++++++++------------------
include/linux/slab_def.h | 4 +++-
include/net/red.h | 3 ++-
lib/flex_array.c | 7 ++++++-
lib/reciprocal_div.c | 24 +++++++++++++++++++----
net/sched/sch_netem.c | 6 ++++--
12 files changed, 88 insertions(+), 49 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 3220b48..f100bd9 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -79,7 +79,6 @@
#include <net/pkt_sched.h>
#include <linux/rculist.h>
#include <net/flow_keys.h>
-#include <linux/reciprocal_div.h>
#include "bonding.h"
#include "bond_3ad.h"
#include "bond_alb.h"
@@ -3596,8 +3595,9 @@ static void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int sl
*/
static u32 bond_rr_gen_slave_id(struct bonding *bond)
{
- int packets_per_slave = bond->params.packets_per_slave;
u32 slave_id;
+ struct reciprocal_value reciprocal_packets_per_slave;
+ int packets_per_slave = bond->params.packets_per_slave;
switch (packets_per_slave) {
case 0:
@@ -3607,8 +3607,10 @@ static u32 bond_rr_gen_slave_id(struct bonding *bond)
slave_id = bond->rr_tx_counter;
break;
default:
+ reciprocal_packets_per_slave =
+ bond->params.reciprocal_packets_per_slave;
slave_id = reciprocal_divide(bond->rr_tx_counter,
- packets_per_slave);
+ reciprocal_packets_per_slave);
break;
}
bond->rr_tx_counter++;
@@ -4343,10 +4345,18 @@ static int bond_check_params(struct bond_params *params)
params->resend_igmp = resend_igmp;
params->min_links = min_links;
params->lp_interval = lp_interval;
- if (packets_per_slave > 1)
- params->packets_per_slave = reciprocal_value(packets_per_slave);
- else
- params->packets_per_slave = packets_per_slave;
+ params->packets_per_slave = packets_per_slave;
+ if (packets_per_slave > 0) {
+ params->reciprocal_packets_per_slave =
+ reciprocal_value(packets_per_slave);
+ } else {
+ /* reciprocal_packets_per_slave is unused if
+ * packets_per_slave is 0 or 1, just initialize it
+ */
+ params->reciprocal_packets_per_slave =
+ (struct reciprocal_value) { 0 };
+ }
+
if (primary) {
strncpy(params->primary, primary, IFNAMSIZ);
params->primary[IFNAMSIZ - 1] = 0;
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 21c6488..e852655 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -19,7 +19,6 @@
#include <linux/if_ether.h>
#include <net/netlink.h>
#include <net/rtnetlink.h>
-#include <linux/reciprocal_div.h>
#include "bonding.h"
int bond_get_slave(struct net_device *slave_dev, struct sk_buff *skb)
@@ -452,9 +451,6 @@ static int bond_fill_info(struct sk_buff *skb,
goto nla_put_failure;
packets_per_slave = bond->params.packets_per_slave;
- if (packets_per_slave > 1)
- packets_per_slave = reciprocal_value(packets_per_slave);
-
if (nla_put_u32(skb, IFLA_BOND_PACKETS_PER_SLAVE,
packets_per_slave))
goto nla_put_failure;
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 945a666..85e4348 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -16,7 +16,6 @@
#include <linux/netdevice.h>
#include <linux/rwlock.h>
#include <linux/rcupdate.h>
-#include <linux/reciprocal_div.h>
#include "bonding.h"
int bond_option_mode_set(struct bonding *bond, int mode)
@@ -671,11 +670,17 @@ int bond_option_packets_per_slave_set(struct bonding *bond,
pr_warn("%s: Warning: packets_per_slave has effect only in balance-rr mode\n",
bond->dev->name);
- if (packets_per_slave > 1)
- bond->params.packets_per_slave =
+ bond->params.packets_per_slave = packets_per_slave;
+ if (packets_per_slave > 0) {
+ bond->params.reciprocal_packets_per_slave =
reciprocal_value(packets_per_slave);
- else
- bond->params.packets_per_slave = packets_per_slave;
+ } else {
+ /* reciprocal_packets_per_slave is unused if
+ * packets_per_slave is 0 or 1, just initialize it
+ */
+ bond->params.reciprocal_packets_per_slave =
+ (struct reciprocal_value) { 0 };
+ }
return 0;
}
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 011f163..c083e9a 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -39,7 +39,6 @@
#include <net/net_namespace.h>
#include <net/netns/generic.h>
#include <linux/nsproxy.h>
-#include <linux/reciprocal_div.h>
#include "bonding.h"
@@ -1374,10 +1373,6 @@ static ssize_t bonding_show_packets_per_slave(struct device *d,
{
struct bonding *bond = to_bond(d);
unsigned int packets_per_slave = bond->params.packets_per_slave;
-
- if (packets_per_slave > 1)
- packets_per_slave = reciprocal_value(packets_per_slave);
-
return sprintf(buf, "%u\n", packets_per_slave);
}
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 8a935f8..0a616c4 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -23,6 +23,8 @@
#include <linux/netpoll.h>
#include <linux/inetdevice.h>
#include <linux/etherdevice.h>
+#include <linux/reciprocal_div.h>
+
#include "bond_3ad.h"
#include "bond_alb.h"
@@ -171,6 +173,7 @@ struct bond_params {
int resend_igmp;
int lp_interval;
int packets_per_slave;
+ struct reciprocal_value reciprocal_packets_per_slave;
};
struct bond_parm_tbl {
diff --git a/include/linux/flex_array.h b/include/linux/flex_array.h
index 6843cf1..b6efb0c 100644
--- a/include/linux/flex_array.h
+++ b/include/linux/flex_array.h
@@ -2,6 +2,7 @@
#define _FLEX_ARRAY_H
#include <linux/types.h>
+#include <linux/reciprocal_div.h>
#include <asm/page.h>
#define FLEX_ARRAY_PART_SIZE PAGE_SIZE
@@ -22,7 +23,7 @@ struct flex_array {
int element_size;
int total_nr_elements;
int elems_per_part;
- u32 reciprocal_elems;
+ struct reciprocal_value reciprocal_elems;
struct flex_array_part *parts[];
};
/*
diff --git a/include/linux/reciprocal_div.h b/include/linux/reciprocal_div.h
index f9c90b3..8c5a3fb 100644
--- a/include/linux/reciprocal_div.h
+++ b/include/linux/reciprocal_div.h
@@ -4,29 +4,32 @@
#include <linux/types.h>
/*
- * This file describes reciprocical division.
+ * This algorithm is based on the paper "Division by Invariant
+ * Integers Using Multiplication" by Torbjörn Granlund and Peter
+ * L. Montgomery.
*
- * This optimizes the (A/B) problem, when A and B are two u32
- * and B is a known value (but not known at compile time)
+ * The assembler implementation from Agner Fog, which this code is
+ * based on, can be found here:
+ * http://www.agner.org/optimize/asmlib.zip
*
- * The math principle used is :
- * Let RECIPROCAL_VALUE(B) be (((1LL << 32) + (B - 1))/ B)
- * Then A / B = (u32)(((u64)(A) * (R)) >> 32)
- *
- * This replaces a divide by a multiply (and a shift), and
- * is generally less expensive in CPU cycles.
+ * This optimization for A/B is helpful if the divisor B is mostly
+ * runtime invariant. The reciprocal of B is calculated in the
+ * slow-path with reciprocal_value(). The fast-path can then just use
+ * a much faster multiplication operation with a variable dividend A
+ * to calculate the division A/B.
*/
-/*
- * Computes the reciprocal value (R) for the value B of the divisor.
- * Should not be called before each reciprocal_divide(),
- * or else the performance is slower than a normal divide.
- */
-extern u32 reciprocal_value(u32 B);
+struct reciprocal_value {
+ u32 m;
+ u8 sh1, sh2;
+};
+struct reciprocal_value reciprocal_value(u32 d);
-static inline u32 reciprocal_divide(u32 A, u32 R)
+static inline u32 reciprocal_divide(u32 a, struct reciprocal_value R)
{
- return (u32)(((u64)A * R) >> 32);
+ u32 t = (u32)(((u64)a * R.m) >> 32);
+ return (t + ((a - t) >> R.sh1)) >> R.sh2;
}
-#endif
+
+#endif /* _LINUX_RECIPROCAL_DIV_H */
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index 09bfffb..96e8aba 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -1,6 +1,8 @@
#ifndef _LINUX_SLAB_DEF_H
#define _LINUX_SLAB_DEF_H
+#include <linux/reciprocal_div.h>
+
/*
* Definitions unique to the original Linux SLAB allocator.
*/
@@ -12,7 +14,7 @@ struct kmem_cache {
unsigned int shared;
unsigned int size;
- u32 reciprocal_buffer_size;
+ struct reciprocal_value reciprocal_buffer_size;
/* 2) touched by every alloc & free from the backend */
unsigned int flags; /* constant flags */
diff --git a/include/net/red.h b/include/net/red.h
index 168bb2f..76e0b5f 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -130,7 +130,8 @@ struct red_parms {
u32 qth_max; /* Max avg length threshold: Wlog scaled */
u32 Scell_max;
u32 max_P; /* probability, [0 .. 1.0] 32 scaled */
- u32 max_P_reciprocal; /* reciprocal_value(max_P / qth_delta) */
+ /* reciprocal_value(max_P / qth_delta) */
+ struct reciprocal_value max_P_reciprocal;
u32 qth_delta; /* max_th - min_th */
u32 target_min; /* min_th + 0.4*(max_th - min_th) */
u32 target_max; /* min_th + 0.6*(max_th - min_th) */
diff --git a/lib/flex_array.c b/lib/flex_array.c
index 6948a66..2eed22f 100644
--- a/lib/flex_array.c
+++ b/lib/flex_array.c
@@ -90,8 +90,8 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total,
{
struct flex_array *ret;
int elems_per_part = 0;
- int reciprocal_elems = 0;
int max_size = 0;
+ struct reciprocal_value reciprocal_elems = { 0 };
if (element_size) {
elems_per_part = FLEX_ARRAY_ELEMENTS_PER_PART(element_size);
@@ -119,6 +119,11 @@ EXPORT_SYMBOL(flex_array_alloc);
static int fa_element_to_part_nr(struct flex_array *fa,
unsigned int element_nr)
{
+ /*
+ * if element_size == 0 we don't get here, so we never touch
+ * the zeroed fa->reciprocal_elems, which would yield invalid
+ * results
+ */
return reciprocal_divide(element_nr, fa->reciprocal_elems);
}
diff --git a/lib/reciprocal_div.c b/lib/reciprocal_div.c
index 75510e9..4641524 100644
--- a/lib/reciprocal_div.c
+++ b/lib/reciprocal_div.c
@@ -1,11 +1,27 @@
+#include <linux/kernel.h>
#include <asm/div64.h>
#include <linux/reciprocal_div.h>
#include <linux/export.h>
-u32 reciprocal_value(u32 k)
+/*
+ * For a description of the algorithm please have a look at
+ * include/linux/reciprocal_div.h
+ */
+
+struct reciprocal_value reciprocal_value(u32 d)
{
- u64 val = (1LL << 32) + (k - 1);
- do_div(val, k);
- return (u32)val;
+ struct reciprocal_value R;
+ u64 m;
+ int l;
+
+ l = fls(d - 1);
+ m = ((1ULL << 32) * ((1ULL << l) - d));
+ do_div(m, d);
+ ++m;
+ R.m = (u32)m;
+ R.sh1 = min(l, 1);
+ R.sh2 = max(l - 1, 0);
+
+ return R;
}
EXPORT_SYMBOL(reciprocal_value);
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index a2bfc37..de1059a 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -91,7 +91,7 @@ struct netem_sched_data {
u64 rate;
s32 packet_overhead;
u32 cell_size;
- u32 cell_size_reciprocal;
+ struct reciprocal_value cell_size_reciprocal;
s32 cell_overhead;
struct crndstate {
@@ -725,9 +725,11 @@ static void get_rate(struct Qdisc *sch, const struct nlattr *attr)
q->rate = r->rate;
q->packet_overhead = r->packet_overhead;
q->cell_size = r->cell_size;
+ q->cell_overhead = r->cell_overhead;
if (q->cell_size)
q->cell_size_reciprocal = reciprocal_value(q->cell_size);
- q->cell_overhead = r->cell_overhead;
+ else
+ q->cell_size_reciprocal = (struct reciprocal_value) { 0 };
}
static int get_loss_clg(struct Qdisc *sch, const struct nlattr *attr)
--
1.8.4.2
^ permalink raw reply related
* [PATCH net-next v5 1/3] random32: add prandom_u32_max and convert open coded users
From: Hannes Frederic Sowa @ 2014-01-22 1:29 UTC (permalink / raw)
To: netdev; +Cc: Daniel Borkmann, Jakub Zawadzki, Eric Dumazet, linux-kernel
In-Reply-To: <1390354181-5080-1-git-send-email-hannes@stressinduktion.org>
From: Daniel Borkmann <dborkman@redhat.com>
Many functions have open coded a function that returns a random
number in range [0,N-1]. Under the assumption that we have a PRNG
such as taus113 with being well distributed in [0, ~0U] space,
we can implement such a function as uword t = (n*m')>>32, where
m' is a random number obtained from PRNG, n the right open interval
border and t our resulting random number, with n,m',t in u32 universe.
Lets go with Joe and simply call it prandom_u32_max(), although
technically we have an right open interval endpoint, but that we
have documented. Other users can further be migrated to the new
prandom_u32_max() function later on; for now, we need to make sure
to migrate reciprocal_divide() users for the reciprocal_divide()
follow-up fixup since their function signatures are going to change.
Joint work with Hannes Frederic Sowa.
Cc: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
---
drivers/net/team/team_mode_random.c | 8 +-------
include/linux/random.h | 18 +++++++++++++++++-
net/packet/af_packet.c | 2 +-
net/sched/sch_choke.c | 9 +--------
4 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/drivers/net/team/team_mode_random.c b/drivers/net/team/team_mode_random.c
index 7f032e2..cd2f692 100644
--- a/drivers/net/team/team_mode_random.c
+++ b/drivers/net/team/team_mode_random.c
@@ -13,20 +13,14 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/skbuff.h>
-#include <linux/reciprocal_div.h>
#include <linux/if_team.h>
-static u32 random_N(unsigned int N)
-{
- return reciprocal_divide(prandom_u32(), N);
-}
-
static bool rnd_transmit(struct team *team, struct sk_buff *skb)
{
struct team_port *port;
int port_index;
- port_index = random_N(team->en_port_count);
+ port_index = prandom_u32_max(team->en_port_count);
port = team_get_port_by_index_rcu(team, port_index);
if (unlikely(!port))
goto drop;
diff --git a/include/linux/random.h b/include/linux/random.h
index 4002b3d..1cfce0e 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -8,7 +8,6 @@
#include <uapi/linux/random.h>
-
extern void add_device_randomness(const void *, unsigned int);
extern void add_input_randomness(unsigned int type, unsigned int code,
unsigned int value);
@@ -38,6 +37,23 @@ struct rnd_state {
u32 prandom_u32_state(struct rnd_state *state);
void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
+/**
+ * prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro)
+ * @ep_ro: right open interval endpoint
+ *
+ * Returns a pseudo-random number that is in interval [0, ep_ro). Note
+ * that the result depends on PRNG being well distributed in [0, ~0U]
+ * u32 space. Here we use maximally equidistributed combined Tausworthe
+ * generator, that is, prandom_u32(). This is useful when requesting a
+ * random index of an array containing ep_ro elements, for example.
+ *
+ * Returns: pseudo-random number in interval [0, ep_ro)
+ */
+static inline u32 prandom_u32_max(u32 ep_ro)
+{
+ return (u32)(((u64) prandom_u32() * ep_ro) >> 32);
+}
+
/*
* Handle minimum values for seeds
*/
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 59fb3db..df3cbdd 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1289,7 +1289,7 @@ static unsigned int fanout_demux_rnd(struct packet_fanout *f,
struct sk_buff *skb,
unsigned int num)
{
- return reciprocal_divide(prandom_u32(), num);
+ return prandom_u32_max(num);
}
static unsigned int fanout_demux_rollover(struct packet_fanout *f,
diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
index ddd73cb..2aee028 100644
--- a/net/sched/sch_choke.c
+++ b/net/sched/sch_choke.c
@@ -14,7 +14,6 @@
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/skbuff.h>
-#include <linux/reciprocal_div.h>
#include <linux/vmalloc.h>
#include <net/pkt_sched.h>
#include <net/inet_ecn.h>
@@ -77,12 +76,6 @@ struct choke_sched_data {
struct sk_buff **tab;
};
-/* deliver a random number between 0 and N - 1 */
-static u32 random_N(unsigned int N)
-{
- return reciprocal_divide(prandom_u32(), N);
-}
-
/* number of elements in queue including holes */
static unsigned int choke_len(const struct choke_sched_data *q)
{
@@ -233,7 +226,7 @@ static struct sk_buff *choke_peek_random(const struct choke_sched_data *q,
int retrys = 3;
do {
- *pidx = (q->head + random_N(choke_len(q))) & q->tab_mask;
+ *pidx = (q->head + prandom_u32_max(choke_len(q))) & q->tab_mask;
skb = q->tab[*pidx];
if (skb)
return skb;
--
1.8.4.2
^ permalink raw reply related
* Re: [PATCH net-next v4 0/3] reciprocal_divide update
From: Hannes Frederic Sowa @ 2014-01-22 1:24 UTC (permalink / raw)
To: netdev
In-Reply-To: <1390352550-4511-1-git-send-email-hannes@stressinduktion.org>
On Wed, Jan 22, 2014 at 02:02:27AM +0100, Hannes Frederic Sowa wrote:
> v1->v2:
> - changed name to prandom_u32_max in p1
> - changed name to trim in p2
> - reworked code in p3
> v2->v3:
> - p1 and p3 stays unchanged, only small update in commit
> message in p3
> - changed name to reciprocal_scale in p2
> - fixed kernel doc format
> v3->v4:
> - pseduo -> pseudo (thanks to Tilman Schmidt)
Oh, David, I messed up the rebase and the change is actually not part of this
series. Please discard this.
I'll double-check and resend soon and finally get my needed sleep then. ;)
Thanks,
Hannes
^ permalink raw reply
* Re: [PATCH net] ipv6: protect protocols not handling ipv4 from v4 connection/bind attempts
From: Hannes Frederic Sowa @ 2014-01-22 1:08 UTC (permalink / raw)
To: David Miller; +Cc: netdev
In-Reply-To: <20140121.165941.1593478240200500821.davem@davemloft.net>
On Tue, Jan 21, 2014 at 04:59:41PM -0800, David Miller wrote:
> From: Hannes Frederic Sowa <hannes@stressinduktion.org>
> Date: Mon, 20 Jan 2014 05:16:39 +0100
>
> > Some ipv6 protocols cannot handle ipv4 addresses, so we must not allow
> > connecting and binding to them. sendmsg logic does already check msg->name
> > for this but must trust already connected sockets which could be set up
> > for connection to ipv4 address family.
> >
> > Per-socket flag ipv6only is of no use here, as it is under users control
> > by setsockopt.
> >
> > Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
>
> Applied. Is the plan to add support to at least ping?
Yes, this is planned but for the meantime we should disable it.
Thanks!
^ permalink raw reply
* Re: [PATCH net-next v6 0/2] stmmac: fix kernel crashes for jumbo frames
From: David Miller @ 2014-01-22 1:05 UTC (permalink / raw)
To: vbridgers2013
Cc: devicetree, netdev, peppe.cavallaro, robh+dt, pawel.moll,
mark.rutland, ijc+devicetree, galak, dinguyen, rayagond
In-Reply-To: <1390217941-22967-1-git-send-email-vbridgers2013@gmail.com>
Series applied, thanks.
^ permalink raw reply
* Re: [patch] rxrpc: out of bound read in debug code
From: David Miller @ 2014-01-22 1:03 UTC (permalink / raw)
To: dan.carpenter; +Cc: netdev, kernel-janitors
In-Reply-To: <20140120102859.GA14233@elgon.mountain>
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Mon, 20 Jan 2014 13:28:59 +0300
> Smatch complains because we are using an untrusted index into the
> rxrpc_acks[] array. It's just a read and it's only in the debug code,
> but it's simple enough to add a check and fix it.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied, thanks Dan.
^ permalink raw reply
* [PATCH net-next v4 0/3] reciprocal_divide update
From: Hannes Frederic Sowa @ 2014-01-22 1:02 UTC (permalink / raw)
To: netdev
This patch is on top of aee636c4809fa5 ("bpf: do not use reciprocal
divide") from Eric that sits in net tree. It will not create a merge
conflict, but it depends on this one, so we suggest, if possible, to
merge net into net-next.
We are proposing this change with only small modifications from the
v2 version, namely updating the name of trim to reciprocal_scale
(as commented on by Ben Hutchings and Eric Dumazet, thanks!).
We thought about introducing the reciprocal_divide algorithm in
parallel to the one already used by the kernel but faced organizational
issues, leading us to the conclusion that it is best to just replace
the old one: We could not come up with names for the different
implementations and also with a way to describe the differences to
guide developers which one to choose in which situation. This is
because we cannot specify the correct semantics for the version
which is currently used by the kernel. Altough it seems to not be
causing problems in the kernel, we cannot surely say so in the
case of flex_array for the future. Current usage seems ok, but
future users could run into problems.
Changelog:
v1->v2:
- changed name to prandom_u32_max in p1
- changed name to trim in p2
- reworked code in p3
v2->v3:
- p1 and p3 stays unchanged, only small update in commit
message in p3
- changed name to reciprocal_scale in p2
- fixed kernel doc format
v3->v4:
- pseduo -> pseudo (thanks to Tilman Schmidt)
Thanks !
Daniel Borkmann (2):
random32: add prandom_u32_max and convert open coded users
net: introduce reciprocal_scale helper and convert users
Hannes Frederic Sowa (1):
reciprocal_divide: update/correction of the algorithm
drivers/net/bonding/bond_main.c | 24 ++++++++++++++++-------
drivers/net/bonding/bond_netlink.c | 4 ----
drivers/net/bonding/bond_options.c | 15 +++++++++-----
drivers/net/bonding/bond_sysfs.c | 5 -----
drivers/net/bonding/bonding.h | 3 +++
drivers/net/team/team_mode_random.c | 8 +-------
include/linux/flex_array.h | 3 ++-
include/linux/kernel.h | 19 ++++++++++++++++++
include/linux/random.h | 18 ++++++++++++++++-
include/linux/reciprocal_div.h | 39 ++++++++++++++++++++-----------------
include/linux/slab_def.h | 4 +++-
include/net/codel.h | 4 +---
include/net/red.h | 3 ++-
lib/flex_array.c | 7 ++++++-
lib/reciprocal_div.c | 24 +++++++++++++++++++----
net/packet/af_packet.c | 5 ++---
net/sched/sch_choke.c | 9 +--------
net/sched/sch_netem.c | 6 ++++--
18 files changed, 129 insertions(+), 71 deletions(-)
^ permalink raw reply
* [PATCH net-next v4 3/3] reciprocal_divide: update/correction of the algorithm
From: Hannes Frederic Sowa @ 2014-01-22 1:02 UTC (permalink / raw)
To: netdev
Cc: Eric Dumazet, Austin S Hemmelgarn, linux-kernel, Jesse Gross,
Jamal Hadi Salim, Stephen Hemminger, Matt Mackall, Pekka Enberg,
Christoph Lameter, Andy Gospodarek, Veaceslav Falico,
Jay Vosburgh, Jakub Zawadzki, Daniel Borkmann
In-Reply-To: <1390352550-4511-1-git-send-email-hannes@stressinduktion.org>
Jakub Zawadzki noticed that some divisions by reciprocal_divide()
were not correct [1][2], which he could also show with BPF code
after divisions are transformed into reciprocal_value() for runtime
invariance which can be passed to reciprocal_divide() later on;
reverse in BPF dump ended up with a different, off-by-one K in
some situations.
This has been fixed by Eric Dumazet in commit aee636c4809fa5
("bpf: do not use reciprocal divide"). This follow-up patch
improves reciprocal_value() and reciprocal_divide() to work in
all cases by using Granlund and Montgomery method, so that also
future use is safe and without any non-obvious side-effects.
Known problems with the old implementation were that division by 1
always returned 0 and some off-by-ones when the dividend and divisor
where very large. This seemed to not be problematic with its
current users, as far as we can tell. Eric Dumazet checked for
the slab usage, we cannot surely say so in the case of flex_array.
Still, in order to fix that, we propose an extension from the
original implementation from commit 6a2d7a955d8d resp. [3][4],
by using the algorithm proposed in "Division by Invariant Integers
Using Multiplication" [5], Torbjörn Granlund and Peter L.
Montgomery, that is, pseudocode for q = n/d where q, n, d is in
u32 universe:
1) Initialization:
int l = ceil(log_2 d)
uword m' = floor((1<<32)*((1<<l)-d)/d)+1
int sh_1 = min(l,1)
int sh_2 = max(l-1,0)
2) For q = n/d, all uword:
uword t = (n*m')>>32
q = (t+((n-t)>>sh_1))>>sh_2
The assembler implementation from Agner Fog [6] also helped a lot
while implementing. We have tested the implementation on x86_64,
ppc64, i686, s390x; on x86_64/haswell we're still half the latency
compared to normal divide.
Joint work with Daniel Borkmann.
[1] http://www.wireshark.org/~darkjames/reciprocal-buggy.c
[2] http://www.wireshark.org/~darkjames/set-and-dump-filter-k-bug.c
[3] https://gmplib.org/~tege/division-paper.pdf
[4] http://homepage.cs.uiowa.edu/~jones/bcd/divide.html
[5] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.1.2556
[6] http://www.agner.org/optimize/asmlib.zip
Reported-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Austin S Hemmelgarn <ahferroin7@gmail.com>
Cc: linux-kernel@vger.kernel.org
Cc: Jesse Gross <jesse@nicira.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: Andy Gospodarek <andy@greyhouse.net>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
drivers/net/bonding/bond_main.c | 24 ++++++++++++++++-------
drivers/net/bonding/bond_netlink.c | 4 ----
drivers/net/bonding/bond_options.c | 15 ++++++++++-----
drivers/net/bonding/bond_sysfs.c | 5 -----
drivers/net/bonding/bonding.h | 3 +++
include/linux/flex_array.h | 3 ++-
include/linux/reciprocal_div.h | 39 ++++++++++++++++++++------------------
include/linux/slab_def.h | 4 +++-
include/net/red.h | 3 ++-
lib/flex_array.c | 7 ++++++-
lib/reciprocal_div.c | 24 +++++++++++++++++++----
net/sched/sch_netem.c | 6 ++++--
12 files changed, 88 insertions(+), 49 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 3220b48..f100bd9 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -79,7 +79,6 @@
#include <net/pkt_sched.h>
#include <linux/rculist.h>
#include <net/flow_keys.h>
-#include <linux/reciprocal_div.h>
#include "bonding.h"
#include "bond_3ad.h"
#include "bond_alb.h"
@@ -3596,8 +3595,9 @@ static void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int sl
*/
static u32 bond_rr_gen_slave_id(struct bonding *bond)
{
- int packets_per_slave = bond->params.packets_per_slave;
u32 slave_id;
+ struct reciprocal_value reciprocal_packets_per_slave;
+ int packets_per_slave = bond->params.packets_per_slave;
switch (packets_per_slave) {
case 0:
@@ -3607,8 +3607,10 @@ static u32 bond_rr_gen_slave_id(struct bonding *bond)
slave_id = bond->rr_tx_counter;
break;
default:
+ reciprocal_packets_per_slave =
+ bond->params.reciprocal_packets_per_slave;
slave_id = reciprocal_divide(bond->rr_tx_counter,
- packets_per_slave);
+ reciprocal_packets_per_slave);
break;
}
bond->rr_tx_counter++;
@@ -4343,10 +4345,18 @@ static int bond_check_params(struct bond_params *params)
params->resend_igmp = resend_igmp;
params->min_links = min_links;
params->lp_interval = lp_interval;
- if (packets_per_slave > 1)
- params->packets_per_slave = reciprocal_value(packets_per_slave);
- else
- params->packets_per_slave = packets_per_slave;
+ params->packets_per_slave = packets_per_slave;
+ if (packets_per_slave > 0) {
+ params->reciprocal_packets_per_slave =
+ reciprocal_value(packets_per_slave);
+ } else {
+ /* reciprocal_packets_per_slave is unused if
+ * packets_per_slave is 0 or 1, just initialize it
+ */
+ params->reciprocal_packets_per_slave =
+ (struct reciprocal_value) { 0 };
+ }
+
if (primary) {
strncpy(params->primary, primary, IFNAMSIZ);
params->primary[IFNAMSIZ - 1] = 0;
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 21c6488..e852655 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -19,7 +19,6 @@
#include <linux/if_ether.h>
#include <net/netlink.h>
#include <net/rtnetlink.h>
-#include <linux/reciprocal_div.h>
#include "bonding.h"
int bond_get_slave(struct net_device *slave_dev, struct sk_buff *skb)
@@ -452,9 +451,6 @@ static int bond_fill_info(struct sk_buff *skb,
goto nla_put_failure;
packets_per_slave = bond->params.packets_per_slave;
- if (packets_per_slave > 1)
- packets_per_slave = reciprocal_value(packets_per_slave);
-
if (nla_put_u32(skb, IFLA_BOND_PACKETS_PER_SLAVE,
packets_per_slave))
goto nla_put_failure;
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 945a666..85e4348 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -16,7 +16,6 @@
#include <linux/netdevice.h>
#include <linux/rwlock.h>
#include <linux/rcupdate.h>
-#include <linux/reciprocal_div.h>
#include "bonding.h"
int bond_option_mode_set(struct bonding *bond, int mode)
@@ -671,11 +670,17 @@ int bond_option_packets_per_slave_set(struct bonding *bond,
pr_warn("%s: Warning: packets_per_slave has effect only in balance-rr mode\n",
bond->dev->name);
- if (packets_per_slave > 1)
- bond->params.packets_per_slave =
+ bond->params.packets_per_slave = packets_per_slave;
+ if (packets_per_slave > 0) {
+ bond->params.reciprocal_packets_per_slave =
reciprocal_value(packets_per_slave);
- else
- bond->params.packets_per_slave = packets_per_slave;
+ } else {
+ /* reciprocal_packets_per_slave is unused if
+ * packets_per_slave is 0 or 1, just initialize it
+ */
+ bond->params.reciprocal_packets_per_slave =
+ (struct reciprocal_value) { 0 };
+ }
return 0;
}
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 011f163..c083e9a 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -39,7 +39,6 @@
#include <net/net_namespace.h>
#include <net/netns/generic.h>
#include <linux/nsproxy.h>
-#include <linux/reciprocal_div.h>
#include "bonding.h"
@@ -1374,10 +1373,6 @@ static ssize_t bonding_show_packets_per_slave(struct device *d,
{
struct bonding *bond = to_bond(d);
unsigned int packets_per_slave = bond->params.packets_per_slave;
-
- if (packets_per_slave > 1)
- packets_per_slave = reciprocal_value(packets_per_slave);
-
return sprintf(buf, "%u\n", packets_per_slave);
}
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 8a935f8..0a616c4 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -23,6 +23,8 @@
#include <linux/netpoll.h>
#include <linux/inetdevice.h>
#include <linux/etherdevice.h>
+#include <linux/reciprocal_div.h>
+
#include "bond_3ad.h"
#include "bond_alb.h"
@@ -171,6 +173,7 @@ struct bond_params {
int resend_igmp;
int lp_interval;
int packets_per_slave;
+ struct reciprocal_value reciprocal_packets_per_slave;
};
struct bond_parm_tbl {
diff --git a/include/linux/flex_array.h b/include/linux/flex_array.h
index 6843cf1..b6efb0c 100644
--- a/include/linux/flex_array.h
+++ b/include/linux/flex_array.h
@@ -2,6 +2,7 @@
#define _FLEX_ARRAY_H
#include <linux/types.h>
+#include <linux/reciprocal_div.h>
#include <asm/page.h>
#define FLEX_ARRAY_PART_SIZE PAGE_SIZE
@@ -22,7 +23,7 @@ struct flex_array {
int element_size;
int total_nr_elements;
int elems_per_part;
- u32 reciprocal_elems;
+ struct reciprocal_value reciprocal_elems;
struct flex_array_part *parts[];
};
/*
diff --git a/include/linux/reciprocal_div.h b/include/linux/reciprocal_div.h
index f9c90b3..8c5a3fb 100644
--- a/include/linux/reciprocal_div.h
+++ b/include/linux/reciprocal_div.h
@@ -4,29 +4,32 @@
#include <linux/types.h>
/*
- * This file describes reciprocical division.
+ * This algorithm is based on the paper "Division by Invariant
+ * Integers Using Multiplication" by Torbjörn Granlund and Peter
+ * L. Montgomery.
*
- * This optimizes the (A/B) problem, when A and B are two u32
- * and B is a known value (but not known at compile time)
+ * The assembler implementation from Agner Fog, which this code is
+ * based on, can be found here:
+ * http://www.agner.org/optimize/asmlib.zip
*
- * The math principle used is :
- * Let RECIPROCAL_VALUE(B) be (((1LL << 32) + (B - 1))/ B)
- * Then A / B = (u32)(((u64)(A) * (R)) >> 32)
- *
- * This replaces a divide by a multiply (and a shift), and
- * is generally less expensive in CPU cycles.
+ * This optimization for A/B is helpful if the divisor B is mostly
+ * runtime invariant. The reciprocal of B is calculated in the
+ * slow-path with reciprocal_value(). The fast-path can then just use
+ * a much faster multiplication operation with a variable dividend A
+ * to calculate the division A/B.
*/
-/*
- * Computes the reciprocal value (R) for the value B of the divisor.
- * Should not be called before each reciprocal_divide(),
- * or else the performance is slower than a normal divide.
- */
-extern u32 reciprocal_value(u32 B);
+struct reciprocal_value {
+ u32 m;
+ u8 sh1, sh2;
+};
+struct reciprocal_value reciprocal_value(u32 d);
-static inline u32 reciprocal_divide(u32 A, u32 R)
+static inline u32 reciprocal_divide(u32 a, struct reciprocal_value R)
{
- return (u32)(((u64)A * R) >> 32);
+ u32 t = (u32)(((u64)a * R.m) >> 32);
+ return (t + ((a - t) >> R.sh1)) >> R.sh2;
}
-#endif
+
+#endif /* _LINUX_RECIPROCAL_DIV_H */
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index 09bfffb..96e8aba 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -1,6 +1,8 @@
#ifndef _LINUX_SLAB_DEF_H
#define _LINUX_SLAB_DEF_H
+#include <linux/reciprocal_div.h>
+
/*
* Definitions unique to the original Linux SLAB allocator.
*/
@@ -12,7 +14,7 @@ struct kmem_cache {
unsigned int shared;
unsigned int size;
- u32 reciprocal_buffer_size;
+ struct reciprocal_value reciprocal_buffer_size;
/* 2) touched by every alloc & free from the backend */
unsigned int flags; /* constant flags */
diff --git a/include/net/red.h b/include/net/red.h
index 168bb2f..76e0b5f 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -130,7 +130,8 @@ struct red_parms {
u32 qth_max; /* Max avg length threshold: Wlog scaled */
u32 Scell_max;
u32 max_P; /* probability, [0 .. 1.0] 32 scaled */
- u32 max_P_reciprocal; /* reciprocal_value(max_P / qth_delta) */
+ /* reciprocal_value(max_P / qth_delta) */
+ struct reciprocal_value max_P_reciprocal;
u32 qth_delta; /* max_th - min_th */
u32 target_min; /* min_th + 0.4*(max_th - min_th) */
u32 target_max; /* min_th + 0.6*(max_th - min_th) */
diff --git a/lib/flex_array.c b/lib/flex_array.c
index 6948a66..2eed22f 100644
--- a/lib/flex_array.c
+++ b/lib/flex_array.c
@@ -90,8 +90,8 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total,
{
struct flex_array *ret;
int elems_per_part = 0;
- int reciprocal_elems = 0;
int max_size = 0;
+ struct reciprocal_value reciprocal_elems = { 0 };
if (element_size) {
elems_per_part = FLEX_ARRAY_ELEMENTS_PER_PART(element_size);
@@ -119,6 +119,11 @@ EXPORT_SYMBOL(flex_array_alloc);
static int fa_element_to_part_nr(struct flex_array *fa,
unsigned int element_nr)
{
+ /*
+ * if element_size == 0 we don't get here, so we never touch
+ * the zeroed fa->reciprocal_elems, which would yield invalid
+ * results
+ */
return reciprocal_divide(element_nr, fa->reciprocal_elems);
}
diff --git a/lib/reciprocal_div.c b/lib/reciprocal_div.c
index 75510e9..4641524 100644
--- a/lib/reciprocal_div.c
+++ b/lib/reciprocal_div.c
@@ -1,11 +1,27 @@
+#include <linux/kernel.h>
#include <asm/div64.h>
#include <linux/reciprocal_div.h>
#include <linux/export.h>
-u32 reciprocal_value(u32 k)
+/*
+ * For a description of the algorithm please have a look at
+ * include/linux/reciprocal_div.h
+ */
+
+struct reciprocal_value reciprocal_value(u32 d)
{
- u64 val = (1LL << 32) + (k - 1);
- do_div(val, k);
- return (u32)val;
+ struct reciprocal_value R;
+ u64 m;
+ int l;
+
+ l = fls(d - 1);
+ m = ((1ULL << 32) * ((1ULL << l) - d));
+ do_div(m, d);
+ ++m;
+ R.m = (u32)m;
+ R.sh1 = min(l, 1);
+ R.sh2 = max(l - 1, 0);
+
+ return R;
}
EXPORT_SYMBOL(reciprocal_value);
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index a2bfc37..de1059a 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -91,7 +91,7 @@ struct netem_sched_data {
u64 rate;
s32 packet_overhead;
u32 cell_size;
- u32 cell_size_reciprocal;
+ struct reciprocal_value cell_size_reciprocal;
s32 cell_overhead;
struct crndstate {
@@ -725,9 +725,11 @@ static void get_rate(struct Qdisc *sch, const struct nlattr *attr)
q->rate = r->rate;
q->packet_overhead = r->packet_overhead;
q->cell_size = r->cell_size;
+ q->cell_overhead = r->cell_overhead;
if (q->cell_size)
q->cell_size_reciprocal = reciprocal_value(q->cell_size);
- q->cell_overhead = r->cell_overhead;
+ else
+ q->cell_size_reciprocal = (struct reciprocal_value) { 0 };
}
static int get_loss_clg(struct Qdisc *sch, const struct nlattr *attr)
--
1.8.4.2
^ permalink raw reply related
* [PATCH net-next v4 2/3] net: introduce reciprocal_scale helper and convert users
From: Hannes Frederic Sowa @ 2014-01-22 1:02 UTC (permalink / raw)
To: netdev; +Cc: Daniel Borkmann, Jakub Zawadzki, Eric Dumazet, linux-kernel
In-Reply-To: <1390352550-4511-1-git-send-email-hannes@stressinduktion.org>
From: Daniel Borkmann <dborkman@redhat.com>
As David Laight suggests, we shouldn't necessarily call this
reciprocal_divide() when users didn't requested a reciprocal_value();
lets keep the basic idea and call it reciprocal_scale(). More
background information on this topic can be found in [1].
Joint work with Hannes Frederic Sowa.
[1] http://homepage.cs.uiowa.edu/~jones/bcd/divide.html
Suggested-by: David Laight <david.laight@aculab.com>
Cc: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
---
include/linux/kernel.h | 19 +++++++++++++++++++
include/net/codel.h | 4 +---
net/packet/af_packet.c | 3 +--
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index ecb8754..03d8a6b 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -193,6 +193,25 @@ extern int _cond_resched(void);
(__x < 0) ? -__x : __x; \
})
+/**
+ * reciprocal_scale - "scale" a value into range [0, ep_ro)
+ * @val: value
+ * @ep_ro: right open interval endpoint
+ *
+ * Perform a "reciprocal multiplication" in order to "scale" a value into
+ * range [0, ep_ro), where the upper interval endpoint is right-open.
+ * This is useful, e.g. for accessing a index of an array containing
+ * ep_ro elements, for example. Think of it as sort of modulus, only that
+ * the result isn't that of modulo. ;) Note that if initial input is a
+ * small value, then result will return 0.
+ *
+ * Return: a result based on val in interval [0, ep_ro).
+ */
+static inline u32 reciprocal_scale(u32 val, u32 ep_ro)
+{
+ return (u32)(((u64) val * ep_ro) >> 32);
+}
+
#if defined(CONFIG_MMU) && \
(defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP))
void might_fault(void);
diff --git a/include/net/codel.h b/include/net/codel.h
index 3b04ff5..fe0eab3 100644
--- a/include/net/codel.h
+++ b/include/net/codel.h
@@ -46,7 +46,6 @@
#include <linux/skbuff.h>
#include <net/pkt_sched.h>
#include <net/inet_ecn.h>
-#include <linux/reciprocal_div.h>
/* Controlling Queue Delay (CoDel) algorithm
* =========================================
@@ -211,10 +210,9 @@ static codel_time_t codel_control_law(codel_time_t t,
codel_time_t interval,
u32 rec_inv_sqrt)
{
- return t + reciprocal_divide(interval, rec_inv_sqrt << REC_INV_SQRT_SHIFT);
+ return t + reciprocal_scale(interval, rec_inv_sqrt << REC_INV_SQRT_SHIFT);
}
-
static bool codel_should_drop(const struct sk_buff *skb,
struct Qdisc *sch,
struct codel_vars *vars,
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index df3cbdd..9734616 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -88,7 +88,6 @@
#include <linux/virtio_net.h>
#include <linux/errqueue.h>
#include <linux/net_tstamp.h>
-#include <linux/reciprocal_div.h>
#include <linux/percpu.h>
#ifdef CONFIG_INET
#include <net/inet_common.h>
@@ -1262,7 +1261,7 @@ static unsigned int fanout_demux_hash(struct packet_fanout *f,
struct sk_buff *skb,
unsigned int num)
{
- return reciprocal_divide(skb->rxhash, num);
+ return reciprocal_scale(skb->rxhash, num);
}
static unsigned int fanout_demux_lb(struct packet_fanout *f,
--
1.8.4.2
^ permalink raw reply related
* [PATCH net-next v4 1/3] random32: add prandom_u32_max and convert open coded users
From: Hannes Frederic Sowa @ 2014-01-22 1:02 UTC (permalink / raw)
To: netdev; +Cc: Daniel Borkmann, Jakub Zawadzki, Eric Dumazet, linux-kernel
In-Reply-To: <1390352550-4511-1-git-send-email-hannes@stressinduktion.org>
From: Daniel Borkmann <dborkman@redhat.com>
Many functions have open coded a function that returns a random
number in range [0,N-1]. Under the assumption that we have a PRNG
such as taus113 with being well distributed in [0, ~0U] space,
we can implement such a function as uword t = (n*m')>>32, where
m' is a random number obtained from PRNG, n the right open interval
border and t our resulting random number, with n,m',t in u32 universe.
Lets go with Joe and simply call it prandom_u32_max(), although
technically we have an right open interval endpoint, but that we
have documented. Other users can further be migrated to the new
prandom_u32_max() function later on; for now, we need to make sure
to migrate reciprocal_divide() users for the reciprocal_divide()
follow-up fixup since their function signatures are going to change.
Joint work with Hannes Frederic Sowa.
Cc: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
---
drivers/net/team/team_mode_random.c | 8 +-------
include/linux/random.h | 18 +++++++++++++++++-
net/packet/af_packet.c | 2 +-
net/sched/sch_choke.c | 9 +--------
4 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/drivers/net/team/team_mode_random.c b/drivers/net/team/team_mode_random.c
index 7f032e2..cd2f692 100644
--- a/drivers/net/team/team_mode_random.c
+++ b/drivers/net/team/team_mode_random.c
@@ -13,20 +13,14 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/skbuff.h>
-#include <linux/reciprocal_div.h>
#include <linux/if_team.h>
-static u32 random_N(unsigned int N)
-{
- return reciprocal_divide(prandom_u32(), N);
-}
-
static bool rnd_transmit(struct team *team, struct sk_buff *skb)
{
struct team_port *port;
int port_index;
- port_index = random_N(team->en_port_count);
+ port_index = prandom_u32_max(team->en_port_count);
port = team_get_port_by_index_rcu(team, port_index);
if (unlikely(!port))
goto drop;
diff --git a/include/linux/random.h b/include/linux/random.h
index 4002b3d..3e89ac9 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -8,7 +8,6 @@
#include <uapi/linux/random.h>
-
extern void add_device_randomness(const void *, unsigned int);
extern void add_input_randomness(unsigned int type, unsigned int code,
unsigned int value);
@@ -38,6 +37,23 @@ struct rnd_state {
u32 prandom_u32_state(struct rnd_state *state);
void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
+/**
+ * prandom_u32_max - returns a pseduo-random number in interval [0, ep_ro)
+ * @ep_ro: right open interval endpoint
+ *
+ * Returns a pseduo-random number that is in interval [0, ep_ro). Note
+ * that the result depends on PRNG being well distributed in [0, ~0U]
+ * u32 space. Here we use maximally equidistributed combined Tausworthe
+ * generator, that is, prandom_u32(). This is useful when requesting a
+ * random index of an array containing ep_ro elements, for example.
+ *
+ * Returns: pseduo-random number in interval [0, ep_ro)
+ */
+static inline u32 prandom_u32_max(u32 ep_ro)
+{
+ return (u32)(((u64) prandom_u32() * ep_ro) >> 32);
+}
+
/*
* Handle minimum values for seeds
*/
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 59fb3db..df3cbdd 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1289,7 +1289,7 @@ static unsigned int fanout_demux_rnd(struct packet_fanout *f,
struct sk_buff *skb,
unsigned int num)
{
- return reciprocal_divide(prandom_u32(), num);
+ return prandom_u32_max(num);
}
static unsigned int fanout_demux_rollover(struct packet_fanout *f,
diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
index ddd73cb..2aee028 100644
--- a/net/sched/sch_choke.c
+++ b/net/sched/sch_choke.c
@@ -14,7 +14,6 @@
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/skbuff.h>
-#include <linux/reciprocal_div.h>
#include <linux/vmalloc.h>
#include <net/pkt_sched.h>
#include <net/inet_ecn.h>
@@ -77,12 +76,6 @@ struct choke_sched_data {
struct sk_buff **tab;
};
-/* deliver a random number between 0 and N - 1 */
-static u32 random_N(unsigned int N)
-{
- return reciprocal_divide(prandom_u32(), N);
-}
-
/* number of elements in queue including holes */
static unsigned int choke_len(const struct choke_sched_data *q)
{
@@ -233,7 +226,7 @@ static struct sk_buff *choke_peek_random(const struct choke_sched_data *q,
int retrys = 3;
do {
- *pidx = (q->head + random_N(choke_len(q))) & q->tab_mask;
+ *pidx = (q->head + prandom_u32_max(choke_len(q))) & q->tab_mask;
skb = q->tab[*pidx];
if (skb)
return skb;
--
1.8.4.2
^ permalink raw reply related
* Re: [PATCH] 8021q: update description
From: David Miller @ 2014-01-22 1:02 UTC (permalink / raw)
To: yegorslists; +Cc: netdev
In-Reply-To: <1390211379-3374-1-git-send-email-yegorslists@googlemail.com>
From: yegorslists@googlemail.com
Date: Mon, 20 Jan 2014 10:49:39 +0100
> From: Yegor Yefremov <yegorslists@googlemail.com>
>
> Replace deprecated 'vconfig' tool with 'ip' from 'iproute2'. Add
> some beautifications like replacing 'ethernet' with 'Ethernet' and
> removing unneeded spaces.
>
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Applied.
...
> <http://www.candelatech.com/~greear/vlan.html>
We should also probably get rid of this URL reference, it hasn't been
updated in almost 9 years, talks about 2.2 and 2.4.x kernels, and
recommends using vconfig.
^ permalink raw reply
* Re: [PATCH net] ipv6: protect protocols not handling ipv4 from v4 connection/bind attempts
From: David Miller @ 2014-01-22 0:59 UTC (permalink / raw)
To: hannes; +Cc: netdev
In-Reply-To: <20140120041639.GA27055@order.stressinduktion.org>
From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Mon, 20 Jan 2014 05:16:39 +0100
> Some ipv6 protocols cannot handle ipv4 addresses, so we must not allow
> connecting and binding to them. sendmsg logic does already check msg->name
> for this but must trust already connected sockets which could be set up
> for connection to ipv4 address family.
>
> Per-socket flag ipv6only is of no use here, as it is under users control
> by setsockopt.
>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Applied. Is the plan to add support to at least ping?
Thanks.
^ permalink raw reply
* Re: [PATCH net-next v2] ipv6: enable anycast addresses as source addresses in ICMPv6 error messages
From: David Miller @ 2014-01-22 0:53 UTC (permalink / raw)
To: fx.lebail
Cc: netdev, dlstevens, billfink, hannes, kuznet, jmorris, yoshfuji,
kaber
In-Reply-To: <1390147236-3660-1-git-send-email-fx.lebail@yahoo.com>
From: Francois-Xavier Le Bail <fx.lebail@yahoo.com>
Date: Sun, 19 Jan 2014 17:00:36 +0100
> - Uses ipv6_anycast_destination() in icmp6_send().
>
> Suggested-by: Bill Fink <billfink@mindspring.com>
> Signed-off-by: Francois-Xavier Le Bail <fx.lebail@yahoo.com>
Applied.
^ permalink raw reply
* Re: [PATCH net v2] tcp: delete redundant calls of tcp_mtup_init()
From: David Miller @ 2014-01-22 0:52 UTC (permalink / raw)
To: panweiping3; +Cc: netdev
In-Reply-To: <1a8e9e92721ef792aa017b89a4d6376dca5dc4f6.1390135376.git.panweiping3@gmail.com>
From: Weiping Pan <panweiping3@gmail.com>
Date: Sun, 19 Jan 2014 20:44:46 +0800
> As tcp_rcv_state_process() has already calls tcp_mtup_init() for non-fastopen
> sock, we can delete the redundant calls of tcp_mtup_init() in
> tcp_{v4,v6}_syn_recv_sock().
>
> Signed-off-by: Weiping Pan <panweiping3@gmail.com>
Looks good, applied.
^ permalink raw reply
* Re: [PATCH net-next] packet: fix a couple of cppcheck warnings
From: David Miller @ 2014-01-22 0:52 UTC (permalink / raw)
To: dborkman; +Cc: netdev
In-Reply-To: <1390128413-7075-1-git-send-email-dborkman@redhat.com>
From: Daniel Borkmann <dborkman@redhat.com>
Date: Sun, 19 Jan 2014 11:46:53 +0100
> Doesn't bring much, but also doesn't hurt us to fix 'em:
>
> 1) In tpacket_rcv() flush dcache page we can restirct the scope
> for start and end and remove one layer of indent.
>
> 2) In tpacket_destruct_skb() we can restirct the scope for ph.
>
> 3) In alloc_one_pg_vec_page() we can remove the NULL assignment
> and change spacing a bit.
>
> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH v2] ipv4: remove the useless argument from ip_tunnel_hash()
From: David Miller @ 2014-01-22 0:49 UTC (permalink / raw)
To: duanj.fnst; +Cc: netdev
In-Reply-To: <52DB903E.9050301@cn.fujitsu.com>
From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Date: Sun, 19 Jan 2014 16:43:42 +0800
>
> Since commit c544193214("GRE: Refactor GRE tunneling code")
> introduced function ip_tunnel_hash(), the argument itn is no
> longer in use, so remove it.
>
> Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH] net: gre: don't pull skb if dealing with icmp message
From: David Miller @ 2014-01-22 0:49 UTC (permalink / raw)
To: duanj.fnst; +Cc: dborkman, netdev
In-Reply-To: <52DB8E4A.7050809@cn.fujitsu.com>
From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Date: Sun, 19 Jan 2014 16:35:22 +0800
>
> When dealing with icmp messages, the skb->data points the
> ip header that triggered the sending of the icmp message.
>
> In gre_cisco_err(), the parse_gre_header() is called, and the
> iptunnel_pull_header() is called to pull the skb at the end of
> the parse_gre_header(). Unfortunately, the ipgre_err still needs
> the skb->data points the ip header following the icmp layer,
> and those ip addresses in ip header will be used to look up
> tunnel by ip_tunnel_lookup().
>
> Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Conditional pulling of headers based upon caller context leads to
impossible to maintain code.
Please find another way to fix this.
^ permalink raw reply
* Re: [PATCH net-next] bond: make slave_sysfs_ops static
From: David Miller @ 2014-01-22 0:46 UTC (permalink / raw)
To: stephen; +Cc: fubar, vfalico, andy, sfeldma, netdev
In-Reply-To: <20140118145418.4b439f15@nehalam.linuxnetplumber.net>
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Sat, 18 Jan 2014 14:54:18 -0800
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Applied.
^ permalink raw reply
* Re: [PATCH net-next v2] net: remove unnecessary initializations in net_dev_init
From: David Miller @ 2014-01-22 0:45 UTC (permalink / raw)
To: sd; +Cc: netdev
In-Reply-To: <1390069167-14080-1-git-send-email-sd@queasysnail.net>
From: Sabrina Dubroca <sd@queasysnail.net>
Date: Sat, 18 Jan 2014 19:19:27 +0100
> softnet_data is already set to 0, no need to use memset or initialize
> specific fields to 0 or NULL afterwards.
>
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Applied, thanks.
^ permalink raw reply
* Re: r8169 won't transmit with 3.12
From: Craig Small @ 2014-01-22 0:41 UTC (permalink / raw)
To: Francois Romieu; +Cc: Realtek linux nic maintainers, netdev
In-Reply-To: <20140121233630.GA3214@electric-eye.fr.zoreil.com>
[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]
Hi,
Thanks for looking into this.
On Wed, Jan 22, 2014 at 12:36:30AM +0100, Francois Romieu wrote:
> You may check that the onboard nic device does not even work when the
> extra PCI-e card aren't plugged.
It definitely doesn't. I've tried with only the onboard device
and no other NIC device (r8169 or not) installed and its the same
problem.
> A complete dmesg including the XID lines that the r8169 driver prints
> would be welcome.
See attached text file. I'm not sure why I get so many interface up
messages. This is for the two NIC cards. I can pull them out and go back
to the onboard one if you like.
I don't see that transmit queue timeout message that often. It looks
like it might happen once per boot and then giveup.
> Please increase the driver verbosity with the 'msglvl' option of ethtool.
I set it at 65535 but it didn't seem to make much difference.
If I:
* rmmod r8169
* modprobe r8169 debug=1
* ifconfig eth0 ....
* ethtool -s eth0 msglvl 65535
* ping -I eth0 ...
I get the following:
[1256123.142885] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
[1256123.142905] r8169 0000:03:00.0: can't disable ASPM; OS doesn't have ASPM control
[1256123.143182] r8169 0000:03:00.0: irq 73 for MSI/MSI-X
[1256123.154873] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
[1256123.154896] r8169 0000:06:00.0: can't disable ASPM; OS doesn't have ASPM control
[1256123.155148] r8169 0000:06:00.0: irq 74 for MSI/MSI-X
[1256182.169596] r8169 0000:03:00.0 eth0: link down
[1256182.169618] r8169 0000:03:00.0 eth0: link down
[1256185.546908] r8169 0000:03:00.0 eth0: link up
[1256228.041490] r8169 0000:03:00.0 eth0: link up
- Craig
--
Craig Small (@smallsees) http://enc.com.au/ csmall at : enc.com.au
Debian GNU/Linux http://www.debian.org/ csmall at : debian.org
GPG fingerprint: 5D2F B320 B825 D939 04D2 0519 3938 F96B DF50 FEA5
[-- Attachment #2: r8169dmesg.txt --]
[-- Type: text/plain, Size: 28914 bytes --]
Jan 7 21:13:52 elmo kernel: [ 0.924084] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 7 21:13:52 elmo kernel: [ 0.924100] r8169 0000:03:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 7 21:13:52 elmo kernel: [ 0.924315] r8169 0000:03:00.0: irq 72 for MSI/MSI-X
Jan 7 21:13:52 elmo kernel: [ 0.924474] r8169 0000:03:00.0 eth0: RTL8168c/8111c at 0xffffc90001820000, 00:e0:4c:80:66:57, XID 1c4000c0 IRQ 72
Jan 7 21:13:52 elmo kernel: [ 0.924477] r8169 0000:03:00.0 eth0: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 7 21:13:52 elmo kernel: [ 0.925663] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 7 21:13:52 elmo kernel: [ 0.925678] r8169 0000:06:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 7 21:13:52 elmo kernel: [ 0.925983] r8169 0000:06:00.0: irq 74 for MSI/MSI-X
Jan 7 21:13:52 elmo kernel: [ 0.926424] r8169 0000:06:00.0 eth1: RTL8168c/8111c at 0xffffc90001870000, 00:e0:4c:80:70:08, XID 1c4000c0 IRQ 74
Jan 7 21:13:52 elmo kernel: [ 0.926427] r8169 0000:06:00.0 eth1: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 7 21:13:54 elmo kernel: [ 22.478851] r8169 0000:03:00.0 eth2: link down
Jan 7 21:13:54 elmo kernel: [ 22.498863] r8169 0000:06:00.0 eth3: link down
Jan 7 21:21:57 elmo kernel: [ 0.921374] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 7 21:21:57 elmo kernel: [ 0.921385] r8169 0000:03:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 7 21:21:57 elmo kernel: [ 0.921559] r8169 0000:03:00.0: irq 73 for MSI/MSI-X
Jan 7 21:21:57 elmo kernel: [ 0.921724] r8169 0000:03:00.0 eth0: RTL8168c/8111c at 0xffffc90001824000, 00:e0:4c:80:66:57, XID 1c4000c0 IRQ 73
Jan 7 21:21:57 elmo kernel: [ 0.921730] r8169 0000:03:00.0 eth0: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 7 21:21:57 elmo kernel: [ 0.924400] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 7 21:21:57 elmo kernel: [ 0.924411] r8169 0000:06:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 7 21:21:57 elmo kernel: [ 0.924593] r8169 0000:06:00.0: irq 74 for MSI/MSI-X
Jan 7 21:21:57 elmo kernel: [ 0.924745] r8169 0000:06:00.0 eth1: RTL8168c/8111c at 0xffffc9000187c000, 00:e0:4c:80:70:08, XID 1c4000c0 IRQ 74
Jan 7 21:21:57 elmo kernel: [ 0.924747] r8169 0000:06:00.0 eth1: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 7 21:21:57 elmo kernel: [ 20.188523] r8169 0000:06:00.0 eth1: link down
Jan 7 21:21:58 elmo kernel: [ 43.722301] r8169 0000:03:00.0 eth0: link down
Jan 7 21:31:36 elmo kernel: [ 0.920953] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 7 21:31:36 elmo kernel: [ 0.920965] r8169 0000:03:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 7 21:31:36 elmo kernel: [ 0.921184] r8169 0000:03:00.0: irq 72 for MSI/MSI-X
Jan 7 21:31:36 elmo kernel: [ 0.921329] r8169 0000:03:00.0 eth0: RTL8168c/8111c at 0xffffc90001820000, 00:e0:4c:80:66:57, XID 1c4000c0 IRQ 72
Jan 7 21:31:36 elmo kernel: [ 0.921332] r8169 0000:03:00.0 eth0: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 7 21:31:36 elmo kernel: [ 0.921407] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 7 21:31:36 elmo kernel: [ 0.921414] r8169 0000:06:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 7 21:31:36 elmo kernel: [ 0.921586] r8169 0000:06:00.0: irq 73 for MSI/MSI-X
Jan 7 21:31:36 elmo kernel: [ 0.921719] r8169 0000:06:00.0 eth1: RTL8168c/8111c at 0xffffc90001824000, 00:e0:4c:80:70:08, XID 1c4000c0 IRQ 73
Jan 7 21:31:36 elmo kernel: [ 0.921722] r8169 0000:06:00.0 eth1: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 7 21:31:36 elmo kernel: [ 20.712240] r8169 0000:03:00.0 eth0: link down
Jan 7 21:31:36 elmo kernel: [ 20.712321] r8169 0000:03:00.0 eth0: link down
Jan 7 21:31:36 elmo kernel: [ 23.934160] r8169 0000:03:00.0 eth0: link up
Jan 7 21:31:36 elmo kernel: [ 51.528553] r8169 0000:06:00.0 eth1: link down
Jan 7 21:31:36 elmo kernel: [ 51.528628] r8169 0000:06:00.0 eth1: link down
Jan 7 21:31:36 elmo kernel: [ 53.825413] NETDEV WATCHDOG: eth0 (r8169): transmit queue 0 timed out
Jan 7 21:31:36 elmo kernel: [ 53.825416] Modules linked in: ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 ip6table_filter ip6_tables ipt_REJECT xt_tcpudp xt_LOG xt_mac nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack iptable_filter ip_tables x_tables fuse it87 hwmon_vid loop tda18271 tda10048 joydev hid_generic snd_hda_codec_hdmi usbhid hid evdev kvm_amd kvm crc32_pclmul crc32c_intel ghash_clmulni_intel raid1 aesni_intel aes_x86_64 ablk_helper cryptd lrw gf128mul glue_helper md_mod psmouse sp5100_tco pcspkr fam15h_power serio_raw edac_mce_amd edac_core k10temp i2c_piix4 nouveau snd_hda_codec_via mxm_wmi wmi saa7164 video ttm drm_kms_helper tveeprom dvb_core snd_hda_intel v4l2_common drm snd_hda_codec videodev snd_hwdep media snd_pcm i2c_algo_bit snd_page_alloc acpi_cpufreq i2c_core snd_timer snd button processor soundcore thermal_sys ext4 crc16 mbcache jbd2 dm_mod sg sd_mod sr_mod cdrom crc_t10dif crct10dif_common ahci libahci ehci_pci libata ohci_pci ohci_hcd ehci_hcd xhci_hcd scsi_mod r8169 mii usbcore usb_common
Jan 7 21:31:36 elmo kernel: [ 53.857677] r8169 0000:03:00.0 eth0: link up
Jan 7 21:31:36 elmo kernel: [ 54.324015] r8169 0000:06:00.0 eth1: link up
Jan 7 21:31:37 elmo kernel: [ 83.826545] r8169 0000:03:00.0 eth0: link up
Jan 7 21:31:44 elmo kernel: [ 90.822740] r8169 0000:06:00.0 eth1: link up
Jan 7 21:31:49 elmo kernel: [ 95.822969] r8169 0000:03:00.0 eth0: link up
Jan 7 21:32:01 elmo kernel: [ 107.832103] r8169 0000:03:00.0 eth0: link up
Jan 7 21:32:02 elmo kernel: [ 108.807299] r8169 0000:06:00.0 eth1: link up
Jan 7 21:32:13 elmo kernel: [ 119.816649] r8169 0000:03:00.0 eth0: link up
Jan 7 21:32:25 elmo kernel: [ 131.813620] r8169 0000:03:00.0 eth0: link up
Jan 7 21:32:55 elmo kernel: [ 161.774516] r8169 0000:03:00.0 eth0: link up
Jan 7 21:33:13 elmo kernel: [ 179.768739] r8169 0000:03:00.0 eth0: link up
Jan 7 21:33:37 elmo kernel: [ 203.758175] r8169 0000:03:00.0 eth0: link up
Jan 7 21:34:19 elmo kernel: [ 245.709869] r8169 0000:03:00.0 eth0: link up
Jan 7 21:35:01 elmo kernel: [ 287.693507] r8169 0000:03:00.0 eth0: link up
Jan 7 21:35:31 elmo kernel: [ 317.654398] r8169 0000:03:00.0 eth0: link up
Jan 7 21:36:01 elmo kernel: [ 347.647293] r8169 0000:03:00.0 eth0: link up
Jan 7 21:36:37 elmo kernel: [ 383.606973] r8169 0000:03:00.0 eth0: link up
Jan 7 21:37:01 elmo kernel: [ 407.633061] r8169 0000:03:00.0 eth0: link up
Jan 7 21:37:19 elmo kernel: [ 425.571252] r8169 0000:03:00.0 eth0: link up
Jan 7 21:38:47 elmo kernel: [ 513.921118] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 7 21:38:47 elmo kernel: [ 513.921136] r8169 0000:03:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 7 21:38:47 elmo kernel: [ 513.921421] r8169 0000:03:00.0: irq 72 for MSI/MSI-X
Jan 7 21:38:47 elmo kernel: [ 513.921795] r8169 0000:03:00.0 eth0: RTL8168c/8111c at 0xffffc90001820000, 00:e0:4c:80:66:57, XID 1c4000c0 IRQ 72
Jan 7 21:38:47 elmo kernel: [ 513.921802] r8169 0000:03:00.0 eth0: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 7 21:38:47 elmo kernel: [ 513.927502] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 7 21:38:47 elmo kernel: [ 513.927525] r8169 0000:06:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 7 21:38:47 elmo kernel: [ 513.927767] r8169 0000:06:00.0: irq 73 for MSI/MSI-X
Jan 7 21:38:47 elmo kernel: [ 513.928204] r8169 0000:06:00.0 eth1: RTL8168c/8111c at 0xffffc90001824000, 00:e0:4c:80:70:08, XID 1c4000c0 IRQ 73
Jan 7 21:38:47 elmo kernel: [ 513.928211] r8169 0000:06:00.0 eth1: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 7 21:39:08 elmo kernel: [ 534.217262] r8169 0000:03:00.0 eth0: link down
Jan 7 21:39:08 elmo kernel: [ 534.217274] r8169 0000:03:00.0 eth0: link down
Jan 7 21:39:11 elmo kernel: [ 537.473818] r8169 0000:03:00.0 eth0: link up
Jan 7 21:39:23 elmo kernel: [ 549.508735] r8169 0000:03:00.0 eth0: link up
Jan 7 21:39:35 elmo kernel: [ 561.479471] r8169 0000:03:00.0 eth0: link up
Jan 7 21:39:53 elmo kernel: [ 579.541748] r8169 0000:03:00.0 eth0: link up
Jan 7 21:40:29 elmo kernel: [ 615.580750] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 7 21:40:29 elmo kernel: [ 615.580771] r8169 0000:03:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 7 21:40:29 elmo kernel: [ 615.581034] r8169 0000:03:00.0: irq 72 for MSI/MSI-X
Jan 7 21:40:29 elmo kernel: [ 615.586376] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 7 21:40:29 elmo kernel: [ 615.586395] r8169 0000:06:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 7 21:40:29 elmo kernel: [ 615.586632] r8169 0000:06:00.0: irq 73 for MSI/MSI-X
Jan 7 21:45:36 elmo kernel: [ 0.924701] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 7 21:45:36 elmo kernel: [ 0.924807] r8169 0000:03:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 7 21:45:36 elmo kernel: [ 0.925414] r8169 0000:03:00.0: irq 72 for MSI/MSI-X
Jan 7 21:45:36 elmo kernel: [ 0.925768] r8169 0000:03:00.0 eth0: RTL8168c/8111c at 0xffffc90001820000, 00:e0:4c:80:66:57, XID 1c4000c0 IRQ 72
Jan 7 21:45:36 elmo kernel: [ 0.925771] r8169 0000:03:00.0 eth0: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 7 21:45:36 elmo kernel: [ 0.925797] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 7 21:45:36 elmo kernel: [ 0.925804] r8169 0000:06:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 7 21:45:36 elmo kernel: [ 0.925981] r8169 0000:06:00.0: irq 73 for MSI/MSI-X
Jan 7 21:45:36 elmo kernel: [ 0.926099] r8169 0000:06:00.0 eth1: RTL8168c/8111c at 0xffffc90001824000, 00:e0:4c:80:70:08, XID 1c4000c0 IRQ 73
Jan 7 21:45:36 elmo kernel: [ 0.926101] r8169 0000:06:00.0 eth1: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 7 21:45:36 elmo kernel: [ 21.831549] r8169 0000:03:00.0 eth0: link down
Jan 7 21:45:44 elmo kernel: [ 42.735362] r8169 0000:06:00.0 eth1: link down
Jan 7 21:45:44 elmo kernel: [ 42.735371] r8169 0000:06:00.0 eth1: link down
Jan 7 21:45:47 elmo kernel: [ 45.491721] r8169 0000:06:00.0 eth1: link up
Jan 7 21:47:59 elmo kernel: [ 177.794729] NETDEV WATCHDOG: eth1 (r8169): transmit queue 0 timed out
Jan 7 21:47:59 elmo kernel: [ 177.794732] Modules linked in: ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 bnep rfcomm bluetooth rfkill vhost_net vhost macvtap macvlan tun ipt_MASQUERADE iptable_nat nf_nat_ipv4 nf_nat xt_CHECKSUM iptable_mangle bridge stp llc xt_multiport ip6table_filter ip6_tables ebtable_nat ebtables parport_pc ppdev lp parport binfmt_misc ipt_REJECT xt_tcpudp xt_LOG xt_mac nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack iptable_filter ip_tables x_tables fuse it87 hwmon_vid loop tda18271 tda10048 joydev hid_generic snd_hda_codec_hdmi usbhid hid evdev raid1 md_mod kvm_amd kvm crc32_pclmul crc32c_intel ghash_clmulni_intel aesni_intel aes_x86_64 ablk_helper cryptd lrw gf128mul glue_helper psmouse pcspkr serio_raw k10temp edac_mce_amd fam15h_power sp5100_tco edac_core nouveau snd_hda_codec_via i2c_piix4 mxm_wmi saa7164 wmi video ttm tveeprom drm_kms_helper dvb_core v4l2_common drm videodev media i2c_algo_bit snd_hda_intel i2c_core snd_hda_codec acpi_cpufreq snd_hwdep processor button snd_pcm snd_page_alloc snd_timer thermal_sys snd soundcore ext4 crc16 mbcache jbd2 dm_mod sg sd_mod sr_mod cdrom crc_t10dif crct10dif_common 8139too ehci_pci ahci ohci_pci ohci_hcd ehci_hcd libahci xhci_hcd r8169 mii usbcore libata usb_common scsi_mod
Jan 7 21:47:59 elmo kernel: [ 177.803038] r8169 0000:06:00.0 eth1: link up
Jan 7 21:55:13 elmo kernel: [ 611.228156] Modules linked in: r8168(O) ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 bnep rfcomm bluetooth rfkill vhost_net vhost macvtap macvlan tun ipt_MASQUERADE iptable_nat nf_nat_ipv4 nf_nat xt_CHECKSUM iptable_mangle bridge stp llc xt_multiport ip6table_filter ip6_tables ebtable_nat ebtables parport_pc ppdev lp parport binfmt_misc ipt_REJECT xt_tcpudp xt_LOG xt_mac nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack iptable_filter ip_tables x_tables fuse it87 hwmon_vid loop tda18271 tda10048 joydev hid_generic snd_hda_codec_hdmi usbhid hid evdev raid1 md_mod kvm_amd kvm crc32_pclmul crc32c_intel ghash_clmulni_intel aesni_intel aes_x86_64 ablk_helper cryptd lrw gf128mul glue_helper psmouse pcspkr serio_raw k10temp edac_mce_amd fam15h_power sp5100_tco edac_core nouveau snd_hda_codec_via i2c_piix4 mxm_wmi saa7164 wmi video ttm tveeprom drm_kms_helper dvb_core v4l2_common drm videodev media i2c_algo_bit snd_hda_intel i2c_core snd_hda_codec acpi_cpufreq snd_hwdep processor button snd_pcm snd_page_alloc snd_timer thermal_sys snd soundcore ext4 crc16 mbcache jbd2 dm_mod sg sd_mod sr_mod cdrom crc_t10dif crct10dif_common 8139too ehci_pci ahci ohci_pci ohci_hcd ehci_hcd libahci xhci_hcd mii usbcore libata usb_common scsi_mod [last unloaded: r8169]
Jan 9 08:52:26 elmo kernel: [124556.014238] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 9 08:52:26 elmo kernel: [124556.014257] r8169 0000:03:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 9 08:52:26 elmo kernel: [124556.014508] r8169 0000:03:00.0: irq 73 for MSI/MSI-X
Jan 9 08:52:26 elmo kernel: [124556.014791] r8169 0000:03:00.0 eth0: RTL8168c/8111c at 0xffffc90001870000, 00:e0:4c:80:66:57, XID 1c4000c0 IRQ 73
Jan 9 08:52:26 elmo kernel: [124556.014799] r8169 0000:03:00.0 eth0: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 9 08:52:26 elmo kernel: [124556.014984] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 9 08:52:26 elmo kernel: [124556.015001] r8169 0000:06:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 9 08:52:26 elmo kernel: [124556.015248] r8169 0000:06:00.0: irq 74 for MSI/MSI-X
Jan 9 08:52:26 elmo kernel: [124556.015509] r8169 0000:06:00.0 eth1: RTL8168c/8111c at 0xffffc9000187e000, 00:e0:4c:80:70:08, XID 1c4000c0 IRQ 74
Jan 9 08:52:26 elmo kernel: [124556.015515] r8169 0000:06:00.0 eth1: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 9 08:52:26 elmo kernel: [124556.056527] r8169 0000:03:00.0 eth0: link down
Jan 9 08:52:27 elmo kernel: [124557.661174] r8169 0000:03:00.0 eth0: link up
Jan 9 08:52:52 elmo kernel: [124582.349643] r8169 0000:03:00.0 eth0: link up
Jan 9 08:53:46 elmo kernel: [124636.305529] r8169 0000:03:00.0 eth0: link up
Jan 9 08:54:36 elmo kernel: [124686.536235] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 9 08:54:36 elmo kernel: [124686.536260] r8169 0000:03:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 9 08:54:36 elmo kernel: [124686.536512] r8169 0000:03:00.0: irq 73 for MSI/MSI-X
Jan 9 08:54:36 elmo kernel: [124686.536805] r8169 0000:03:00.0 eth0: RTL8168c/8111c at 0xffffc90001870000, 00:e0:4c:80:66:57, XID 1c4000c0 IRQ 73
Jan 9 08:54:36 elmo kernel: [124686.536812] r8169 0000:03:00.0 eth0: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 9 08:54:36 elmo kernel: [124686.547745] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
Jan 9 08:54:36 elmo kernel: [124686.547769] r8169 0000:06:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 9 08:54:36 elmo kernel: [124686.548024] r8169 0000:06:00.0: irq 74 for MSI/MSI-X
Jan 9 08:54:36 elmo kernel: [124686.555383] r8169 0000:03:00.0 eth0: link down
Jan 9 08:54:36 elmo kernel: [124686.555396] r8169 0000:03:00.0 eth0: link down
Jan 9 08:54:36 elmo kernel: [124686.555635] r8169 0000:06:00.0 eth1: RTL8168c/8111c at 0xffffc9000187e000, 00:e0:4c:80:70:08, XID 1c4000c0 IRQ 74
Jan 9 08:54:36 elmo kernel: [124686.555640] r8169 0000:06:00.0 eth1: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 9 08:54:40 elmo kernel: [124690.143434] r8169 0000:03:00.0 eth0: link up
Jan 9 08:55:40 elmo kernel: [124750.245190] r8169 0000:03:00.0 eth0: link up
Jan 9 08:56:28 elmo kernel: [124798.267925] r8169 0000:03:00.0 eth0: link up
Jan 9 08:58:16 elmo kernel: [124906.124315] r8169 0000:03:00.0 eth0: link up
Jan 9 09:00:34 elmo kernel: [125043.447578] r8169 0000:03:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 9 09:00:34 elmo kernel: [125043.447833] r8169 0000:03:00.0: irq 73 for MSI/MSI-X
Jan 9 09:00:34 elmo kernel: [125043.448156] r8169 0000:03:00.0 eth0: RTL8168c/8111c at 0xffffc90001870000, 00:e0:4c:80:66:57, XID 1c4000c0 IRQ 73
Jan 9 09:00:34 elmo kernel: [125043.448162] r8169 0000:03:00.0 eth0: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 9 09:00:34 elmo kernel: [125043.460502] r8169 0000:06:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 9 09:00:34 elmo kernel: [125043.460705] r8169 0000:06:00.0: irq 74 for MSI/MSI-X
Jan 9 09:00:34 elmo kernel: [125043.467175] r8169 0000:06:00.0 eth1: RTL8168c/8111c at 0xffffc9000187e000, 00:e0:4c:80:70:08, XID 1c4000c0 IRQ 74
Jan 9 09:00:34 elmo kernel: [125043.467181] r8169 0000:06:00.0 eth1: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 9 09:09:00 elmo kernel: [125549.128197] r8169 0000:03:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 9 09:09:00 elmo kernel: [125549.128457] r8169 0000:03:00.0: irq 73 for MSI/MSI-X
Jan 9 09:09:00 elmo kernel: [125549.128748] r8169 0000:03:00.0 eth0: RTL8168c/8111c at 0xffffc90001870000, 00:e0:4c:80:66:57, XID 1c4000c0 IRQ 73
Jan 9 09:09:00 elmo kernel: [125549.128755] r8169 0000:03:00.0 eth0: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 9 09:09:00 elmo kernel: [125549.145664] r8169 0000:06:00.0: can't disable ASPM; OS doesn't have ASPM control
Jan 9 09:09:00 elmo kernel: [125549.145934] r8169 0000:06:00.0: irq 74 for MSI/MSI-X
Jan 9 09:09:00 elmo kernel: [125549.146934] r8169 0000:03:00.0 eth0: link down
Jan 9 09:09:00 elmo kernel: [125549.147189] r8169 0000:06:00.0 eth1: RTL8168c/8111c at 0xffffc9000187e000, 00:e0:4c:80:70:08, XID 1c4000c0 IRQ 74
Jan 9 09:09:00 elmo kernel: [125549.147193] r8169 0000:06:00.0 eth1: jumbo features [frames: 6128 bytes, tx checksumming: ko]
Jan 9 09:09:00 elmo kernel: [125549.147234] r8169 0000:03:00.0 eth0: link down
Jan 9 09:09:03 elmo kernel: [125552.943570] r8169 0000:03:00.0 eth0: link up
Jan 9 09:09:28 elmo kernel: [125577.579875] r8169 0000:03:00.0 eth0: link up
Jan 9 09:10:34 elmo kernel: [125643.518729] r8169 0000:03:00.0 eth0: link up
Jan 9 09:11:04 elmo kernel: [125673.505548] r8169 0000:03:00.0 eth0: link up
Jan 9 09:11:52 elmo kernel: [125721.462613] r8169 0000:03:00.0 eth0: link up
Jan 9 09:12:22 elmo kernel: [125751.445129] r8169 0000:03:00.0 eth0: link up
Jan 9 09:13:31 elmo kernel: [125820.588517] r8169 0000:03:00.0 eth0: link down
Jan 9 09:13:31 elmo kernel: [125820.588524] r8169 0000:03:00.0 eth0: link down
Jan 9 09:13:34 elmo kernel: [125823.765570] r8169 0000:03:00.0 eth0: link up
Jan 9 09:13:59 elmo kernel: [125848.409967] r8169 0000:03:00.0 eth0: link up
Jan 9 10:56:59 elmo kernel: [132023.485940] r8169 0000:03:00.0 eth0: link down
Jan 9 11:02:14 elmo kernel: [132338.259437] r8169 0000:03:00.0 eth0: link up
Jan 9 11:02:15 elmo kernel: [132338.888600] r8169 0000:03:00.0 eth0: link down
Jan 9 11:02:17 elmo kernel: [132340.899557] r8169 0000:03:00.0 eth0: link up
Jan 9 12:21:59 elmo kernel: [137119.706747] r8169 0000:03:00.0 eth0: link up
Jan 9 13:46:58 elmo kernel: [142215.007812] r8169 0000:03:00.0 eth0: link down
Jan 9 13:51:11 elmo kernel: [142467.021851] r8169 0000:03:00.0 eth0: link up
Jan 9 13:51:12 elmo kernel: [142468.036445] r8169 0000:03:00.0 eth0: link down
Jan 9 13:51:13 elmo kernel: [142469.683089] r8169 0000:03:00.0 eth0: link up
Jan 9 14:22:01 elmo kernel: [144316.058860] r8169 0000:03:00.0 eth0: link up
Jan 10 00:15:01 elmo kernel: [179868.506724] r8169 0000:03:00.0 eth0: link up
Jan 10 01:34:07 elmo kernel: [184610.809173] r8169 0000:03:00.0 eth0: link up
Jan 10 06:27:19 elmo kernel: [202189.245589] r8169 0000:03:00.0 eth0: link up
Jan 10 10:25:17 elmo kernel: [216458.170910] r8169 0000:03:00.0 eth0: link up
Jan 10 10:50:23 elmo kernel: [217963.001075] r8169 0000:03:00.0 eth0: link up
Jan 10 11:04:29 elmo kernel: [218808.352269] r8169 0000:03:00.0 eth0: link up
Jan 10 11:27:35 elmo kernel: [220193.304666] r8169 0000:03:00.0 eth0: link up
Jan 10 11:50:23 elmo kernel: [221560.241410] r8169 0000:03:00.0 eth0: link up
Jan 10 12:05:59 elmo kernel: [222495.539781] r8169 0000:03:00.0 eth0: link up
Jan 10 12:29:41 elmo kernel: [223916.436973] r8169 0000:03:00.0 eth0: link up
Jan 10 12:51:23 elmo kernel: [225217.437479] r8169 0000:03:00.0 eth0: link up
Jan 10 13:04:53 elmo kernel: [226026.817632] r8169 0000:03:00.0 eth0: link up
Jan 10 13:28:47 elmo kernel: [227459.718466] r8169 0000:03:00.0 eth0: link up
Jan 10 13:51:35 elmo kernel: [228826.681757] r8169 0000:03:00.0 eth0: link up
Jan 10 14:03:41 elmo kernel: [229552.123700] r8169 0000:03:00.0 eth0: link up
Jan 10 14:26:23 elmo kernel: [230913.072252] r8169 0000:03:00.0 eth0: link up
Jan 10 14:47:11 elmo kernel: [232160.105546] r8169 0000:03:00.0 eth0: link up
Jan 10 15:12:11 elmo kernel: [233658.974021] r8169 0000:03:00.0 eth0: link up
Jan 10 15:29:29 elmo kernel: [234696.177510] r8169 0000:03:00.0 eth0: link up
Jan 10 15:50:23 elmo kernel: [235949.197834] r8169 0000:03:00.0 eth0: link up
Jan 10 16:13:17 elmo kernel: [237322.147870] r8169 0000:03:00.0 eth0: link up
Jan 10 16:34:17 elmo kernel: [238581.179914] r8169 0000:03:00.0 eth0: link up
Jan 10 16:59:23 elmo kernel: [240086.040262] r8169 0000:03:00.0 eth0: link up
Jan 10 17:14:59 elmo kernel: [241021.338493] r8169 0000:03:00.0 eth0: link up
Jan 10 17:36:29 elmo kernel: [242310.318221] r8169 0000:03:00.0 eth0: link up
Jan 10 18:00:29 elmo kernel: [243749.209619] r8169 0000:03:00.0 eth0: link up
Jan 10 18:24:17 elmo kernel: [245176.117274] r8169 0000:03:00.0 eth0: link up
Jan 10 18:47:11 elmo kernel: [246549.108048] r8169 0000:03:00.0 eth0: link up
Jan 10 19:02:35 elmo kernel: [247472.355174] r8169 0000:03:00.0 eth0: link up
Jan 10 19:26:47 elmo kernel: [248923.303384] r8169 0000:03:00.0 eth0: link up
Jan 10 19:50:47 elmo kernel: [250362.144802] r8169 0000:03:00.0 eth0: link up
Jan 10 20:13:29 elmo kernel: [251723.101783] r8169 0000:03:00.0 eth0: link up
Jan 10 20:35:29 elmo kernel: [253042.081251] r8169 0000:03:00.0 eth0: link up
Jan 10 20:59:29 elmo kernel: [254480.981747] r8169 0000:03:00.0 eth0: link up
Jan 10 21:22:17 elmo kernel: [255847.927367] r8169 0000:03:00.0 eth0: link up
Jan 10 21:46:11 elmo kernel: [257280.835154] r8169 0000:03:00.0 eth0: link up
Jan 10 22:10:35 elmo kernel: [258743.709869] r8169 0000:03:00.0 eth0: link up
Jan 10 22:25:23 elmo kernel: [259631.016371] r8169 0000:03:00.0 eth0: link up
Jan 10 22:49:47 elmo kernel: [261093.912822] r8169 0000:03:00.0 eth0: link up
Jan 10 23:14:29 elmo kernel: [262574.775599] r8169 0000:03:00.0 eth0: link up
Jan 10 23:41:05 elmo kernel: [264169.532821] r8169 0000:03:00.0 eth0: link up
Jan 11 00:20:29 elmo kernel: [266531.713878] r8169 0000:03:00.0 eth0: link up
Jan 11 01:08:29 elmo kernel: [269409.500032] r8169 0000:03:00.0 eth0: link up
Jan 11 01:22:35 elmo kernel: [270254.861202] r8169 0000:03:00.0 eth0: link up
Jan 11 01:45:53 elmo kernel: [271651.779561] r8169 0000:03:00.0 eth0: link up
Jan 11 02:09:29 elmo kernel: [273066.706131] r8169 0000:03:00.0 eth0: link up
Jan 11 02:25:11 elmo kernel: [274008.016185] r8169 0000:03:00.0 eth0: link up
Jan 11 02:48:53 elmo kernel: [275428.884591] r8169 0000:03:00.0 eth0: link up
Jan 11 03:14:05 elmo kernel: [276939.735485] r8169 0000:03:00.0 eth0: link up
Jan 11 03:55:29 elmo kernel: [279421.824429] r8169 0000:03:00.0 eth0: link up
Jan 11 04:42:29 elmo kernel: [282239.665715] r8169 0000:03:00.0 eth0: link up
Jan 11 05:26:05 elmo kernel: [284853.658781] r8169 0000:03:00.0 eth0: link up
Jan 11 06:14:05 elmo kernel: [287731.454199] r8169 0000:03:00.0 eth0: link up
Jan 11 06:25:11 elmo kernel: [288396.950192] r8169 0000:03:00.0 eth0: link up
Jan 11 06:41:23 elmo kernel: [289368.205492] r8169 0000:03:00.0 eth0: link up
Jan 11 07:05:29 elmo kernel: [290813.090764] r8169 0000:03:00.0 eth0: link up
Jan 11 07:28:11 elmo kernel: [292174.044720] r8169 0000:03:00.0 eth0: link up
Jan 11 07:52:23 elmo kernel: [293624.947008] r8169 0000:03:00.0 eth0: link up
Jan 11 08:16:17 elmo kernel: [295057.821023] r8169 0000:03:00.0 eth0: link up
Jan 11 08:30:35 elmo kernel: [295915.174546] r8169 0000:03:00.0 eth0: link up
Jan 11 08:56:41 elmo kernel: [297479.953856] r8169 0000:03:00.0 eth0: link up
Jan 11 09:20:41 elmo kernel: [298918.875097] r8169 0000:03:00.0 eth0: link up
Jan 11 09:42:29 elmo kernel: [300225.856036] r8169 0000:03:00.0 eth0: link up
Jan 11 10:05:17 elmo kernel: [301592.816385] r8169 0000:03:00.0 eth0: link up
Jan 11 10:22:47 elmo kernel: [302642.021483] r8169 0000:03:00.0 eth0: link up
Jan 11 10:46:41 elmo kernel: [304074.915787] r8169 0000:03:00.0 eth0: link up
Jan 11 11:12:47 elmo kernel: [305639.727570] r8169 0000:03:00.0 eth0: link up
Jan 11 11:43:17 elmo kernel: [307468.308263] r8169 0000:03:00.0 eth0: link up
Jan 11 11:56:53 elmo kernel: [308283.696450] r8169 0000:03:00.0 eth0: link up
Jan 11 12:19:47 elmo kernel: [309656.641788] r8169 0000:03:00.0 eth0: link up
Jan 11 12:43:05 elmo kernel: [311053.560314] r8169 0000:03:00.0 eth0: link up
Jan 11 13:07:47 elmo kernel: [312534.418463] r8169 0000:03:00.0 eth0: link up
Jan 11 13:30:41 elmo kernel: [313907.365171] r8169 0000:03:00.0 eth0: link up
Jan 11 13:54:17 elmo kernel: [315322.276762] r8169 0000:03:00.0 eth0: link up
Jan 11 14:18:47 elmo kernel: [316791.163514] r8169 0000:03:00.0 eth0: link up
Jan 11 14:42:29 elmo kernel: [318212.066921] r8169 0000:03:00.0 eth0: link up
Jan 11 15:07:47 elmo kernel: [319728.890740] r8169 0000:03:00.0 eth0: link up
Jan 11 15:22:47 elmo kernel: [320628.199976] r8169 0000:03:00.0 eth0: link up
Jan 11 15:46:41 elmo kernel: [322061.101203] r8169 0000:03:00.0 eth0: link up
Jan 11 16:09:59 elmo kernel: [323458.047578] r8169 0000:03:00.0 eth0: link up
Jan 11 16:32:29 elmo kernel: [324807.000015] r8169 0000:03:00.0 eth0: link up
Jan 11 16:56:17 elmo kernel: [326233.897558] r8169 0000:03:00.0 eth0: link up
Jan 11 17:19:23 elmo kernel: [327618.832116] r8169 0000:03:00.0 eth0: link up
Jan 11 17:42:17 elmo kernel: [328991.781805] r8169 0000:03:00.0 eth0: link up
Jan 11 17:58:29 elmo kernel: [329963.040468] r8169 0000:03:00.0 eth0: link up
Jan 11 18:19:29 elmo kernel: [331222.061017] r8169 0000:03:00.0 eth0: link up
Jan 11 18:43:17 elmo kernel: [332648.954572] r8169 0000:03:00.0 eth0: link up
Jan 11 19:12:53 elmo kernel: [334423.600928] r8169 0000:03:00.0 eth0: link up
Jan 11 19:54:23 elmo kernel: [336911.694736] r8169 0000:03:00.0 eth0: link up
Jan 11 20:08:29 elmo kernel: [337757.063044] r8169 0000:03:00.0 eth0: link up
Jan 11 20:32:17 elmo kernel: [339183.947065] r8169 0000:03:00.0 eth0: link up
Jan 11 20:56:41 elmo kernel: [340646.830012] r8169 0000:03:00.0 eth0: link up
Jan 11 21:12:35 elmo kernel: [341600.106319] r8169 0000:03:00.0 eth0: link up
Jan 11 21:34:59 elmo kernel: [342943.072953] r8169 0000:03:00.0 eth0: link up
Jan 11 21:58:23 elmo kernel: [344346.010377] r8169 0000:03:00.0 eth0: link up
Jan 11 22:27:29 elmo kernel: [346090.650653] r8169 0000:03:00.0 eth0: link up
Jan 11 22:39:29 elmo kernel: [346810.097681] r8169 0000:03:00.0 eth0: link up
Jan 11 23:03:05 elmo kernel: [348225.015098] r8169 0000:03:00.0 eth0: link up
Jan 11 23:26:29 elmo kernel: [349627.946117] r8169 0000:03:00.0 eth0: link up
Jan 11 23:41:41 elmo kernel: [350539.240694] r8169 0000:03:00.0 eth0: link up
Jan 12 00:05:41 elmo kernel: [351978.133377] r8169 0000:03:00.0 eth0: link up
Jan 12 00:28:05 elmo kernel: [353321.087554] r8169 0000:03:00.0 eth0: link up
Jan 12 01:12:17 elmo kernel: [355971.080348] r8169 0000:03:00.0 eth0: link up
Jan 12 01:58:17 elmo kernel: [358728.956382] r8169 0000:03:00.0 eth0: link up
Jan 12 02:44:11 elmo kernel: [361480.834141] r8169 0000:03:00.0 eth0: link up
Jan 12 03:33:35 elmo kernel: [364442.572951] r8169 0000:03:00.0 eth0: link up
Jan 12 03:44:29 elmo kernel: [365096.063835] r8169 0000:03:00.0 eth0: link up
Jan 12 04:10:41 elmo kernel: [366666.862665] r8169 0000:03:00.0 eth0: link up
Jan 12 04:35:17 elmo kernel: [368141.719614] r8169 0000:03:00.0 eth0: link up
Jan 12 04:50:59 elmo kernel: [369083.003813] r8169 0000:03:00.0 eth0: link up
Jan 12 05:14:53 elmo kernel: [370515.900323] r8169 0000:03:00.0 eth0: link up
Jan 12 05:37:53 elmo kernel: [371894.857820] r8169 0000:03:00.0 eth0: link up
Jan 12 05:53:05 elmo kernel: [372806.157333] r8169 0000:03:00.0 eth0: link up
Jan 12 06:15:59 elmo kernel: [374179.086690] r8169 0000:03:00.0 eth0: link up
^ permalink raw reply
* [PATCH net-next] bridge: Remove unnecessary vlan_put_tag in br_handle_vlan
From: Toshiaki Makita @ 2014-01-22 0:29 UTC (permalink / raw)
To: David S . Miller, Stephen Hemminger, Vlad Yasevich, netdev
Cc: Toshiaki Makita
br_handle_vlan() pushes HW accelerated vlan tag into skbuff when outgoing
port is the bridge device.
This is unnecessary because __netif_receive_skb_core() can handle skbs
with HW accelerated vlan tag. In current implementation,
__netif_receive_skb_core() needs to extract the vlan tag embedded in skb
data. This could cause low network performance especially when receiving
frames at a high frame rate on the bridge device.
Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
---
net/bridge/br_vlan.c | 21 ---------------------
1 file changed, 21 deletions(-)
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 7ffc801..4ca4d0a 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -151,27 +151,6 @@ struct sk_buff *br_handle_vlan(struct net_bridge *br,
br_vlan_get_tag(skb, &vid);
if (test_bit(vid, pv->untagged_bitmap))
skb = br_vlan_untag(skb);
- else {
- /* Egress policy says "send tagged". If output device
- * is the bridge, we need to add the VLAN header
- * ourselves since we'll be going through the RX path.
- * Sending to ports puts the frame on the TX path and
- * we let dev_hard_start_xmit() add the header.
- */
- if (skb->protocol != htons(ETH_P_8021Q) &&
- pv->port_idx == 0) {
- /* vlan_put_tag expects skb->data to point to
- * mac header.
- */
- skb_push(skb, ETH_HLEN);
- skb = __vlan_put_tag(skb, skb->vlan_proto, skb->vlan_tci);
- if (!skb)
- goto out;
- /* put skb->data back to where it was */
- skb_pull(skb, ETH_HLEN);
- skb->vlan_tci = 0;
- }
- }
out:
return skb;
--
1.8.1.2
^ permalink raw reply related
* Re: [PATCH net-next] net: add vxlan description
From: David Miller @ 2014-01-22 0:28 UTC (permalink / raw)
To: jesse.brandeburg; +Cc: netdev, stephen
In-Reply-To: <1389985233-8097-1-git-send-email-jesse.brandeburg@intel.com>
From: Jesse Brandeburg <jesse.brandeburg@intel.com>
Date: Fri, 17 Jan 2014 11:00:33 -0800
> Add a description to the vxlan module, helping save the world
> from the minions of destruction and confusion.
>
> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Applied, thanks Jesse.
^ permalink raw reply
* Re: [PATCH net-next 1/5] bonding: The fail_over_mac should be set only in ACTIVE_BACKUP mode
From: Jay Vosburgh @ 2014-01-22 0:25 UTC (permalink / raw)
To: Ding Tianhong; +Cc: Veaceslav Falico, David S. Miller, Netdev, Andy Gospodarek
In-Reply-To: <52DE4161.3050801@huawei.com>
Ding Tianhong <dingtianhong@huawei.com> wrote:
>According the bonding.txt, the option fail_over_mac only affect for
>AB mode, but in currect code, the parameter could be set to active
>or follow in every mode, this will cause bonding could not set all
>slaves of an RR or XOR mode to the same MAC address at enslavement
>time, so reset fail_over_mac to 0 if the mode is not ACTIVE_BACKUP.
The correct way to fix this in general is to permit setting an
option at any time, but only have it take effect in active-backup mode.
This minimizes ordering requirements when setting options.
I would instead modify the bond enslave and removal processing
to check the mode in addition to fail_over_mac when setting a slave's
MAC during enslavement. The change active slave processing already only
calls the fail_over_mac function when in active-backup mode. This
should also be a simpler change set.
>Fix the wrong variables for pr_err().
>
>Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
>---
> drivers/net/bonding/bond_main.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index 3220b48..ecff04e 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -4307,12 +4307,14 @@ static int bond_check_params(struct bond_params *params)
> fail_over_mac_tbl);
> if (fail_over_mac_value == -1) {
> pr_err("Error: invalid fail_over_mac \"%s\"\n",
>- arp_validate == NULL ? "NULL" : arp_validate);
>+ fail_over_mac == NULL ? "NULL" : fail_over_mac);
This part is ok.
> return -EINVAL;
> }
>
>- if (bond_mode != BOND_MODE_ACTIVEBACKUP)
>- pr_warning("Warning: fail_over_mac only affects active-backup mode.\n");
>+ if (bond_mode != BOND_MODE_ACTIVEBACKUP) {
>+ pr_warning("Warning: fail_over_mac only affects active-backup mode, set it to 0.\n");
>+ fail_over_mac_value = BOND_FOM_NONE;
>+ }
This part is not.
I would additionally NAK patches 2, 3, and 4 (noting that 4
inhibits the change to fail_over_mac, but not the warning message that
we're changing it).
Patch 5 is ok, although it really has nothing to do with
fail_over_mac.
-J
> } else {
> fail_over_mac_value = BOND_FOM_NONE;
> }
>--
>1.8.0
---
-Jay Vosburgh, IBM Linux Technology Center, fubar@us.ibm.com
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox