Netdev List
 help / color / mirror / Atom feed
* Re: [RFC patch net-next] ipv4: use bcast as dst address in case IFF_NOARP is set
From: Jiri Pirko @ 2013-01-08 17:45 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: davem, edumazet, kuznet, jmorris, yoshfuji, kaber, netdev, pavlix
In-Reply-To: <7abb4995-17a4-49ca-b0a7-41af6ff763e1@tahiti.vyatta.com>

Tue, Jan 08, 2013 at 06:11:55PM CET, stephen.hemminger@vyatta.com wrote:
>
>> When IFF_NOARP is set on a device, dev->dev_addr is used as *dst*
>> addr of sent frames. That does not make sense. Use rather bcast
>> address
>> instead.
>> 
>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>
>What did you test this on? I think this may have been
>intentional to avoid broadcasting.

Thanks for looking at this Stephen.

I tested this on two boxes connected via ethernet.

I believe this may have been intentional, but what sense does it have to
use dev_addr as destination address? That is what I do not understand.

Also, what is the issue with sending all packets to broadcast when NOARP is
set? In my opinion, it only makes sense.

^ permalink raw reply

* Re: IPV4 TCP connection reset using iperf
From: Rick Jones @ 2013-01-08 17:39 UTC (permalink / raw)
  To: Madhvapathi Sriram; +Cc: netdev
In-Reply-To: <CAAvRe=izMJWEFDcZYEoJCY2Em7NQKco4_6x1L7t4h2XSJf6_Sg@mail.gmail.com>

On 01/08/2013 06:41 AM, Madhvapathi Sriram wrote:
> Hi,
>
> I have recently migrated to kernel version 3.6.10 from 3.2.1. I was
> running iperf to routinely measure TCP throughput and I have been
> facing problems eversince. I am using a wireless interface.
>
> wireless client: iperf -s -i 1 -w 1024K
> wireless server: iperf -c 192.168.1.1 -i -1 -w 1024 -t 600
>
> While, the connection is maintained for sometime and the perf logs
> keep going. Randomly, the connection breaks with the server side
> resetting the connection. The tcp dump on the client shows RST sent by
> the server. Switching back to 3.2.1 works. This issue starts from
> kernel version 3.5 onnwards.
>
> I have tried to probe along some points to take a look at the air
> logs, tcpdump on either sides but to no clue - everything seems normal
> like, the tcp window values, very less/negligible retransmissions and
> so on. The RST is set abruptly and randomly (no definite time - may
> happen randomly).
>
> I am looking for some suggestions or pointers towards analyzing the issue.

I cannot imagine that iperf bulk transfer would look all that much 
different from netperf bulk transfer, but I suppose you could see if a 
netperf TCP_STREAM test with similar configuration settings encounters 
the same RST issues.  Or, for that matter, an equally long-lived FTP or 
scp transfer.

rick jones

^ permalink raw reply

* Re: [PATCH v2] sctp: Change defaults on cookie hmac selection
From: Florian Fainelli @ 2013-01-08 17:36 UTC (permalink / raw)
  To: Vlad Yasevich
  Cc: Neil Horman, netdev, David Miller, Linus Torvalds, linux-sctp
In-Reply-To: <50EAEE64.5010300@gmail.com>

Le 01/07/13 16:48, Vlad Yasevich a écrit :
> No, thats the problem, your old config is no longer valid with this 
> new Kconfig
>> file.  Your config is telling the config utility that you want your 
>> default
>> Cookie hmac to be MD5, but you've explicitly told it (via your yes "" 
>> | make
>> oldconfig command), that you want SCTP_COOKIE_HMAC_MD5 to be 
>> disabled, so the
>> config utility is left with no choice to prompt you again for a 
>> default hmac,
>> which your command answers again by saying 
>> SCTP_DEFAULT_COOKIE_HMAC_MD5 (the
>> default choice of 1).  Thats your loop, you keep telling the config 
>> utility that
>> you both want the default hmac to be md5, and that you don't want to 
>> allow md5
>> to be an available hmac alg.
>>
>> Thats not a bug.  I'm sorry if your old configuration needs manual 
>> updating, but
>> there are no guarantees that old configurations will 'just work' in 
>> perpituity.
>>
>
> Neil
>
> Actually, I think we have a bug in the config.  Look at the thermal 
> driver config again.  It has:
>
> choice
>         prompt "Default Thermal governor"
>         default THERMAL_DEFAULT_GOV_STEP_WISE
>
> config THERMAL_DEFAULT_GOV_STEP_WISE
>     ...
> config THERMAL_DEFAULT_GOV_FAIR_SHARE
>     ...
> config THERMAL_DEFAULT_GOV_USER_SPACE
>     ...
> endchoice
>
>
> SCTP has:
>
> choice
>         prompt "Default SCTP cookie HMAC encoding"
>         default SCTP_COOKIE_HMAC_MD5
>
> config SCTP_DEFAULT_COOKIE_HMAC_MD5
>     ...
> config SCTP_DEFAULT_COOKIE_HMAC_SHA1
>     ...
> config SCTP_DEFAULT_COOKIE_HMAC_NONE
>     ...
> endchoice
>
> See the difference?  The default value of the choice statement needs to
> be one of the available choices.

Right, since none of the config symbols actually exist when migrating 
from and oldconfig we are still being prompted, which is just fine 
actually. Having the config symbol being the default a member of the 
choice/endchoice section is what should be expected.
--
Florian

^ permalink raw reply

* Proxy ARP causing Neighbour table overflow
From: Ian Pilcher @ 2013-01-08 17:26 UTC (permalink / raw)
  To: netdev

I am using proxy ARP to divide my home network into several different
subnets, while allowing them all to communicate through my residential
"router".  I am seeing a (very) large number of "Neighbour table over-
flow" messages, although I haven't noticed any impact on connectivity or
performance.

(If you're not familiar with proxy ARP, it's pretty cool.  See
http://en.wikipedia.org/wiki/Proxy_ARP.)

Some details on my setup:

* I have configured my residential router (Verizon FiOS) to use all of
  172.31.0.0/16 as my home network.

* The routers internal IP address is 172.31.255.254.  As expected its
  subnet mask is 255.255.0.0.

* I have configured the router's built-in DHCP server to provide
  addresses within the range 172.31.255.151 - 172.31.255.253 (along with
  a subnet mask of 255.255.0.0).  Normally, the only devices using these
  addresses are my FiOS set-top boxes.

* My subnets run on separate VLANs.  Routing between them is provided by
  a small server running CentOS 6.3 (32-bit).  The server has a dual-
  port NIC, and it is using mode 6 (balance-alb) bonding.  Thus, the
  interfaces on the server range from bond0.249 - bond0.255.

* The "upstream" IP address of my server (on bond0.255) is
  172.31.255.1; it's subnet mask is 255.255.255.0.  (Note the
  difference from the router's subnet mask.)

* The server acts as the default gateway for the other subnets --
  172.31.249.0/24 (on bond0.249, 172.31.249.254) through 172.31.254.0/24
  (on bond0.254, 172.31.249.254).

* I have set "net.ipv4.conf.bond0/255.proxy_arp = 1" in
  /etc/sysctl.conf.  When the server sees an ARP request on bond0.255
  for an address in the range 172.31.249.1 - 172.31.254.254, it responds
  with its own MAC (actually, one of its two MACs because of the way
  mode 6 bonding works).

Despite all this complexity (for a home network at least), I really
don't have a huge number of devices.  Running "arp -n | wc -l" on the
server shows that it has 15 entries in its ARP cache right now, which is
about normal.  It may go up a bit when I spin up a bunch of VMs, but not
by that much.

So why am I getting the "Neighbour table overflow" messages.  Everything
I can Google up on this messages indicates that it happens with "large,
flat networks" with a lot of users.  I do sort of have a large flat
network, but that's really only true from the router's point of view.

(I should note that I only recently configured Ethernet bonding, I was
seeing the "Neighbour table overflow" messages when I was using only a
single interface.)

Any ideas?

Thanks!

-- 
========================================================================
Ian Pilcher                                         arequipeno@gmail.com
Sometimes there's nothing left to do but crash and burn...or die trying.
========================================================================

^ permalink raw reply

* Re: [PATCH 1/2] ipv6: avoid blackhole and prohibited entries upon prefix purge [v2]
From: YOSHIFUJI Hideaki @ 2013-01-08 17:18 UTC (permalink / raw)
  To: nicolas.dichtel
  Cc: Romain KUNTZ, netdev, Eric Dumazet, davem, YOSHIFUJI Hideaki
In-Reply-To: <50EC47AD.8000801@6wind.com>

Nicolas Dichtel wrote:
> Le 08/01/2013 12:38, Romain KUNTZ a écrit :
>> On Jan 7, 2013, at 16:43 , Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:
>>> Le 07/01/2013 12:30, Romain KUNTZ a écrit :
>>>> Hello Nicolas,
>>>>
>>>> On Jan 7, 2013, at 11:25 , Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:
>>>>
>>>>> Le 05/01/2013 22:44, Romain KUNTZ a écrit :
>>>>>> Mobile IPv6 provokes a kernel Oops since commit 64c6d08e (ipv6:
>>>>>> del unreachable route when an addr is deleted on lo), because
>>>>>> ip6_route_lookup() may also return blackhole and prohibited
>>>>>> entry. However, these entries have a NULL rt6i_table argument,
>>>>>> which provokes an Oops in __ip6_del_rt() when trying to lock
>>>>>> rt6i_table->tb6_lock.
>>>>>>
>>>>>> Beside, when purging a prefix, blakhole and prohibited entries
>>>>>> should not be selected because they are not what we are looking
>>>>>> for.
>>>>>>
>>>>>> We fix this by adding two new lookup flags (RT6_LOOKUP_F_NO_BLK_HOLE
>>>>>> and RT6_LOOKUP_F_NO_PROHIBIT) in order to ensure that such entries
>>>>>> are skipped during lookup and that the correct entry is returned.
>>>>>>
>>>>>> [v2]: use 'goto out;' instead of 'goto again;' to avoid unnecessary
>>>>>> oprations on rt (as suggested by Eric Dumazet).
>>>>>>
>>>>>> Signed-off-by: Romain Kuntz <r.kuntz@ipflavors.com>
>>>>>> ---
>>>>>>   include/net/ip6_route.h |    2 ++
>>>>>>   net/ipv6/addrconf.c     |    4 +++-
>>>>>>   net/ipv6/fib6_rules.c   |    4 ++++
>>>>>>   3 files changed, 9 insertions(+), 1 deletions(-)
>>>>>>
>>>>>> diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
>>>>>> index 27d8318..3c93743 100644
>>>>>> --- a/include/net/ip6_route.h
>>>>>> +++ b/include/net/ip6_route.h
>>>>>> @@ -30,6 +30,8 @@ struct route_info {
>>>>>>   #define RT6_LOOKUP_F_SRCPREF_TMP    0x00000008
>>>>>>   #define RT6_LOOKUP_F_SRCPREF_PUBLIC    0x00000010
>>>>>>   #define RT6_LOOKUP_F_SRCPREF_COA    0x00000020
>>>>>> +#define RT6_LOOKUP_F_NO_BLK_HOLE    0x00000040
>>>>>> +#define RT6_LOOKUP_F_NO_PROHIBIT    0x00000080
>>>>>>
>>>>>>   /*
>>>>>>    * rt6_srcprefs2flags() and rt6_flags2srcprefs() translate
>>>>>> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
>>>>>> index 408cac4a..1891e23 100644
>>>>>> --- a/net/ipv6/addrconf.c
>>>>>> +++ b/net/ipv6/addrconf.c
>>>>>> @@ -948,7 +948,9 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
>>>>>>           fl6.flowi6_oif = ifp->idev->dev->ifindex;
>>>>>>           fl6.daddr = prefix;
>>>>>>           rt = (struct rt6_info *)ip6_route_lookup(net, &fl6,
>>>>>> -                             RT6_LOOKUP_F_IFACE);
>>>>>> +                        RT6_LOOKUP_F_IFACE |
>>>>>> +                        RT6_LOOKUP_F_NO_BLK_HOLE |
>>>>>> +                        RT6_LOOKUP_F_NO_PROHIBIT);
>>>>>>
>>>>>>           if (rt != net->ipv6.ip6_null_entry &&
>>>>> Is it not simpler to test the result here (net->ipv6.ip6_blk_hole_entry and
>>>>> net->ipv6.ip6_prohibit_entry) like for the null_entry?
>>>>> It will also avoid adding more flags.
>>>>
>>>> Your proposal would only solve part of the problem (the Oops in __ip6_del_rt()). Another problem here is that blackhole and prohibited rules should not be selected when trying to purge a prefix (correct me if I'm wrong) because they are not what we are looking for. This can prevent the targeted prefix from being purged.
>>> In fact, I'm not sure to get the scenario. This part of the code just tries
>>> to remove the connected prefix, added by the kernel when the address was added.
>>> Can you describe your scenario?
>>
>>
>> I should have given more details from the beginning, my mistake. The scenario where this happens is quite simple:
>>
>> - install a blackhole rule (e.g. "from 2001:db8::1000 blackhole" - the source address does not matter at all) with the FIB_RULE_FIND_SADDR flag set (setting this flag is not possible with iproute2, but for test purpose you can use the enclosed patch against the latest iproute2 tree and then use "./ip -6 rule add from 2001:db8::1000/128 blackhole prio 1000").
>>
>> - try to delete an address from one of your interface (any address, it can be different from the one you used for the blackhole rule): "ip -6 addr del <v6-addr>/64 dev eth<x>"
>>
>> and you get an Oops. When trying to remove the connected prefix, the fib6_rule_match() function will match the blackhole rule because RT6_LOOKUP_F_HAS_SADDR is not set and FIB_RULE_FIND_SADDR is set.
>>
>> With your proposal, the Oops is fixed but the connected prefix route is not deleted. With my initial patch, the Oops is fixed and the connected prefix route is also deleted.
> Ok, I get it. I thin,there is two bugs: the oops and the wrong lookup.
> 
> Your proposal fix only a particular case. Try this (with your ip route2 patch):
> ip -6 addr add 2002::1/64 dev eth0
> ip -6 route add 2002::/64 table 257 dev eth0
> ip -6 addr del 2002::1/64 dev eth0
> 
> The route deleted is not the connected prefix, but the route added in table 257.
> The connected prefix is still here in the main table. It's not what we want.
> Maybe the lookup should be done directly into the right table, ie table RT6_TABLE_PREFIX. What do you think?

I agree.  I think we can use addrconf_get_prefix_route() here.

--yoshfuji

^ permalink raw reply

* Re: balance-alb and arp-reply stomping
From: Jay Vosburgh @ 2013-01-08 17:14 UTC (permalink / raw)
  To: Matthew O'Connor; +Cc: netdev
In-Reply-To: <CAK8PzV=GN0+txo=ixnKGGUXEeJMfd8=Ce=bSReg_oJXScbs79g@mail.gmail.com>

Matthew O'Connor <liquidhorse@gmail.com> wrote:

>Hi!  I've encountered what appears to be a known "issue" with
>balance-alb, whereby when a bond configured thus is put into a bridge
>with virtual ethernet adapters, on reply to arp requests the bond
>appears to "stomp" the MAC of the outgoing replies with one of its own
>adapters' MACs.  The consequence seems to be intermittent
>connectivity, easily witnessed by ping-loss early in a virtual
>adapter's life.  Checking the ARP cache on another machine shows that
>the virtual adapter's MAC has been replaced with one of the bond
>slaves'.  Other bonding modes do not exhibit this behavior.
>
>I was wondering if this is something that had been brought up before
>for fixing, and whether or not you would accept a patch if an
>appropriate fix was implemented?  My naive understanding would suggest
>checking the outgoing reply against a table of known slaves, and if
>the MAC did not exist there then map it to a slave and transmit the
>reply unmodified.

	This should be fixed in current kernels (to have balanace-alb
mode not modify ARPs that do not originate locally); I see the patch in
the 3.8-rc2 source, but not in the linux-3.7.1 source.

	You could apply the patch to an older kernel, it's pretty
simple.  The patch itself can be found here:

http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=patch;h=567b871e503316b0927e54a3d7c86d50b722d955

	-J

---
	-Jay Vosburgh, IBM Linux Technology Center, fubar@us.ibm.com

^ permalink raw reply

* TCP sequence number security fixes for stable
From: Ben Hutchings @ 2013-01-08 17:13 UTC (permalink / raw)
  To: David Miller; +Cc: Eric Dumazet, John Dykstra, netdev

Please consider these for your stable update queue:

282f23c6ee343 tcp: implement RFC 5961 3.2
0c24604b68fc7 tcp: implement RFC 5961 4.2
e371589917011 tcp: refine SYN handling in tcp_validate_incoming
bd090dfc634dd tcp: tcp_replace_ts_recent() should not be called from tcp_validate_incoming()
354e4aa391ed5 tcp: RFC 5961 5.2 Blind Data Injection Attack Mitigation

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply

* Re: [RFC patch net-next] ipv4: use bcast as dst address in case IFF_NOARP is set
From: Stephen Hemminger @ 2013-01-08 17:11 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: davem, edumazet, kuznet, jmorris, yoshfuji, kaber, netdev
In-Reply-To: <1357650162-5554-1-git-send-email-jiri@resnulli.us>


> When IFF_NOARP is set on a device, dev->dev_addr is used as *dst*
> addr of sent frames. That does not make sense. Use rather bcast
> address
> instead.
> 
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>

What did you test this on? I think this may have been
intentional to avoid broadcasting.

^ permalink raw reply

* [PATCH net-next] ipv6: Optimize ipv6_change_dsfield().
From: YOSHIFUJI Hideaki @ 2013-01-08 16:47 UTC (permalink / raw)
  To: davem, netdev; +Cc: yoshfuji

Do not convert endian back and forth.
If the caller uses contant "mask" argument (and most callers do),
we can omit runtime endian conversion here.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
---
 include/net/dsfield.h |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/net/dsfield.h b/include/net/dsfield.h
index 8a8d4e0..e1ad903 100644
--- a/include/net/dsfield.h
+++ b/include/net/dsfield.h
@@ -43,11 +43,9 @@ static inline void ipv4_change_dsfield(struct iphdr *iph,__u8 mask,
 static inline void ipv6_change_dsfield(struct ipv6hdr *ipv6h,__u8 mask,
     __u8 value)
 {
-        __u16 tmp;
+	__be16 *p = (__force __be16 *)ipv6h;
 
-	tmp = ntohs(*(__be16 *) ipv6h);
-	tmp = (tmp & ((mask << 4) | 0xf00f)) | (value << 4);
-	*(__be16 *) ipv6h = htons(tmp);
+	*p = (*p & htons((((u16)mask << 4) | 0xf00f))) | htons((u16)value << 4);
 }
 
 
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH net-next] ipv6: Use container_of macro instead of magic number to get ipv6 header.
From: YOSHIFUJI Hideaki @ 2013-01-08 16:44 UTC (permalink / raw)
  To: davem, netdev; +Cc: yoshfuji

In ipv6_recv_error(), addr_offset points to daddr field of the ip header.
To get ipv6 header, use container_of() macro instead of substracting magic
number (24).

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
---
 net/ipv6/datagram.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 8edf260..56b692b 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -356,12 +356,11 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
 		sin->sin6_port = serr->port;
 		sin->sin6_scope_id = 0;
 		if (skb->protocol == htons(ETH_P_IPV6)) {
-			sin->sin6_addr =
-				*(struct in6_addr *)(nh + serr->addr_offset);
+			const struct ipv6hdr *ip6h = container_of((struct in6_addr *)(nh + serr->addr_offset),
+								  struct ipv6hdr, daddr);
+			sin->sin6_addr = ip6h->daddr;
 			if (np->sndflow)
-				sin->sin6_flowinfo =
-					(*(__be32 *)(nh + serr->addr_offset - 24) &
-					 IPV6_FLOWINFO_MASK);
+				sin->sin6_flowinfo = *(__be32 *)ip6h & IPV6_FLOWINFO_MASK;
 			if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
 				sin->sin6_scope_id = IP6CB(skb)->iif;
 		} else {
-- 
1.7.9.5

^ permalink raw reply related

* balance-alb and arp-reply stomping
From: Matthew O'Connor @ 2013-01-08 16:22 UTC (permalink / raw)
  To: netdev

Hi!  I've encountered what appears to be a known "issue" with
balance-alb, whereby when a bond configured thus is put into a bridge
with virtual ethernet adapters, on reply to arp requests the bond
appears to "stomp" the MAC of the outgoing replies with one of its own
adapters' MACs.  The consequence seems to be intermittent
connectivity, easily witnessed by ping-loss early in a virtual
adapter's life.  Checking the ARP cache on another machine shows that
the virtual adapter's MAC has been replaced with one of the bond
slaves'.  Other bonding modes do not exhibit this behavior.

I was wondering if this is something that had been brought up before
for fixing, and whether or not you would accept a patch if an
appropriate fix was implemented?  My naive understanding would suggest
checking the outgoing reply against a table of known slaves, and if
the MAC did not exist there then map it to a slave and transmit the
reply unmodified.

One thing I find strange about this problem: when pinging a host that
is behind said bond and bridge, I occasionally see the virtual
adapter's true MAC appear intermittently even though it would seem
gratuitous ARPs are also getting stomped.  The MAC appears and then
quickly disappears, replaced with one of the bond's slaves.  What's
more, after the virtual adapter has been a member of the bridge for a
good while (several minutes, it seems), the intermittent connectivity
seems less of an issue - for instance, I just pinged one host that
exhibited this problem the other day, and it replied to 370 pings
without a single lost packet.  Ordinarily, when the issue occurs,
50-70% of the packets appear to be lost.

I am not currently a member of this list - please CC me on replies!  THANKS!!

-- Matt

^ permalink raw reply

* Re: [PATCH 1/2] ipv6: avoid blackhole and prohibited entries upon prefix purge [v2]
From: Nicolas Dichtel @ 2013-01-08 16:22 UTC (permalink / raw)
  To: Romain KUNTZ; +Cc: netdev, Eric Dumazet, yoshfuji, davem
In-Reply-To: <08F52788-0BD9-4907-8FC3-E9DF530AB042@ipflavors.com>

Le 08/01/2013 12:38, Romain KUNTZ a écrit :
> On Jan 7, 2013, at 16:43 , Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:
>> Le 07/01/2013 12:30, Romain KUNTZ a écrit :
>>> Hello Nicolas,
>>>
>>> On Jan 7, 2013, at 11:25 , Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:
>>>
>>>> Le 05/01/2013 22:44, Romain KUNTZ a écrit :
>>>>> Mobile IPv6 provokes a kernel Oops since commit 64c6d08e (ipv6:
>>>>> del unreachable route when an addr is deleted on lo), because
>>>>> ip6_route_lookup() may also return blackhole and prohibited
>>>>> entry. However, these entries have a NULL rt6i_table argument,
>>>>> which provokes an Oops in __ip6_del_rt() when trying to lock
>>>>> rt6i_table->tb6_lock.
>>>>>
>>>>> Beside, when purging a prefix, blakhole and prohibited entries
>>>>> should not be selected because they are not what we are looking
>>>>> for.
>>>>>
>>>>> We fix this by adding two new lookup flags (RT6_LOOKUP_F_NO_BLK_HOLE
>>>>> and RT6_LOOKUP_F_NO_PROHIBIT) in order to ensure that such entries
>>>>> are skipped during lookup and that the correct entry is returned.
>>>>>
>>>>> [v2]: use 'goto out;' instead of 'goto again;' to avoid unnecessary
>>>>> oprations on rt (as suggested by Eric Dumazet).
>>>>>
>>>>> Signed-off-by: Romain Kuntz <r.kuntz@ipflavors.com>
>>>>> ---
>>>>>   include/net/ip6_route.h |    2 ++
>>>>>   net/ipv6/addrconf.c     |    4 +++-
>>>>>   net/ipv6/fib6_rules.c   |    4 ++++
>>>>>   3 files changed, 9 insertions(+), 1 deletions(-)
>>>>>
>>>>> diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
>>>>> index 27d8318..3c93743 100644
>>>>> --- a/include/net/ip6_route.h
>>>>> +++ b/include/net/ip6_route.h
>>>>> @@ -30,6 +30,8 @@ struct route_info {
>>>>>   #define RT6_LOOKUP_F_SRCPREF_TMP	0x00000008
>>>>>   #define RT6_LOOKUP_F_SRCPREF_PUBLIC	0x00000010
>>>>>   #define RT6_LOOKUP_F_SRCPREF_COA	0x00000020
>>>>> +#define RT6_LOOKUP_F_NO_BLK_HOLE	0x00000040
>>>>> +#define RT6_LOOKUP_F_NO_PROHIBIT	0x00000080
>>>>>
>>>>>   /*
>>>>>    * rt6_srcprefs2flags() and rt6_flags2srcprefs() translate
>>>>> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
>>>>> index 408cac4a..1891e23 100644
>>>>> --- a/net/ipv6/addrconf.c
>>>>> +++ b/net/ipv6/addrconf.c
>>>>> @@ -948,7 +948,9 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
>>>>>   		fl6.flowi6_oif = ifp->idev->dev->ifindex;
>>>>>   		fl6.daddr = prefix;
>>>>>   		rt = (struct rt6_info *)ip6_route_lookup(net, &fl6,
>>>>> -							 RT6_LOOKUP_F_IFACE);
>>>>> +						RT6_LOOKUP_F_IFACE |
>>>>> +						RT6_LOOKUP_F_NO_BLK_HOLE |
>>>>> +						RT6_LOOKUP_F_NO_PROHIBIT);
>>>>>
>>>>>   		if (rt != net->ipv6.ip6_null_entry &&
>>>> Is it not simpler to test the result here (net->ipv6.ip6_blk_hole_entry and
>>>> net->ipv6.ip6_prohibit_entry) like for the null_entry?
>>>> It will also avoid adding more flags.
>>>
>>> Your proposal would only solve part of the problem (the Oops in __ip6_del_rt()). Another problem here is that blackhole and prohibited rules should not be selected when trying to purge a prefix (correct me if I'm wrong) because they are not what we are looking for. This can prevent the targeted prefix from being purged.
>> In fact, I'm not sure to get the scenario. This part of the code just tries
>> to remove the connected prefix, added by the kernel when the address was added.
>> Can you describe your scenario?
>
>
> I should have given more details from the beginning, my mistake. The scenario where this happens is quite simple:
>
> - install a blackhole rule (e.g. "from 2001:db8::1000 blackhole" - the source address does not matter at all) with the FIB_RULE_FIND_SADDR flag set (setting this flag is not possible with iproute2, but for test purpose you can use the enclosed patch against the latest iproute2 tree and then use "./ip -6 rule add from 2001:db8::1000/128 blackhole prio 1000").
>
> - try to delete an address from one of your interface (any address, it can be different from the one you used for the blackhole rule): "ip -6 addr del <v6-addr>/64 dev eth<x>"
>
> and you get an Oops. When trying to remove the connected prefix, the fib6_rule_match() function will match the blackhole rule because RT6_LOOKUP_F_HAS_SADDR is not set and FIB_RULE_FIND_SADDR is set.
>
> With your proposal, the Oops is fixed but the connected prefix route is not deleted. With my initial patch, the Oops is fixed and the connected prefix route is also deleted.
Ok, I get it. I thin,there is two bugs: the oops and the wrong lookup.

Your proposal fix only a particular case. Try this (with your ip route2 patch):
ip -6 addr add 2002::1/64 dev eth0
ip -6 route add 2002::/64 table 257 dev eth0
ip -6 addr del 2002::1/64 dev eth0

The route deleted is not the connected prefix, but the route added in table 257.
The connected prefix is still here in the main table. It's not what we want.
Maybe the lookup should be done directly into the right table, ie table 
RT6_TABLE_PREFIX. What do you think?

^ permalink raw reply

* Re: [PATCH 1/1 net-next] net: fec: enable pause frame to improve rx prefomance for 1G network
From: Eric Nelson @ 2013-01-08 16:13 UTC (permalink / raw)
  To: Dirk Behme
  Cc: Frank Li, B38611@freescale.com, netdev@vger.kernel.org,
	s.hauer@pengutronix.de, lznuaa@gmail.com, shawn.guo@linaro.org,
	davem@davemloft.net, linux-arm-kernel@lists.infradead.org
In-Reply-To: <50EBED0E.6090608@de.bosch.com>

On 01/08/2013 02:55 AM, Dirk Behme wrote:
> On 08.01.2013 09:43, Frank Li wrote:
>> The limition of imx6 internal bus cause fec can't achieve 1G perfomance.
>> There will be many packages lost because FIFO over run.
>>
>> This patch enable pause frame flow control.
>
> Many thanks for this patch!
>
> Do we want/need anything similar for U-Boot, too?
>
> Some people want to boot the system from U-Boot attached to 1G network
> and have issues there, too.
>

It's hard to see how the typical use (dhcp+tftp) would be affected
because of the small packet sizes and half-duplex operation.

That said, the statistics registers make it pretty easy to see when
there are overflows as described here:
	http://boundarydevices.com/i-mx6-ethernet/

We should be able to just poke the ENET_MIBC register and watch
to see if the IEEE_R_MACERR register shows that overruns are
occurring using the U-Boot md and mw commands.

In a quick test, it appears that this doesn't work though.
This line of code in fec_halt from fec_mxc.c seems to clear the
statistics.

	writel(readl(&fec->eth->ecntrl) & ~FEC_ECNTRL_ETHER_EN,
			&fec->eth->ecntrl);

If you comment that out, you can see all of the statistics registers
as shown below:

U-Boot > mw.l 0x02188064 0    #ENET_MIBC
U-Boot > dhcp 10800000 192.168.0.55:uImage-bluemeany
BOOTP broadcast 1
DHCP client bound to address 192.168.0.91
Using FEC device
TFTP from server 192.168.0.55; our IP address is 192.168.0.91
Filename 'uImage-bluemeany'.
Load address: 0x10800000
Loading: ...
done
Bytes transferred = 3760504 (396178 hex)
U-Boot > md.l 0x02188200 0x39
02188200: 00000000 00001cb6 00000003 00000000    ................
02188210: 00000000 00000000 00000000 00000000    ................
02188220: 00000000 00000000 00001cb2 00000002    ................
02188230: 00000000 00000002 00000000 00000000    ................
02188240: 00000000 00072fd4 00000000 00001cb6    ...../..........
02188250: 00000000 00000000 00000000 00000000    ................
02188260: 00000000 00000000 00000000 00000000    ................
02188270: 00000000 00072fd4 00000000 00000000    ...../..........
02188280: 00000000 00001dca 0000002a 000000e6    ........*.......
02188290: 00000000 00000000 00000000 00000000    ................
021882a0: 00000000 00000000 00000037 00000057    ........7...W...
021882b0: 0000004e 00000023 00001ccb 00000000    N...#...........
021882c0: 00000000 003fd011 00000000 00001dcc    ......?.........
021882d0: 00000000 00000000 00000000 00000000    ................
021882e0: 003fd011    ..?.
U-Boot >

Register 0x021882d8 is the MACERR (fifo overlow) counter.

Regards,


Eric

^ permalink raw reply

* Re: [PATCH] ath9k_htc: Fix skb leaks
From: Larry Finger @ 2013-01-08 16:09 UTC (permalink / raw)
  To: Sujith Manoharan
  Cc: linville, linux-wireless, netdev, Stable, Luis R. Rodriguez,
	Vasanthakumar Thiagarajan, Senthil Balasubramanian, ath9k-devel,
	linux-kernel
In-Reply-To: <20707.50445.510814.481023@gargle.gargle.HOWL>

On 01/01/2013 11:26 PM, Sujith Manoharan wrote:
> Larry Finger wrote:
>> My only counter argument is that none of the other paths that get to
>> ath9k_htc_txcompletion_cb() leak the skb. It only happens for the path that goes
>> through htc_connect_service().
>
> Sure, but the TX completion handler would be invoked for every skb that is passed
> to the USB layer, including the ones that are allocated in htc_hst.c. When this
> skb goes down to hif_usb.c, a URB is allocated and I am not sure how freeing
> the skb before the USB layer invokes the completion handler for the URB is correct.
>
> I'll come up with a patch and see if kmemleak still complains.

Did I miss your posting on this issue?

Larry

^ permalink raw reply

* Re: [Xen-devel] xen-netback notify DomU to send ARP.
From: Ian Campbell @ 2013-01-08 16:00 UTC (permalink / raw)
  To: jianhai luan
  Cc: xen-devel@lists.xensource.com, netdev@vger.kernel.org,
	Konrad Rzeszutek Wilk
In-Reply-To: <50EC3DFD.8060206@oracle.com>

On Tue, 2013-01-08 at 15:40 +0000, jianhai luan wrote:
> 
> On 2013-1-8 21:42, Ian Campbell wrote: 
> > On Tue, 2013-01-08 at 13:13 +0000, Jan Beulich wrote: 
> > > > > > On 08.01.13 at 12:57, jianhai luan <jianhai.luan@oracle.com>
> > > > > > wrote: 
> > > >     When Xen Dom0's network circumstance changed, DomU 
> > > > should be notified in some special condition. For 
> > > > example the below circumstance: 
> > > >     ping from Guest A to DomU: 
> > > >     Guest A --> eth0 - bond0 - xenbr0 --VIF(DOMU) 
> > > >                 eth1 / 
> > > >     when eth0 inactive, and eth1 active. 
> > How is eth0 failing? Are you unplugging it, un-enslaving it or
> > taking 
> > some other sort of administrative action? 
> In my emulation environment, i unplug it or ifdown the interface,

I expect these would behave rather different, since the affect of ifdown
looks rather different to an unplug from the PoV of the switch.

Is the ifdown case something which you are trying to solve or just what
appeared to be a convenient test case? I'd be less inclined to worry
about explict admin actions such as that.

Unplugging the cable should cause:

> > Doesn't this state change cause the switch to which eth0 and eth1
> > are 
> > attached to forget the MAC tables associated with the eth0 port,
> > meaning 
> > that subsequent traffic will be flooded until it learns that eth1 is
> > the 
> > new port? 

Ian

^ permalink raw reply

* Re: xen-netback notify DomU to send ARP.
From: jianhai luan @ 2013-01-08 15:40 UTC (permalink / raw)
  To: Ian Campbell; +Cc: netdev, xen-devel, Ian Campbell, Konrad Rzeszutek Wilk
In-Reply-To: <1357652541.7989.179.camel@zakaz.uk.xensource.com>


[-- Attachment #1.1: Type: text/plain, Size: 2657 bytes --]


On 2013-1-8 21:42, Ian Campbell wrote:
> On Tue, 2013-01-08 at 13:13 +0000, Jan Beulich wrote:
>>>>> On 08.01.13 at 12:57, jianhai luan <jianhai.luan@oracle.com> wrote:
>>>     When Xen Dom0's network circumstance changed, DomU
>>> should be notified in some special condition. For
>>> example the below circumstance:
>>>     ping from Guest A to DomU:
>>>     Guest A --> eth0 - bond0 - xenbr0 --VIF(DOMU)
>>>                 eth1 /
>>>     when eth0 inactive, and eth1 active.
> How is eth0 failing? Are you unplugging it, un-enslaving it or taking
> some other sort of administrative action?
In my emulation environment, i unplug it or ifdown the interface, while 
eth0 maybe wrong in productive environment.
>
> Which bonding mode are you using?
Bond running in active-backup mode.
>
> Doesn't this state change cause the switch to which eth0 and eth1 are
> attached to forget the MAC tables associated with the eth0 port, meaning
> that subsequent traffic will be flooded until it learns that eth1 is the
> new port?
>
>>>     Guest A --> eth0   bond0 - xenbr0 --VIF(DOMU)
>>>                 eth1 /
>>>     Guest A will don't reach to DomU. After Guest A
>>>     send ARP request and DomU respond, Guest A will
>>>     reach DomU. But some more second will be elapsed.
>>>                 eth0   bond0 - xenbr0 --VIF(DOMU)
>>>     Guest A --> eth1/
>> Isn't a change to the availability of the bonds supposed to be
>> transparent to Guest A _and_ DomU? I.e. aren't you trying to fix
>> an eventual problem here in the wrong place?
> In non-virtualised bonding the bonding drive can take care of some of
> this because it knows its own MAC address and can send appropriate
> gratuitous frames (depends on the bonding mode) to paper over things. In
> the virtualised case it (most likely) doesn't know VIF(DOMU)s MAC
> address.
   If you have know all ip and mac before modprobe bond, you can 
configure the bond argument. But you don't know all ip and mac before 
start new virtual.
   If bond want to know all DomU's ip and mac which pass through, it 
must check all skb. it's not good idea.
>
>>> If Xen netback watch the network change, will notify
>>> DomU by change it own status. So netfront will watch
>>> netback's change, and DomU send ARP initiative.
>> Your patch is, at least according to what I see, completely
>> unusable - line breaks dropped, line order reversed, and
>> (guessing) some UTF-16/UCS-2 characters inserted at the top.
>> Please attach patches as plain ASCII.
>  From the name it looks to me like it is the vi temp file created while
> you have the file open rather than the actual patch file...
>
> Ian.
>
Thanks,
Jason


[-- Attachment #1.2: Type: text/html, Size: 5439 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply

* [PATCH v2] net: set default_ethtool_ops in register_netdevice
From: Stanislaw Gruszka @ 2013-01-08 15:38 UTC (permalink / raw)
  To: netdev, David S. Miller
  Cc: Eric Dumazet, Ben Greear, Bjørn Mork, linux-wireless,
	Ben Hutchings, Michał Mirosław

Since:

commit 2c60db037034d27f8c636403355d52872da92f81
Author: Eric Dumazet <edumazet@google.com>
Date:   Sun Sep 16 09:17:26 2012 +0000

    net: provide a default dev->ethtool_ops

wireless core does not correctly assign ethtool_ops. In order to fix
the problem, move assignement of default_ethtool_ops to
register_netdevice(). This is safe because both register_netdevice()
and dev_ethtool() are protected by RTNL lock.

Patch is besed on hint of Michał Mirosław.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: stable@vger.kernel.org # 3.7+
---
v1 -> v2: change order of default_ethtool_ops initialization to avoid
the problem. Change the subject accordingly.

 net/core/dev.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)


diff --git a/net/core/dev.c b/net/core/dev.c
index 515473e..3196820 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5710,6 +5710,8 @@ static int netif_alloc_netdev_queues(struct net_device *dev)
 	return 0;
 }
 
+static const struct ethtool_ops default_ethtool_ops;
+
 /**
  *	register_netdevice	- register a network device
  *	@dev: device to register
@@ -5830,6 +5832,8 @@ int register_netdevice(struct net_device *dev)
 	    dev->rtnl_link_state == RTNL_LINK_INITIALIZED)
 		rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
 
+	if (!dev->ethtool_ops)
+		dev->ethtool_ops = &default_ethtool_ops;
 out:
 	return ret;
 
@@ -6119,8 +6123,6 @@ struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
 	return queue;
 }
 
-static const struct ethtool_ops default_ethtool_ops;
-
 /**
  *	alloc_netdev_mqs - allocate network device
  *	@sizeof_priv:	size of private data to allocate space for
@@ -6208,8 +6210,6 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
 
 	strcpy(dev->name, name);
 	dev->group = INIT_NETDEV_GROUP;
-	if (!dev->ethtool_ops)
-		dev->ethtool_ops = &default_ethtool_ops;
 	return dev;
 
 free_all:
-- 
1.7.1

^ permalink raw reply related

* Re: [Patch] net: prevent setting ttl=0 via IP_TTL
From: Eric Dumazet @ 2013-01-08 15:07 UTC (permalink / raw)
  To: Cong Wang; +Cc: netdev, nitin padalia, David S. Miller
In-Reply-To: <1357629420-29725-1-git-send-email-xiyou.wangcong@gmail.com>

On Tue, 2013-01-08 at 15:17 +0800, Cong Wang wrote:

> ---
> diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
> index 3c9d208..d9c4f11 100644
> --- a/net/ipv4/ip_sockglue.c
> +++ b/net/ipv4/ip_sockglue.c
> @@ -590,7 +590,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
>  	case IP_TTL:
>  		if (optlen < 1)
>  			goto e_inval;
> -		if (val != -1 && (val < 0 || val > 255))
> +		if (val != -1 && (val < 1 || val > 255))
>  			goto e_inval;
>  		inet->uc_ttl = val;
>  		break;

Hmm, I wonder why I did this, indeed ....

Thanks !

Acked-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply

* [PATCH 5/5] kfifo: log based kfifo API
From: Yuanhan Liu @ 2013-01-08 14:57 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: Yuanhan Liu, Stefani Seibold, Andrew Morton,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
	platform-driver-x86-u79uwXL29TY76Z2rM5mHXA,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-media-u79uwXL29TY76Z2rM5mHXA,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	libertas-dev-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-pci-u79uwXL29TY76Z2rM5mHXA,
	open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
	linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg,
	dccp-u79uwXL29TY76Z2rM5mHXA, linux-sctp-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1357657073-27352-1-git-send-email-yuanhan.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

The current kfifo API take the kfifo size as input, while it rounds
 _down_ the size to power of 2 at __kfifo_alloc. This may introduce
potential issue.

Take the code at drivers/hid/hid-logitech-dj.c as example:

	if (kfifo_alloc(&djrcv_dev->notif_fifo,
                       DJ_MAX_NUMBER_NOTIFICATIONS * sizeof(struct dj_report),
                       GFP_KERNEL)) {

Where, DJ_MAX_NUMBER_NOTIFICATIONS is 8, and sizeo of(struct dj_report)
is 15.

Which means it wants to allocate a kfifo buffer which can store 8
dj_report entries at once. The expected kfifo buffer size would be
8 * 15 = 120 then. While, in the end, __kfifo_alloc will turn the
size to rounddown_power_of_2(120) =  64, and then allocate a buf
with 64 bytes, which I don't think this is the original author want.

With the new log API, we can do like following:

	int kfifo_size_order = order_base_2(DJ_MAX_NUMBER_NOTIFICATIONS *
					    sizeof(struct dj_report));

	if (kfifo_alloc(&djrcv_dev->notif_fifo, kfifo_size_order, GFP_KERNEL)) {

This make sure we will allocate enough kfifo buffer for holding
DJ_MAX_NUMBER_NOTIFICATIONS dj_report entries.

Cc: Stefani Seibold <stefani-mkwtCZVSLSnR7s880joybQ@public.gmane.org>
Cc: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Cc: platform-driver-x86-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: libertas-dev-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: open-iscsi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org
Cc: linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org
Cc: dccp-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-sctp-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Signed-off-by: Yuanhan Liu <yuanhan.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 arch/arm/plat-omap/Kconfig                  |    2 +-
 arch/arm/plat-omap/mailbox.c                |    6 +++-
 arch/powerpc/sysdev/fsl_rmu.c               |    2 +-
 drivers/char/sonypi.c                       |    9 ++++---
 drivers/hid/hid-logitech-dj.c               |    7 +++--
 drivers/iio/industrialio-event.c            |    2 +-
 drivers/iio/kfifo_buf.c                     |    3 +-
 drivers/infiniband/hw/cxgb3/cxio_resource.c |    8 ++++--
 drivers/media/i2c/cx25840/cx25840-ir.c      |    9 +++++--
 drivers/media/pci/cx23885/cx23888-ir.c      |    9 +++++--
 drivers/media/pci/meye/meye.c               |    6 +---
 drivers/media/pci/meye/meye.h               |    2 +
 drivers/media/rc/ir-raw.c                   |    7 +++--
 drivers/memstick/host/r592.h                |    2 +-
 drivers/mmc/card/sdio_uart.c                |    4 ++-
 drivers/mtd/sm_ftl.c                        |    5 +++-
 drivers/net/wireless/libertas/main.c        |    4 ++-
 drivers/net/wireless/rt2x00/rt2x00dev.c     |    5 +--
 drivers/pci/pcie/aer/aerdrv_core.c          |    3 +-
 drivers/platform/x86/fujitsu-laptop.c       |    5 ++-
 drivers/platform/x86/sony-laptop.c          |    6 ++--
 drivers/rapidio/devices/tsi721.c            |    5 ++-
 drivers/scsi/libiscsi_tcp.c                 |    6 +++-
 drivers/staging/omapdrm/omap_plane.c        |    5 +++-
 drivers/tty/n_gsm.c                         |    4 ++-
 drivers/tty/nozomi.c                        |    5 +--
 drivers/tty/serial/ifx6x60.c                |    2 +-
 drivers/tty/serial/ifx6x60.h                |    3 +-
 drivers/tty/serial/kgdb_nmi.c               |    7 +++--
 drivers/usb/host/fhci.h                     |    4 ++-
 drivers/usb/serial/cypress_m8.c             |    4 +-
 drivers/usb/serial/io_ti.c                  |    4 +-
 drivers/usb/serial/ti_usb_3410_5052.c       |    7 +++--
 drivers/usb/serial/usb-serial.c             |    2 +-
 include/linux/kfifo.h                       |   31 +++++++++++++--------------
 include/linux/rio.h                         |    1 +
 include/media/lirc_dev.h                    |    4 ++-
 kernel/kfifo.c                              |    9 +------
 mm/memory-failure.c                         |    3 +-
 net/dccp/probe.c                            |    6 +++-
 net/sctp/probe.c                            |    6 +++-
 samples/kfifo/bytestream-example.c          |    8 +++---
 samples/kfifo/dma-example.c                 |    5 ++-
 samples/kfifo/inttype-example.c             |    7 +++--
 samples/kfifo/record-example.c              |    6 ++--
 45 files changed, 142 insertions(+), 108 deletions(-)

diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index 665870d..7eda02c 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -124,7 +124,7 @@ config OMAP_MBOX_FWK
 	  DSP, IVA1.0 and IVA2 in OMAP1/2/3.
 
 config OMAP_MBOX_KFIFO_SIZE
-	int "Mailbox kfifo default buffer size (bytes)"
+	int "Mailbox kfifo default buffer size (bytes, should be power of 2. If not, will roundup to power of 2"
 	depends on OMAP_MBOX_FWK
 	default 256
 	help
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 42377ef..848fa0b 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -30,6 +30,7 @@
 #include <linux/err.h>
 #include <linux/notifier.h>
 #include <linux/module.h>
+#include <linux/log2.h>
 
 #include <plat/mailbox.h>
 
@@ -40,7 +41,7 @@ static DEFINE_MUTEX(mbox_configured_lock);
 
 static unsigned int mbox_kfifo_size = CONFIG_OMAP_MBOX_KFIFO_SIZE;
 module_param(mbox_kfifo_size, uint, S_IRUGO);
-MODULE_PARM_DESC(mbox_kfifo_size, "Size of omap's mailbox kfifo (bytes)");
+MODULE_PARM_DESC(mbox_kfifo_size, "Size of omap's mailbox kfifo (bytes, should be power of 2. If not, will roundup to power of 2)");
 
 /* Mailbox FIFO handle functions */
 static inline mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
@@ -218,6 +219,7 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
 					void (*tasklet)(unsigned long))
 {
 	struct omap_mbox_queue *mq;
+	int mbox_kfifo_size_order = order_base_2(mbox_kfifo_size);
 
 	mq = kzalloc(sizeof(struct omap_mbox_queue), GFP_KERNEL);
 	if (!mq)
@@ -225,7 +227,7 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
 
 	spin_lock_init(&mq->lock);
 
-	if (kfifo_alloc(&mq->fifo, mbox_kfifo_size, GFP_KERNEL))
+	if (kfifo_alloc(&mq->fifo, mbox_kfifo_size_order, GFP_KERNEL))
 		goto error;
 
 	if (work)
diff --git a/arch/powerpc/sysdev/fsl_rmu.c b/arch/powerpc/sysdev/fsl_rmu.c
index 14bd522..84d2b8c 100644
--- a/arch/powerpc/sysdev/fsl_rmu.c
+++ b/arch/powerpc/sysdev/fsl_rmu.c
@@ -587,7 +587,7 @@ int fsl_rio_port_write_init(struct fsl_rio_pw *pw)
 
 	INIT_WORK(&pw->pw_work, fsl_pw_dpc);
 	spin_lock_init(&pw->pw_fifo_lock);
-	if (kfifo_alloc(&pw->pw_fifo, RIO_PW_MSG_SIZE * 32, GFP_KERNEL)) {
+	if (kfifo_alloc(&pw->pw_fifo, RIO_KFIFO_SIZE_ORDER, GFP_KERNEL)) {
 		pr_err("FIFO allocation failed\n");
 		rc = -ENOMEM;
 		goto err_out_irq;
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index d780295..39d8dd7 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -429,7 +429,7 @@ static struct sonypi_eventtypes {
 	{ 0 }
 };
 
-#define SONYPI_BUF_SIZE	128
+#define SONYPI_KFIFO_SIZE_ORDER		7
 
 /* Correspondance table between sonypi events and input layer events */
 static struct {
@@ -1316,7 +1316,8 @@ static int sonypi_probe(struct platform_device *dev)
 			"http://www.linux.it/~malattia/wiki/index.php/Sony_drivers\n");
 
 	spin_lock_init(&sonypi_device.fifo_lock);
-	error = kfifo_alloc(&sonypi_device.fifo, SONYPI_BUF_SIZE, GFP_KERNEL);
+	error = kfifo_alloc(&sonypi_device.fifo, SONYPI_KFIFO_SIZE_ORDER,
+			GFP_KERNEL);
 	if (error) {
 		printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
 		return error;
@@ -1395,8 +1396,8 @@ static int sonypi_probe(struct platform_device *dev)
 		}
 
 		spin_lock_init(&sonypi_device.input_fifo_lock);
-		error = kfifo_alloc(&sonypi_device.input_fifo, SONYPI_BUF_SIZE,
-				GFP_KERNEL);
+		error = kfifo_alloc(&sonypi_device.input_fifo,
+				SONYPI_KFIFO_SIZE_ORDER, GFP_KERNEL);
 		if (error) {
 			printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
 			goto err_inpdev_unregister;
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index 9500f2f..031be77 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -26,6 +26,7 @@
 #include <linux/hid.h>
 #include <linux/module.h>
 #include <linux/usb.h>
+#include <linux/log2.h>
 #include <asm/unaligned.h>
 #include "usbhid/usbhid.h"
 #include "hid-ids.h"
@@ -730,6 +731,8 @@ static int logi_dj_probe(struct hid_device *hdev,
 	struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
 	struct dj_receiver_dev *djrcv_dev;
 	int retval;
+	int kfifo_size_order = order_base_2(DJ_MAX_NUMBER_NOTIFICATIONS *
+					    sizeof(struct dj_report));
 
 	if (is_dj_device((struct dj_device *)hdev->driver_data))
 		return -ENODEV;
@@ -757,9 +760,7 @@ static int logi_dj_probe(struct hid_device *hdev,
 	djrcv_dev->hdev = hdev;
 	INIT_WORK(&djrcv_dev->work, delayedwork_callback);
 	spin_lock_init(&djrcv_dev->lock);
-	if (kfifo_alloc(&djrcv_dev->notif_fifo,
-			DJ_MAX_NUMBER_NOTIFICATIONS * sizeof(struct dj_report),
-			GFP_KERNEL)) {
+	if (kfifo_alloc(&djrcv_dev->notif_fifo, kfifo_size_order, GFP_KERNEL)) {
 		dev_err(&hdev->dev,
 			"%s:failed allocating notif_fifo\n", __func__);
 		kfree(djrcv_dev);
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c
index 261cae0..9b73680 100644
--- a/drivers/iio/industrialio-event.c
+++ b/drivers/iio/industrialio-event.c
@@ -35,7 +35,7 @@
  */
 struct iio_event_interface {
 	wait_queue_head_t	wait;
-	DECLARE_KFIFO(det_events, struct iio_event_data, 16);
+	DECLARE_KFIFO(det_events, struct iio_event_data, 4);
 
 	struct list_head	dev_attr_list;
 	unsigned long		flags;
diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c
index 5bc5c86..d8ba52ff 100644
--- a/drivers/iio/kfifo_buf.c
+++ b/drivers/iio/kfifo_buf.c
@@ -7,6 +7,7 @@
 #include <linux/mutex.h>
 #include <linux/iio/kfifo_buf.h>
 #include <linux/sched.h>
+#include <linux/log2.h>
 
 struct iio_kfifo {
 	struct iio_buffer buffer;
@@ -23,7 +24,7 @@ static inline int __iio_allocate_kfifo(struct iio_kfifo *buf,
 		return -EINVAL;
 
 	__iio_update_buffer(&buf->buffer, bytes_per_datum, length);
-	return __kfifo_alloc((struct __kfifo *)&buf->kf, length,
+	return __kfifo_alloc((struct __kfifo *)&buf->kf, order_base_2(length),
 			     bytes_per_datum, GFP_KERNEL);
 }
 
diff --git a/drivers/infiniband/hw/cxgb3/cxio_resource.c b/drivers/infiniband/hw/cxgb3/cxio_resource.c
index 31f9201..186d05e 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_resource.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_resource.c
@@ -36,6 +36,7 @@
 #include <linux/kfifo.h>
 #include <linux/spinlock.h>
 #include <linux/errno.h>
+#include <linux/log2.h>
 #include "cxio_resource.h"
 #include "cxio_hal.h"
 
@@ -54,8 +55,9 @@ static int __cxio_init_resource_fifo(struct kfifo *fifo,
 	u32 random_bytes;
 	u32 rarray[16];
 	spin_lock_init(fifo_lock);
+	int kfifo_size_order = order_base_2(nr * sizeof(u32));
 
-	if (kfifo_alloc(fifo, nr * sizeof(u32), GFP_KERNEL))
+	if (kfifo_alloc(fifo, kfifo_size_order, GFP_KERNEL))
 		return -ENOMEM;
 
 	for (i = 0; i < skip_low + skip_high; i++)
@@ -111,11 +113,11 @@ static int cxio_init_resource_fifo_random(struct kfifo *fifo,
 static int cxio_init_qpid_fifo(struct cxio_rdev *rdev_p)
 {
 	u32 i;
+	int kfifo_size_order = order_base_2(T3_MAX_NUM_QP * sizeof(u32));
 
 	spin_lock_init(&rdev_p->rscp->qpid_fifo_lock);
 
-	if (kfifo_alloc(&rdev_p->rscp->qpid_fifo, T3_MAX_NUM_QP * sizeof(u32),
-					      GFP_KERNEL))
+	if (kfifo_alloc(&rdev_p->rscp->qpid_fifo, kfifo_size_order, GFP_KERNEL))
 		return -ENOMEM;
 
 	for (i = 16; i < T3_MAX_NUM_QP; i++)
diff --git a/drivers/media/i2c/cx25840/cx25840-ir.c b/drivers/media/i2c/cx25840/cx25840-ir.c
index 38ce76e..1da0b6c 100644
--- a/drivers/media/i2c/cx25840/cx25840-ir.c
+++ b/drivers/media/i2c/cx25840/cx25840-ir.c
@@ -24,6 +24,7 @@
 #include <linux/slab.h>
 #include <linux/kfifo.h>
 #include <linux/module.h>
+#include <linux/log2.h>
 #include <media/cx25840.h>
 #include <media/rc-core.h>
 
@@ -106,8 +107,10 @@ union cx25840_ir_fifo_rec {
 	struct ir_raw_event ir_core_data;
 };
 
-#define CX25840_IR_RX_KFIFO_SIZE    (256 * sizeof(union cx25840_ir_fifo_rec))
-#define CX25840_IR_TX_KFIFO_SIZE    (256 * sizeof(union cx25840_ir_fifo_rec))
+#define CX25840_IR_RX_KFIFO_SIZE_ORDER	(order_base_2(256 * sizeof(union cx25840_ir_fifo_rec)))
+#define CX25840_IR_RX_KFIFO_SIZE    	(1<<CX25840_IR_RX_KFIFO_SIZE_ORDER)
+#define CX25840_IR_TX_KFIFO_SIZE_ORDER	(order_base_2(256 * sizeof(union cx25840_ir_fifo_rec)))
+#define CX25840_IR_TX_KFIFO_SIZE    	(CX25840_IR_TX_KFIFO_SIZE_ORDER)
 
 struct cx25840_ir_state {
 	struct i2c_client *c;
@@ -1236,7 +1239,7 @@ int cx25840_ir_probe(struct v4l2_subdev *sd)
 
 	spin_lock_init(&ir_state->rx_kfifo_lock);
 	if (kfifo_alloc(&ir_state->rx_kfifo,
-			CX25840_IR_RX_KFIFO_SIZE, GFP_KERNEL)) {
+			CX25840_IR_RX_KFIFO_SIZE_ORDER, GFP_KERNEL)) {
 		kfree(ir_state);
 		return -ENOMEM;
 	}
diff --git a/drivers/media/pci/cx23885/cx23888-ir.c b/drivers/media/pci/cx23885/cx23888-ir.c
index c4bd1e9..4c6e24b 100644
--- a/drivers/media/pci/cx23885/cx23888-ir.c
+++ b/drivers/media/pci/cx23885/cx23888-ir.c
@@ -23,6 +23,7 @@
 
 #include <linux/kfifo.h>
 #include <linux/slab.h>
+#include <linux/log2.h>
 
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
@@ -125,8 +126,10 @@ union cx23888_ir_fifo_rec {
 	struct ir_raw_event ir_core_data;
 };
 
-#define CX23888_IR_RX_KFIFO_SIZE    (256 * sizeof(union cx23888_ir_fifo_rec))
-#define CX23888_IR_TX_KFIFO_SIZE    (256 * sizeof(union cx23888_ir_fifo_rec))
+#define CX23888_IR_RX_KFIFO_SIZE_ORDER	(order_base_2(256 * sizeof(union cx23888_ir_fifo_rec)))
+#define CX23888_IR_RX_KFIFO_SIZE    	(1<<CX23888_IR_RX_KFIFO_SIZE_ORDER)
+#define CX23888_IR_TX_KFIFO_SIZE_ORDER	(order_base_2(256 * sizeof(union cx23888_ir_fifo_rec)))
+#define CX23888_IR_TX_KFIFO_SIZE    	(1<<CX23888_IR_TX_KFIFO_SIZE_ORDER)
 
 struct cx23888_ir_state {
 	struct v4l2_subdev sd;
@@ -1213,7 +1216,7 @@ int cx23888_ir_probe(struct cx23885_dev *dev)
 		return -ENOMEM;
 
 	spin_lock_init(&state->rx_kfifo_lock);
-	if (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE, GFP_KERNEL))
+	if (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE_ORDER, GFP_KERNEL))
 		return -ENOMEM;
 
 	state->dev = dev;
diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c
index 049e186..3bcde0c 100644
--- a/drivers/media/pci/meye/meye.c
+++ b/drivers/media/pci/meye/meye.c
@@ -1759,14 +1759,12 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
 	}
 
 	spin_lock_init(&meye.grabq_lock);
-	if (kfifo_alloc(&meye.grabq, sizeof(int) * MEYE_MAX_BUFNBRS,
-				GFP_KERNEL)) {
+	if (kfifo_alloc(&meye.grabq, MEYE_KFIFO_SIZE_ORDER, GFP_KERNEL)) {
 		v4l2_err(v4l2_dev, "fifo allocation failed\n");
 		goto outkfifoalloc1;
 	}
 	spin_lock_init(&meye.doneq_lock);
-	if (kfifo_alloc(&meye.doneq, sizeof(int) * MEYE_MAX_BUFNBRS,
-				GFP_KERNEL)) {
+	if (kfifo_alloc(&meye.doneq, MEYE_KFIFO_SIZE_ORDER, GFP_KERNEL)) {
 		v4l2_err(v4l2_dev, "fifo allocation failed\n");
 		goto outkfifoalloc2;
 	}
diff --git a/drivers/media/pci/meye/meye.h b/drivers/media/pci/meye/meye.h
index 4bdeb03..5d3ab4f 100644
--- a/drivers/media/pci/meye/meye.h
+++ b/drivers/media/pci/meye/meye.h
@@ -260,6 +260,7 @@
 /* private API definitions */
 #include <linux/meye.h>
 #include <linux/mutex.h>
+#include <linux/log2.h>
 
 
 /* Enable jpg software correction */
@@ -270,6 +271,7 @@
 
 /* Maximum number of buffers */
 #define MEYE_MAX_BUFNBRS	32
+#define MEYE_KFIFO_SIZE_ORDER	(order_base_2(MEYE_MAX_BUFNBRS * sizeof(int)))
 
 /* State of a buffer */
 #define MEYE_BUF_UNUSED	0	/* not used */
diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index 97dc8d1..e4d1ec8 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -18,6 +18,7 @@
 #include <linux/kmod.h>
 #include <linux/sched.h>
 #include <linux/freezer.h>
+#include <linux/log2.h>
 #include "rc-core-priv.h"
 
 /* Define the max number of pulse/space transitions to buffer */
@@ -252,6 +253,8 @@ int ir_raw_event_register(struct rc_dev *dev)
 {
 	int rc;
 	struct ir_raw_handler *handler;
+	int kfifo_size_order = order_base_2(sizeof(struct ir_raw_event) *
+					    MAX_IR_EVENT_SIZE);
 
 	if (!dev)
 		return -EINVAL;
@@ -262,9 +265,7 @@ int ir_raw_event_register(struct rc_dev *dev)
 
 	dev->raw->dev = dev;
 	dev->raw->enabled_protocols = ~0;
-	rc = kfifo_alloc(&dev->raw->kfifo,
-			 sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE,
-			 GFP_KERNEL);
+	rc = kfifo_alloc(&dev->raw->kfifo, kfifo_size_order, GFP_KERNEL);
 	if (rc < 0)
 		goto out;
 
diff --git a/drivers/memstick/host/r592.h b/drivers/memstick/host/r592.h
index c5726c1..6fc19f4 100644
--- a/drivers/memstick/host/r592.h
+++ b/drivers/memstick/host/r592.h
@@ -143,7 +143,7 @@ struct r592_device {
 	struct task_struct *io_thread;
 	bool parallel_mode;
 
-	DECLARE_KFIFO(pio_fifo, u8, sizeof(u32));
+	DECLARE_KFIFO(pio_fifo, u8, 2);
 
 	/* DMA area */
 	int dma_capable;
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c
index bd57a11..c54a7c5 100644
--- a/drivers/mmc/card/sdio_uart.c
+++ b/drivers/mmc/card/sdio_uart.c
@@ -43,12 +43,14 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/sdio_ids.h>
+#include <linux/log2.h>
 
 
 #define UART_NR		8	/* Number of UARTs this driver can handle */
 
 
 #define FIFO_SIZE	PAGE_SIZE
+#define FIFO_SIZE_ORDER	PAGE_SHIFT
 #define WAKEUP_CHARS	256
 
 struct uart_icount {
@@ -93,7 +95,7 @@ static int sdio_uart_add_port(struct sdio_uart_port *port)
 
 	mutex_init(&port->func_lock);
 	spin_lock_init(&port->write_lock);
-	if (kfifo_alloc(&port->xmit_fifo, FIFO_SIZE, GFP_KERNEL))
+	if (kfifo_alloc(&port->xmit_fifo, FIFO_SIZE_ORDER, GFP_KERNEL))
 		return -ENOMEM;
 
 	spin_lock(&sdio_uart_table_lock);
diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
index 8dd6ba5..672ef47 100644
--- a/drivers/mtd/sm_ftl.c
+++ b/drivers/mtd/sm_ftl.c
@@ -17,6 +17,7 @@
 #include <linux/bitops.h>
 #include <linux/slab.h>
 #include <linux/mtd/nand_ecc.h>
+#include <linux/log2.h>
 #include "nand/sm_common.h"
 #include "sm_ftl.h"
 
@@ -766,6 +767,7 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num)
 	int lba;
 	int i = 0;
 	int len;
+	int kfifo_size_order;
 
 	dbg("initializing zone %d", zone_num);
 
@@ -778,7 +780,8 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num)
 
 
 	/* Allocate memory for free sectors FIFO */
-	if (kfifo_alloc(&zone->free_sectors, ftl->zone_size * 2, GFP_KERNEL)) {
+	kfifo_size_order = order_base_2(ftl->zone_size * 2);
+	if (kfifo_alloc(&zone->free_sectors, kfifo_size_order, GFP_KERNEL)) {
 		kfree(zone->lba_to_phys_table);
 		return -ENOMEM;
 	}
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 0c02f04..ea5ddf4 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -25,6 +25,8 @@
 #include "cmd.h"
 #include "mesh.h"
 
+#define KFIFO_SIZE_ORDER	6
+
 #define DRIVER_RELEASE_VERSION "323.p0"
 const char lbs_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION
 #ifdef  DEBUG
@@ -914,7 +916,7 @@ static int lbs_init_adapter(struct lbs_private *priv)
 	priv->resp_len[0] = priv->resp_len[1] = 0;
 
 	/* Create the event FIFO */
-	ret = kfifo_alloc(&priv->event_fifo, sizeof(u32) * 16, GFP_KERNEL);
+	ret = kfifo_alloc(&priv->event_fifo, KFIFO_SIZE_ORDER, GFP_KERNEL);
 	if (ret) {
 		pr_err("Out of memory allocating event FIFO buffer\n");
 		goto out;
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 44f8b3f..c8f68485 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -979,12 +979,11 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
 		 * tx_queues * entry_num and round up to the nearest
 		 * power of 2.
 		 */
-		int kfifo_size =
-			roundup_pow_of_two(rt2x00dev->ops->tx_queues *
+		int kfifo_size_order = order_base_2(rt2x00dev->ops->tx_queues *
 					   rt2x00dev->ops->tx->entry_num *
 					   sizeof(u32));
 
-		status = kfifo_alloc(&rt2x00dev->txstatus_fifo, kfifo_size,
+		status = kfifo_alloc(&rt2x00dev->txstatus_fifo, kfifo_size_order,
 				     GFP_KERNEL);
 		if (status)
 			return status;
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index 421bbc5..ec9284a 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -574,7 +574,6 @@ static void handle_error_source(struct pcie_device *aerdev,
 static void aer_recover_work_func(struct work_struct *work);
 
 #define AER_RECOVER_RING_ORDER		4
-#define AER_RECOVER_RING_SIZE		(1 << AER_RECOVER_RING_ORDER)
 
 struct aer_recover_entry
 {
@@ -585,7 +584,7 @@ struct aer_recover_entry
 };
 
 static DEFINE_KFIFO(aer_recover_ring, struct aer_recover_entry,
-		    AER_RECOVER_RING_SIZE);
+		    AER_RECOVER_RING_ORDER);
 /*
  * Mutual exclusion for writers of aer_recover_ring, reader side don't
  * need lock, because there is only one reader and lock is not needed
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index c4c1a54..185bd55 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -66,6 +66,7 @@
 #include <linux/backlight.h>
 #include <linux/input.h>
 #include <linux/kfifo.h>
+#include <linux/log2.h>
 #include <linux/video_output.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
@@ -116,6 +117,7 @@
 
 #define MAX_HOTKEY_RINGBUFFER_SIZE 100
 #define RINGBUFFERSIZE 40
+#define KFIFO_SIZE_ORDER	(order_base_2(RINGBUFFERSIZE * sizeof(int)))
 
 /* Debugging */
 #define FUJLAPTOP_LOG	   ACPI_FUJITSU_HID ": "
@@ -825,8 +827,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
 
 	/* kfifo */
 	spin_lock_init(&fujitsu_hotkey->fifo_lock);
-	error = kfifo_alloc(&fujitsu_hotkey->fifo, RINGBUFFERSIZE * sizeof(int),
-			GFP_KERNEL);
+	error = kfifo_alloc(&fujitsu_hotkey->fifo, KFIFO_SIZE_ORDER, GFP_KERNEL);
 	if (error) {
 		pr_err("kfifo_alloc failed\n");
 		goto err_stop;
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index daaddec..ee57eac 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -183,7 +183,7 @@ static void sony_nc_rfkill_update(void);
 
 /*********** Input Devices ***********/
 
-#define SONY_LAPTOP_BUF_SIZE	128
+#define SONY_LAPTOP_KFIFO_SIZE_ORDER	7
 struct sony_laptop_input_s {
 	atomic_t		users;
 	struct input_dev	*jog_dev;
@@ -447,7 +447,7 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device)
 	/* kfifo */
 	spin_lock_init(&sony_laptop_input.fifo_lock);
 	error = kfifo_alloc(&sony_laptop_input.fifo,
-			    SONY_LAPTOP_BUF_SIZE, GFP_KERNEL);
+			    SONY_LAPTOP_KFIFO_SIZE_ORDER, GFP_KERNEL);
 	if (error) {
 		pr_err("kfifo_alloc failed\n");
 		goto err_dec_users;
@@ -3752,7 +3752,7 @@ static int sonypi_compat_init(void)
 
 	spin_lock_init(&sonypi_compat.fifo_lock);
 	error =
-	 kfifo_alloc(&sonypi_compat.fifo, SONY_LAPTOP_BUF_SIZE, GFP_KERNEL);
+	 kfifo_alloc(&sonypi_compat.fifo, SONY_LAPTOP_KFIFO_SIZE_ORDER, GFP_KERNEL);
 	if (error) {
 		pr_err("kfifo_alloc failed\n");
 		return error;
diff --git a/drivers/rapidio/devices/tsi721.c b/drivers/rapidio/devices/tsi721.c
index 6faba40..a731e87 100644
--- a/drivers/rapidio/devices/tsi721.c
+++ b/drivers/rapidio/devices/tsi721.c
@@ -32,6 +32,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/interrupt.h>
 #include <linux/kfifo.h>
+#include <linux/log2.h>
 #include <linux/delay.h>
 
 #include "tsi721.h"
@@ -970,11 +971,11 @@ static void tsi721_init_sr2pc_mapping(struct tsi721_device *priv)
  */
 static int tsi721_port_write_init(struct tsi721_device *priv)
 {
+	int kfifo_size_order = order_base_2(TSI721_RIO_PW_MSG_SIZE * 32);
 	priv->pw_discard_count = 0;
 	INIT_WORK(&priv->pw_work, tsi721_pw_dpc);
 	spin_lock_init(&priv->pw_fifo_lock);
-	if (kfifo_alloc(&priv->pw_fifo,
-			TSI721_RIO_PW_MSG_SIZE * 32, GFP_KERNEL)) {
+	if (kfifo_alloc(&priv->pw_fifo, kfifo_size_order, GFP_KERNEL)) {
 		dev_err(&priv->pdev->dev, "PW FIFO allocation failed\n");
 		return -ENOMEM;
 	}
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index 552e8a2..bdb09bf 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -35,6 +35,7 @@
 #include <linux/crypto.h>
 #include <linux/delay.h>
 #include <linux/kfifo.h>
+#include <linux/log2.h>
 #include <linux/scatterlist.h>
 #include <linux/module.h>
 #include <net/tcp.h>
@@ -1113,6 +1114,7 @@ int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session)
 {
 	int i;
 	int cmd_i;
+	int kfifo_size_order;
 
 	/*
 	 * initialize per-task: R2T pool and xmit queue
@@ -1135,8 +1137,8 @@ int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session)
 		}
 
 		/* R2T xmit queue */
-		if (kfifo_alloc(&tcp_task->r2tqueue,
-		      session->max_r2t * 4 * sizeof(void*), GFP_KERNEL)) {
+		kfifo_size_order = order_base_2(session->max_r2t * 4 * sizeof(void *));
+		if (kfifo_alloc(&tcp_task->r2tqueue, kfifo_size_order, GFP_KERNEL)) {
 			iscsi_pool_free(&tcp_task->r2tpool);
 			goto r2t_alloc_fail;
 		}
diff --git a/drivers/staging/omapdrm/omap_plane.c b/drivers/staging/omapdrm/omap_plane.c
index 2a8e5ba..40f057f 100644
--- a/drivers/staging/omapdrm/omap_plane.c
+++ b/drivers/staging/omapdrm/omap_plane.c
@@ -28,6 +28,8 @@
  */
 #define omap_plane _omap_plane
 
+#define OMAP_KFIFO_SIZE_ORDER	4
+
 /*
  * plane funcs
  */
@@ -508,7 +510,8 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
 
 	mutex_init(&omap_plane->unpin_mutex);
 
-	ret = kfifo_alloc(&omap_plane->unpin_fifo, 16, GFP_KERNEL);
+	ret = kfifo_alloc(&omap_plane->unpin_fifo, OMAP_KFIFO_SIZE_ORDER,
+			  GFP_KERNEL);
 	if (ret) {
 		dev_err(dev->dev, "could not allocate unpin FIFO\n");
 		goto fail;
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index dcc0430..b3b1b1c 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -66,6 +66,8 @@
 static int debug;
 module_param(debug, int, 0600);
 
+#define KFIFO_SIZE_ORDER	12
+
 /* Defaults: these are from the specification */
 
 #define T1	10		/* 100mS */
@@ -1636,7 +1638,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
 	spin_lock_init(&dlci->lock);
 	mutex_init(&dlci->mutex);
 	dlci->fifo = &dlci->_fifo;
-	if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
+	if (kfifo_alloc(&dlci->_fifo, KFIFO_SIZE_ORDER, GFP_KERNEL) < 0) {
 		kfree(dlci);
 		return NULL;
 	}
diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index a0c69ab..8b54da3 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -128,8 +128,7 @@ static int debug;
 #define NTTY_TTY_MAXMINORS	256
 #define NTTY_FIFO_BUFFER_SIZE	8192
 
-/* Must be power of 2 */
-#define FIFO_BUFFER_SIZE_UL	8192
+#define FIFO_BUFFER_SIZE_ORDER	13
 
 /* Size of tmp send buffer to card */
 #define SEND_BUF_MAX		1024
@@ -1428,7 +1427,7 @@ static int nozomi_card_init(struct pci_dev *pdev,
 	}
 
 	for (i = PORT_MDM; i < MAX_PORT; i++) {
-		if (kfifo_alloc(&dc->port[i].fifo_ul, FIFO_BUFFER_SIZE_UL,
+		if (kfifo_alloc(&dc->port[i].fifo_ul, FIFO_BUFFER_SIZE_ORDER,
 					GFP_KERNEL)) {
 			dev_err(&pdev->dev,
 					"Could not allocate kfifo buffer\n");
diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c
index 675d94a..f80dc2c 100644
--- a/drivers/tty/serial/ifx6x60.c
+++ b/drivers/tty/serial/ifx6x60.c
@@ -880,7 +880,7 @@ static int ifx_spi_create_port(struct ifx_spi_device *ifx_dev)
 	lockdep_set_class_and_subclass(&ifx_dev->fifo_lock,
 		&ifx_spi_key, 0);
 
-	if (kfifo_alloc(&ifx_dev->tx_fifo, IFX_SPI_FIFO_SIZE, GFP_KERNEL)) {
+	if (kfifo_alloc(&ifx_dev->tx_fifo, IFX_SPI_FIFO_SIZE_ORDER, GFP_KERNEL)) {
 		ret = -ENOMEM;
 		goto error_ret;
 	}
diff --git a/drivers/tty/serial/ifx6x60.h b/drivers/tty/serial/ifx6x60.h
index 4fbddc2..da4fd1c 100644
--- a/drivers/tty/serial/ifx6x60.h
+++ b/drivers/tty/serial/ifx6x60.h
@@ -31,7 +31,8 @@
 
 #define IFX_SPI_MAX_MINORS		1
 #define IFX_SPI_TRANSFER_SIZE		2048
-#define IFX_SPI_FIFO_SIZE		4096
+#define IFX_SPI_FIFO_SIZE_ORDER		12
+#define IFX_SPI_FIFO_SIZE		(1 << IFX_SPI_FIFO_SIZE_ORDER)
 
 #define IFX_SPI_HEADER_OVERHEAD		4
 #define IFX_RESET_TIMEOUT		msecs_to_jiffies(50)
diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
index 6ac2b79..947dd72 100644
--- a/drivers/tty/serial/kgdb_nmi.c
+++ b/drivers/tty/serial/kgdb_nmi.c
@@ -26,6 +26,7 @@
 #include <linux/interrupt.h>
 #include <linux/hrtimer.h>
 #include <linux/tick.h>
+#include <linux/log2.h>
 #include <linux/kfifo.h>
 #include <linux/kgdb.h>
 #include <linux/kdb.h>
@@ -75,13 +76,13 @@ static struct console kgdb_nmi_console = {
  * This is usually the maximum rate on debug ports. We make fifo large enough
  * to make copy-pasting to the terminal usable.
  */
-#define KGDB_NMI_BAUD		115200
-#define KGDB_NMI_FIFO_SIZE	roundup_pow_of_two(KGDB_NMI_BAUD / 8 / HZ)
+#define KGDB_NMI_BAUD			115200
+#define KGDB_NMI_FIFO_SIZE_ORDER	order_base_2(KGDB_NMI_BAUD / 8 / HZ)
 
 struct kgdb_nmi_tty_priv {
 	struct tty_port port;
 	struct tasklet_struct tlet;
-	STRUCT_KFIFO(char, KGDB_NMI_FIFO_SIZE) fifo;
+	STRUCT_KFIFO(char, KGDB_NMI_FIFO_SIZE_ORDER) fifo;
 };
 
 static struct kgdb_nmi_tty_priv *kgdb_nmi_port_to_priv(struct tty_port *port)
diff --git a/drivers/usb/host/fhci.h b/drivers/usb/host/fhci.h
index 7cc1c32..e4a0ac6 100644
--- a/drivers/usb/host/fhci.h
+++ b/drivers/usb/host/fhci.h
@@ -24,6 +24,7 @@
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/kfifo.h>
+#include <linux/log2.h>
 #include <linux/io.h>
 #include <linux/usb.h>
 #include <linux/usb/hcd.h>
@@ -478,7 +479,8 @@ static inline struct usb_hcd *fhci_to_hcd(struct fhci_hcd *fhci)
 /* fifo of pointers */
 static inline int cq_new(struct kfifo *fifo, int size)
 {
-	return kfifo_alloc(fifo, size * sizeof(void *), GFP_KERNEL);
+	int kfifo_size_order = order_base_2(size * sizeof(void *));
+	return kfifo_alloc(fifo, kfifo_size_order, GFP_KERNEL);
 }
 
 static inline void cq_delete(struct kfifo *kfifo)
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index fd8c35f..a4d7cd1 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -54,7 +54,7 @@ static bool unstable_bauds;
 #define DRIVER_DESC "Cypress USB to Serial Driver"
 
 /* write buffer size defines */
-#define CYPRESS_BUF_SIZE	1024
+#define CYPRESS_KFIFO_SIZE_ORDER	10
 
 static const struct usb_device_id id_table_earthmate[] = {
 	{ USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
@@ -445,7 +445,7 @@ static int cypress_generic_port_probe(struct usb_serial_port *port)
 
 	priv->comm_is_ok = !0;
 	spin_lock_init(&priv->lock);
-	if (kfifo_alloc(&priv->write_fifo, CYPRESS_BUF_SIZE, GFP_KERNEL)) {
+	if (kfifo_alloc(&priv->write_fifo, CYPRESS_KFIFO_SIZE_ORDER, GFP_KERNEL)) {
 		kfree(priv);
 		return -ENOMEM;
 	}
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 58184f3..a19018b 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -64,7 +64,7 @@
 
 #define EDGE_CLOSING_WAIT	4000	/* in .01 sec */
 
-#define EDGE_OUT_BUF_SIZE	1024
+#define EDGE_KFIFO_SIZE_ORDER	10
 
 
 /* Product information read from the Edgeport */
@@ -2567,7 +2567,7 @@ static int edge_port_probe(struct usb_serial_port *port)
 	if (!edge_port)
 		return -ENOMEM;
 
-	ret = kfifo_alloc(&edge_port->write_fifo, EDGE_OUT_BUF_SIZE,
+	ret = kfifo_alloc(&edge_port->write_fifo, EDGE_KFIFO_SIZE_ORDER,
 								GFP_KERNEL);
 	if (ret) {
 		kfree(edge_port);
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index f2530d2..777e90a 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -45,7 +45,8 @@
 
 #define TI_FIRMWARE_BUF_SIZE	16284
 
-#define TI_WRITE_BUF_SIZE	1024
+#define TI_KFIFO_SIZE_ORDER	10
+#define TI_KFIFO_SIZE		(1 << TI_KFIFO_SIZE_ORDER)
 
 #define TI_TRANSFER_TIMEOUT	2
 
@@ -434,7 +435,7 @@ static int ti_port_probe(struct usb_serial_port *port)
 	tport->tp_closing_wait = closing_wait;
 	init_waitqueue_head(&tport->tp_msr_wait);
 	init_waitqueue_head(&tport->tp_write_wait);
-	if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE, GFP_KERNEL)) {
+	if (kfifo_alloc(&tport->write_fifo, TI_KFIFO_SIZE_ORDER, GFP_KERNEL)) {
 		kfree(tport);
 		return -ENOMEM;
 	}
@@ -1355,7 +1356,7 @@ static int ti_get_serial_info(struct ti_port *tport,
 	ret_serial.line = port->serial->minor;
 	ret_serial.port = port->number - port->serial->minor;
 	ret_serial.flags = tport->tp_flags;
-	ret_serial.xmit_fifo_size = TI_WRITE_BUF_SIZE;
+	ret_serial.xmit_fifo_size = TI_KFIFO_SIZE;
 	ret_serial.baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800;
 	ret_serial.closing_wait = tport->tp_closing_wait;
 
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 64bda13..11ca271 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -934,7 +934,7 @@ static int usb_serial_probe(struct usb_interface *interface,
 	for (i = 0; i < num_bulk_out; ++i) {
 		endpoint = bulk_out_endpoint[i];
 		port = serial->port[i];
-		if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL))
+		if (kfifo_alloc(&port->write_fifo, PAGE_SHIFT, GFP_KERNEL))
 			goto probe_error;
 		buffer_size = serial->type->bulk_out_size;
 		if (!buffer_size)
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 4bf984e..28dfe98 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -76,8 +76,8 @@ struct __kfifo {
 	type		buf[((size < 2) || (size & (size - 1))) ? -1 : size]; \
 }
 
-#define STRUCT_KFIFO(type, size) \
-	struct __STRUCT_KFIFO(type, size, 0)
+#define STRUCT_KFIFO(type, size_order) \
+	struct __STRUCT_KFIFO(type, (1<<(size_order)), 0)
 
 #define __STRUCT_KFIFO_PTR(type, recsize) \
 { \
@@ -93,11 +93,11 @@ struct __kfifo {
  */
 struct kfifo __STRUCT_KFIFO_PTR(unsigned char, 0);
 
-#define STRUCT_KFIFO_REC_1(size) \
-	struct __STRUCT_KFIFO(unsigned char, size, 1)
+#define STRUCT_KFIFO_REC_1(size_order) \
+	struct __STRUCT_KFIFO(unsigned char, (1<<(size_order)), 1)
 
-#define STRUCT_KFIFO_REC_2(size) \
-	struct __STRUCT_KFIFO(unsigned char, size, 2)
+#define STRUCT_KFIFO_REC_2(size_order) \
+	struct __STRUCT_KFIFO(unsigned char, (1<<(size_order)), 2)
 
 /*
  * define kfifo_rec types
@@ -123,9 +123,9 @@ struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2);
  * DECLARE_KFIFO - macro to declare a fifo object
  * @fifo: name of the declared fifo
  * @type: type of the fifo elements
- * @size: the number of elements in the fifo, this must be a power of 2
+ * @size_order: request 2^size_order fifo elements
  */
-#define DECLARE_KFIFO(fifo, type, size)	STRUCT_KFIFO(type, size) fifo
+#define DECLARE_KFIFO(fifo, type, size_order)	STRUCT_KFIFO(type, size_order) fifo
 
 /**
  * INIT_KFIFO - Initialize a fifo declared by DECLARE_KFIFO
@@ -146,12 +146,12 @@ struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2);
  * DEFINE_KFIFO - macro to define and initialize a fifo
  * @fifo: name of the declared fifo datatype
  * @type: type of the fifo elements
- * @size: the number of elements in the fifo, this must be a power of 2
+ * @size_order: request 2^size_order fifo elements
  *
  * Note: the macro can be used for global and local fifo data type variables.
  */
-#define DEFINE_KFIFO(fifo, type, size) \
-	DECLARE_KFIFO(fifo, type, size) = \
+#define DEFINE_KFIFO(fifo, type, size_order) \
+	DECLARE_KFIFO(fifo, type, size_order) = \
 	(typeof(fifo)) { \
 		{ \
 			{ \
@@ -317,22 +317,21 @@ __kfifo_uint_must_check_helper( \
 /**
  * kfifo_alloc - dynamically allocates a new fifo buffer
  * @fifo: pointer to the fifo
- * @size: the number of elements in the fifo, this must be a power of 2
+ * @size_order: request 2^size_order fifo elements
  * @gfp_mask: get_free_pages mask, passed to kmalloc()
  *
  * This macro dynamically allocates a new fifo buffer.
  *
- * The numer of elements will be rounded-up to a power of 2.
  * The fifo will be release with kfifo_free().
  * Return 0 if no error, otherwise an error code.
  */
-#define kfifo_alloc(fifo, size, gfp_mask) \
+#define kfifo_alloc(fifo, size_order, gfp_mask) \
 __kfifo_int_must_check_helper( \
 ({ \
 	typeof((fifo) + 1) __tmp = (fifo); \
 	struct __kfifo *__kfifo = &__tmp->kfifo; \
 	__is_kfifo_ptr(__tmp) ? \
-	__kfifo_alloc(__kfifo, size, sizeof(*__tmp->type), gfp_mask) : \
+	__kfifo_alloc(__kfifo, size_order, sizeof(*__tmp->type), gfp_mask) : \
 	-EINVAL; \
 }) \
 )
@@ -745,7 +744,7 @@ __kfifo_uint_must_check_helper( \
 }) \
 )
 
-extern int __kfifo_alloc(struct __kfifo *fifo, unsigned int size,
+extern int __kfifo_alloc(struct __kfifo *fifo, int size_order,
 	size_t esize, gfp_t gfp_mask);
 
 extern void __kfifo_free(struct __kfifo *fifo);
diff --git a/include/linux/rio.h b/include/linux/rio.h
index a3e7842..05ff6bb 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -70,6 +70,7 @@
 #define RIO_OUTB_MBOX_RESOURCE	2
 
 #define RIO_PW_MSG_SIZE		64
+#define RIO_KFIFO_SIZE_ORDER	11	/* 64 * 32 */
 
 /*
  * A component tag value (stored in the component tag CSR) is used as device's
diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h
index 168dd0b..7816d39 100644
--- a/include/media/lirc_dev.h
+++ b/include/media/lirc_dev.h
@@ -19,6 +19,7 @@
 #include <linux/ioctl.h>
 #include <linux/poll.h>
 #include <linux/kfifo.h>
+#include <linux/log2.h>
 #include <media/lirc.h>
 
 struct lirc_buffer {
@@ -50,12 +51,13 @@ static inline int lirc_buffer_init(struct lirc_buffer *buf,
 				    unsigned int size)
 {
 	int ret;
+	int kfifo_size_order = order_base_2(size * chunk_size);
 
 	init_waitqueue_head(&buf->wait_poll);
 	spin_lock_init(&buf->fifo_lock);
 	buf->chunk_size = chunk_size;
 	buf->size = size;
-	ret = kfifo_alloc(&buf->fifo, size * chunk_size, GFP_KERNEL);
+	ret = kfifo_alloc(&buf->fifo, kfifo_size_order, GFP_KERNEL);
 	if (ret == 0)
 		buf->fifo_initialized = 1;
 
diff --git a/kernel/kfifo.c b/kernel/kfifo.c
index d07f480..be1c2a0 100644
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -35,15 +35,10 @@ static inline unsigned int kfifo_unused(struct __kfifo *fifo)
 	return (fifo->mask + 1) - (fifo->in - fifo->out);
 }
 
-int __kfifo_alloc(struct __kfifo *fifo, unsigned int size,
+int __kfifo_alloc(struct __kfifo *fifo, int size_order,
 		size_t esize, gfp_t gfp_mask)
 {
-	/*
-	 * round down to the next power of 2, since our 'let the indices
-	 * wrap' technique works only in this case.
-	 */
-	if (!is_power_of_2(size))
-		size = rounddown_pow_of_two(size);
+	unsigned int size = 1 << size_order;
 
 	fifo->in = 0;
 	fifo->out = 0;
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index c6e4dd3..827bbf3 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1189,7 +1189,6 @@ out:
 EXPORT_SYMBOL_GPL(memory_failure);
 
 #define MEMORY_FAILURE_FIFO_ORDER	4
-#define MEMORY_FAILURE_FIFO_SIZE	(1 << MEMORY_FAILURE_FIFO_ORDER)
 
 struct memory_failure_entry {
 	unsigned long pfn;
@@ -1199,7 +1198,7 @@ struct memory_failure_entry {
 
 struct memory_failure_cpu {
 	DECLARE_KFIFO(fifo, struct memory_failure_entry,
-		      MEMORY_FAILURE_FIFO_SIZE);
+		      MEMORY_FAILURE_FIFO_ORDER);
 	spinlock_t lock;
 	struct work_struct work;
 };
diff --git a/net/dccp/probe.c b/net/dccp/probe.c
index 0a8d6eb..0a12fd5 100644
--- a/net/dccp/probe.c
+++ b/net/dccp/probe.c
@@ -31,6 +31,7 @@
 #include <linux/kfifo.h>
 #include <linux/vmalloc.h>
 #include <linux/gfp.h>
+#include <linux/log2.h>
 #include <net/net_namespace.h>
 
 #include "dccp.h"
@@ -166,10 +167,11 @@ static __init int setup_jprobe(void)
 static __init int dccpprobe_init(void)
 {
 	int ret = -ENOMEM;
+	int kfifo_size_order = order_base_2(bufsize);
 
 	init_waitqueue_head(&dccpw.wait);
 	spin_lock_init(&dccpw.lock);
-	if (kfifo_alloc(&dccpw.fifo, bufsize, GFP_KERNEL))
+	if (kfifo_alloc(&dccpw.fifo, kfifo_size_order, GFP_KERNEL))
 		return ret;
 	if (!proc_net_fops_create(&init_net, procname, S_IRUSR, &dccpprobe_fops))
 		goto err0;
@@ -200,7 +202,7 @@ module_exit(dccpprobe_exit);
 MODULE_PARM_DESC(port, "Port to match (0=all)");
 module_param(port, int, 0);
 
-MODULE_PARM_DESC(bufsize, "Log buffer size (default 64k)");
+MODULE_PARM_DESC(bufsize, "Log buffer size (default 64k , should be power of 2. If not, will roundup to power of 2)");
 module_param(bufsize, int, 0);
 
 MODULE_AUTHOR("Ian McDonald <ian.mcdonald-WpNOhQBWTy6lP80pJB477g@public.gmane.org>");
diff --git a/net/sctp/probe.c b/net/sctp/probe.c
index 5f7518d..1736ef4 100644
--- a/net/sctp/probe.c
+++ b/net/sctp/probe.c
@@ -33,6 +33,7 @@
 #include <linux/module.h>
 #include <linux/kfifo.h>
 #include <linux/time.h>
+#include <linux/log2.h>
 #include <net/net_namespace.h>
 
 #include <net/sctp/sctp.h>
@@ -47,7 +48,7 @@ MODULE_PARM_DESC(port, "Port to match (0=all)");
 module_param(port, int, 0);
 
 static int bufsize __read_mostly = 64 * 1024;
-MODULE_PARM_DESC(bufsize, "Log buffer size (default 64k)");
+MODULE_PARM_DESC(bufsize, "Log buffer size (default 64k, should be power of 2. If not, will roundup to power of 2)");
 module_param(bufsize, int, 0);
 
 static int full __read_mostly = 1;
@@ -182,10 +183,11 @@ static struct jprobe sctp_recv_probe = {
 static __init int sctpprobe_init(void)
 {
 	int ret = -ENOMEM;
+	int kfifo_size_order = order_base_2(bufsize);
 
 	init_waitqueue_head(&sctpw.wait);
 	spin_lock_init(&sctpw.lock);
-	if (kfifo_alloc(&sctpw.fifo, bufsize, GFP_KERNEL))
+	if (kfifo_alloc(&sctpw.fifo, kfifo_size_order, GFP_KERNEL))
 		return ret;
 
 	if (!proc_net_fops_create(&init_net, procname, S_IRUSR,
diff --git a/samples/kfifo/bytestream-example.c b/samples/kfifo/bytestream-example.c
index cfe40ad..eb3a46e 100644
--- a/samples/kfifo/bytestream-example.c
+++ b/samples/kfifo/bytestream-example.c
@@ -18,7 +18,7 @@
  */
 
 /* fifo size in elements (bytes) */
-#define FIFO_SIZE	32
+#define FIFO_SIZE_ORDER	5
 
 /* name of the proc entry */
 #define	PROC_FIFO	"bytestream-fifo"
@@ -41,10 +41,10 @@ static DEFINE_MUTEX(write_lock);
 #ifdef DYNAMIC
 static struct kfifo test;
 #else
-static DECLARE_KFIFO(test, unsigned char, FIFO_SIZE);
+static DECLARE_KFIFO(test, unsigned char, FIFO_SIZE_ORDER);
 #endif
 
-static const unsigned char expected_result[FIFO_SIZE] = {
+static const unsigned char expected_result[1<<FIFO_SIZE_ORDER] = {
 	 3,  4,  5,  6,  7,  8,  9,  0,
 	 1, 20, 21, 22, 23, 24, 25, 26,
 	27, 28, 29, 30, 31, 32, 33, 34,
@@ -156,7 +156,7 @@ static int __init example_init(void)
 #ifdef DYNAMIC
 	int ret;
 
-	ret = kfifo_alloc(&test, FIFO_SIZE, GFP_KERNEL);
+	ret = kfifo_alloc(&test, FIFO_SIZE_ORDER, GFP_KERNEL);
 	if (ret) {
 		printk(KERN_ERR "error kfifo_alloc\n");
 		return ret;
diff --git a/samples/kfifo/dma-example.c b/samples/kfifo/dma-example.c
index 0647379..bbc0787 100644
--- a/samples/kfifo/dma-example.c
+++ b/samples/kfifo/dma-example.c
@@ -16,7 +16,8 @@
  */
 
 /* fifo size in elements (bytes) */
-#define FIFO_SIZE	32
+#define FIFO_SIZE_ORDER	5
+#define FIFO_SIZE	(1<< FIFO_SIZE_ORDER)
 
 static struct kfifo fifo;
 
@@ -29,7 +30,7 @@ static int __init example_init(void)
 
 	printk(KERN_INFO "DMA fifo test start\n");
 
-	if (kfifo_alloc(&fifo, FIFO_SIZE, GFP_KERNEL)) {
+	if (kfifo_alloc(&fifo, FIFO_SIZE_ORDER, GFP_KERNEL)) {
 		printk(KERN_WARNING "error kfifo_alloc\n");
 		return -ENOMEM;
 	}
diff --git a/samples/kfifo/inttype-example.c b/samples/kfifo/inttype-example.c
index 6f8e79e..bed3229 100644
--- a/samples/kfifo/inttype-example.c
+++ b/samples/kfifo/inttype-example.c
@@ -18,7 +18,8 @@
  */
 
 /* fifo size in elements (ints) */
-#define FIFO_SIZE	32
+#define FIFO_SIZE_ORDER	5
+#define FIFO_SIZE	(1<< FIFO_SIZE_ORDER)
 
 /* name of the proc entry */
 #define	PROC_FIFO	"int-fifo"
@@ -41,7 +42,7 @@ static DEFINE_MUTEX(write_lock);
 #ifdef DYNAMIC
 static DECLARE_KFIFO_PTR(test, int);
 #else
-static DEFINE_KFIFO(test, int, FIFO_SIZE);
+static DEFINE_KFIFO(test, int, FIFO_SIZE_ORDER);
 #endif
 
 static const int expected_result[FIFO_SIZE] = {
@@ -149,7 +150,7 @@ static int __init example_init(void)
 #ifdef DYNAMIC
 	int ret;
 
-	ret = kfifo_alloc(&test, FIFO_SIZE, GFP_KERNEL);
+	ret = kfifo_alloc(&test, FIFO_SIZE_ORDER, GFP_KERNEL);
 	if (ret) {
 		printk(KERN_ERR "error kfifo_alloc\n");
 		return ret;
diff --git a/samples/kfifo/record-example.c b/samples/kfifo/record-example.c
index 2d7529e..2902eae 100644
--- a/samples/kfifo/record-example.c
+++ b/samples/kfifo/record-example.c
@@ -18,7 +18,7 @@
  */
 
 /* fifo size in elements (bytes) */
-#define FIFO_SIZE	128
+#define FIFO_SIZE_ORDER	7
 
 /* name of the proc entry */
 #define	PROC_FIFO	"record-fifo"
@@ -50,7 +50,7 @@ static DEFINE_MUTEX(write_lock);
 struct kfifo_rec_ptr_1 test;
 
 #else
-typedef STRUCT_KFIFO_REC_1(FIFO_SIZE) mytest;
+typedef STRUCT_KFIFO_REC_1(FIFO_SIZE_ORDER) mytest;
 
 static mytest test;
 #endif
@@ -163,7 +163,7 @@ static int __init example_init(void)
 #ifdef DYNAMIC
 	int ret;
 
-	ret = kfifo_alloc(&test, FIFO_SIZE, GFP_KERNEL);
+	ret = kfifo_alloc(&test, FIFO_SIZE_ORDER, GFP_KERNEL);
 	if (ret) {
 		printk(KERN_ERR "error kfifo_alloc\n");
 		return ret;
-- 
1.7.7.6

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply related

* RE: [patch] bnx2x: NULL dereference on error in debug code
From: Ariel Elior @ 2013-01-08 14:54 UTC (permalink / raw)
  To: Dan Carpenter, Eilon Greenstein
  Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
In-Reply-To: <20130108134213.GA23742@elgon.mountain>

> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-
> owner@vger.kernel.org] On Behalf Of Dan Carpenter
> Sent: Tuesday, January 08, 2013 3:42 PM
> To: Eilon Greenstein
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; kernel-
> janitors@vger.kernel.org
> Subject: [patch] bnx2x: NULL dereference on error in debug code
> 
> "vfop" is NULL here.  I've changed the debugging to not use it.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Only needed in linux-next.
> 
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
> b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
> index 71fcef0..3eef972 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
> @@ -463,8 +463,7 @@ static int bnx2x_vfop_qdtor_cmd(struct bnx2x *bp,
>  		return bnx2x_vfop_transition(bp, vf, bnx2x_vfop_qdtor,
>  					     cmd->block);
>  	}
> -	DP(BNX2X_MSG_IOV, "VF[%d] failed to add a vfop. rc %d\n",
> -	   vf->abs_vfid, vfop->rc);
> +	DP(BNX2X_MSG_IOV, "VF[%d] failed to add a vfop.\n", vf->abs_vfid);
>  	return -ENOMEM;
>  }
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

And now acking it properly.
Acked-by Ariel Elior <ariele@broadcom.com>

^ permalink raw reply

* RE: [patch] bnx2x: NULL dereference on error in debug code
From: Ariel Elior @ 2013-01-08 14:50 UTC (permalink / raw)
  To: Dan Carpenter, Eilon Greenstein
  Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
In-Reply-To: <20130108134213.GA23742@elgon.mountain>

> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-
> owner@vger.kernel.org] On Behalf Of Dan Carpenter
> Sent: Tuesday, January 08, 2013 3:42 PM
> To: Eilon Greenstein
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; kernel-
> janitors@vger.kernel.org
> Subject: [patch] bnx2x: NULL dereference on error in debug code
> 
> "vfop" is NULL here.  I've changed the debugging to not use it.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Only needed in linux-next.
> 
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
> b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
> index 71fcef0..3eef972 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
> @@ -463,8 +463,7 @@ static int bnx2x_vfop_qdtor_cmd(struct bnx2x *bp,
>  		return bnx2x_vfop_transition(bp, vf, bnx2x_vfop_qdtor,
>  					     cmd->block);
>  	}
> -	DP(BNX2X_MSG_IOV, "VF[%d] failed to add a vfop. rc %d\n",
> -	   vf->abs_vfid, vfop->rc);
> +	DP(BNX2X_MSG_IOV, "VF[%d] failed to add a vfop.\n", vf->abs_vfid);
>  	return -ENOMEM;
>  }
> 
Right you are. Ack.
Thanks Dan,
Ariel

^ permalink raw reply

* Re: [PATCH] sunrpc: verbs: Avoid 1kb stack
From: J. Bruce Fields @ 2013-01-08 14:46 UTC (permalink / raw)
  To: Joe Perches
  Cc: Trond Myklebust, David S. Miller,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Tom Tucker,
	steved-H+wXaHxf7aLQT0dZR+AlfA, Tom Talpey
In-Reply-To: <1357587696.21481.48.camel@joe-AO722>

On Mon, Jan 07, 2013 at 11:41:36AM -0800, Joe Perches wrote:
> 16 * 64 is a bit much.
> Use kmalloc_array instead.

I thought there was some reason we didn't do this.

Grepping up through the callers....  It looks like the result is
xprt_rdma_send_request returns -EIO, and as far as I can tell that gets
passed up to the application on the client.   That doesn't sound right.

--b.

> 
> Signed-off-by: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
> ---
>  net/sunrpc/xprtrdma/verbs.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
> index 745973b..9cfebb4 100644
> --- a/net/sunrpc/xprtrdma/verbs.c
> +++ b/net/sunrpc/xprtrdma/verbs.c
> @@ -1736,8 +1736,13 @@ rpcrdma_register_default_external(struct rpcrdma_mr_seg *seg,
>  	int mem_priv = (writing ? IB_ACCESS_REMOTE_WRITE :
>  				  IB_ACCESS_REMOTE_READ);
>  	struct rpcrdma_mr_seg *seg1 = seg;
> -	struct ib_phys_buf ipb[RPCRDMA_MAX_DATA_SEGS];
>  	int len, i, rc = 0;
> +	struct ib_phys_buf *ipb = kmalloc_array(RPCRDMA_MAX_DATA_SEGS,
> +						sizeof(*ipb),
> +						GFP_KERNEL);
> +
> +	if (!ipb)
> +		return -ENOMEM;
>  
>  	if (*nsegs > RPCRDMA_MAX_DATA_SEGS)
>  		*nsegs = RPCRDMA_MAX_DATA_SEGS;
> @@ -1770,6 +1775,9 @@ rpcrdma_register_default_external(struct rpcrdma_mr_seg *seg,
>  		seg1->mr_len = len;
>  	}
>  	*nsegs = i;
> +
> +	kfree(ipb);
> +
>  	return rc;
>  }
>  
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* IPV4 TCP connection reset using iperf
From: Madhvapathi Sriram @ 2013-01-08 14:41 UTC (permalink / raw)
  To: netdev

Hi,

I have recently migrated to kernel version 3.6.10 from 3.2.1. I was
running iperf to routinely measure TCP throughput and I have been
facing problems eversince. I am using a wireless interface.

wireless client: iperf -s -i 1 -w 1024K
wireless server: iperf -c 192.168.1.1 -i -1 -w 1024 -t 600

While, the connection is maintained for sometime and the perf logs
keep going. Randomly, the connection breaks with the server side
resetting the connection. The tcp dump on the client shows RST sent by
the server. Switching back to 3.2.1 works. This issue starts from
kernel version 3.5 onnwards.

I have tried to probe along some points to take a look at the air
logs, tcpdump on either sides but to no clue - everything seems normal
like, the tcp window values, very less/negligible retransmissions and
so on. The RST is set abruptly and randomly (no definite time - may
happen randomly).

I am looking for some suggestions or pointers towards analyzing the issue.

Thanks and regards,
Madhvapathi Sriram

^ permalink raw reply

* Re: [RFC PATCH V2] tcp: introduce raw access to experimental options
From: Einar Lueck @ 2013-01-08 14:36 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, davem, ubacher, raspl, frankbla, samudrala
In-Reply-To: <1357577051.6919.3171.camel@edumazet-glaptop>

On 01/07/2013 05:44 PM, Eric Dumazet wrote:
>
> Thats a big addition, and for example doesn't help if the SYNACK should
> include an option that is depending on the content of SYN message.
>
> For TCP fastopen for example, the cookie we send to the client is not a
> constant cookie.
>
> Also TCP coalescing of TCP collapse will merge several skbs, so storing
> "the last received options" in the socket is kind of not well defined
> semantic.
>
> It looks like you need to add hooks and kernel modules to fully use
> experimental options, like congestion control modules.
>
>
Thanks for the fast feedback, Eric. Let me try to make sure that I
understand your suggestions correctly:
You suggest to have a set of hooks that allow to move all code that
exploits experimental options into dedicated modules (e.g. one module
for TCP fastopen and one for cookies). Extensibility then comes on
a per module granularity. Is my understanding correct?

Thx,
Einar.

^ permalink raw reply

* Re: [PATCH net-next] net: introduce skb_transport_header_was_set()
From: Jamal Hadi Salim @ 2013-01-08 14:05 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev
In-Reply-To: <1357586901.6919.3551.camel@edumazet-glaptop>

On 13-01-07 02:28 PM, Eric Dumazet wrote:

> Note that network stacks usually reset the transport header anyway,
> after pulling the network header, so this change only allows
> a followup patch to have more precise qdisc pkt_len computation
> for GSO packets at ingress side.
>

Looks good to me.

cheers,
jamal

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox