<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/net/core/netpoll.c, branch v3.10.8</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>netpoll: inverted down_trylock() test</title>
<updated>2013-05-06T15:06:52+00:00</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2013-05-06T02:15:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a3dbbc2bab8d9a6e55fc0af3906d1dddbc0c531e'/>
<id>a3dbbc2bab8d9a6e55fc0af3906d1dddbc0c531e</id>
<content type='text'>
The return value is reversed from mutex_trylock().

Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The return value is reversed from mutex_trylock().

Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netpoll: convert mutex into a semaphore</title>
<updated>2013-05-01T19:00:24+00:00</updated>
<author>
<name>Neil Horman</name>
<email>nhorman@tuxdriver.com</email>
</author>
<published>2013-04-30T05:35:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=bd7c4b604a6cd707803c7c6ba142bfa131f9a9f3'/>
<id>bd7c4b604a6cd707803c7c6ba142bfa131f9a9f3</id>
<content type='text'>
Bart Van Assche recently reported a warning to me:

&lt;IRQ&gt;  [&lt;ffffffff8103d79f&gt;] warn_slowpath_common+0x7f/0xc0
[&lt;ffffffff8103d7fa&gt;] warn_slowpath_null+0x1a/0x20
[&lt;ffffffff814761dd&gt;] mutex_trylock+0x16d/0x180
[&lt;ffffffff813968c9&gt;] netpoll_poll_dev+0x49/0xc30
[&lt;ffffffff8136a2d2&gt;] ? __alloc_skb+0x82/0x2a0
[&lt;ffffffff81397715&gt;] netpoll_send_skb_on_dev+0x265/0x410
[&lt;ffffffff81397c5a&gt;] netpoll_send_udp+0x28a/0x3a0
[&lt;ffffffffa0541843&gt;] ? write_msg+0x53/0x110 [netconsole]
[&lt;ffffffffa05418bf&gt;] write_msg+0xcf/0x110 [netconsole]
[&lt;ffffffff8103eba1&gt;] call_console_drivers.constprop.17+0xa1/0x1c0
[&lt;ffffffff8103fb76&gt;] console_unlock+0x2d6/0x450
[&lt;ffffffff8104011e&gt;] vprintk_emit+0x1ee/0x510
[&lt;ffffffff8146f9f6&gt;] printk+0x4d/0x4f
[&lt;ffffffffa0004f1d&gt;] scsi_print_command+0x7d/0xe0 [scsi_mod]

This resulted from my commit ca99ca14c which introduced a mutex_trylock
operation in a path that could execute in interrupt context.  When mutex
debugging is enabled, the above warns the user when we are in fact
exectuting in interrupt context
interrupt context.

After some discussion, It seems that a semaphore is the proper mechanism to use
here.  While mutexes are defined to be unusable in interrupt context, no such
condition exists for semaphores (save for the fact that the non blocking api
calls, like up and down_trylock must be used when in irq context).

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Reported-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
CC: Bart Van Assche &lt;bvanassche@acm.org&gt;
CC: David Miller &lt;davem@davemloft.net&gt;
CC: netdev@vger.kernel.org
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Bart Van Assche recently reported a warning to me:

&lt;IRQ&gt;  [&lt;ffffffff8103d79f&gt;] warn_slowpath_common+0x7f/0xc0
[&lt;ffffffff8103d7fa&gt;] warn_slowpath_null+0x1a/0x20
[&lt;ffffffff814761dd&gt;] mutex_trylock+0x16d/0x180
[&lt;ffffffff813968c9&gt;] netpoll_poll_dev+0x49/0xc30
[&lt;ffffffff8136a2d2&gt;] ? __alloc_skb+0x82/0x2a0
[&lt;ffffffff81397715&gt;] netpoll_send_skb_on_dev+0x265/0x410
[&lt;ffffffff81397c5a&gt;] netpoll_send_udp+0x28a/0x3a0
[&lt;ffffffffa0541843&gt;] ? write_msg+0x53/0x110 [netconsole]
[&lt;ffffffffa05418bf&gt;] write_msg+0xcf/0x110 [netconsole]
[&lt;ffffffff8103eba1&gt;] call_console_drivers.constprop.17+0xa1/0x1c0
[&lt;ffffffff8103fb76&gt;] console_unlock+0x2d6/0x450
[&lt;ffffffff8104011e&gt;] vprintk_emit+0x1ee/0x510
[&lt;ffffffff8146f9f6&gt;] printk+0x4d/0x4f
[&lt;ffffffffa0004f1d&gt;] scsi_print_command+0x7d/0xe0 [scsi_mod]

This resulted from my commit ca99ca14c which introduced a mutex_trylock
operation in a path that could execute in interrupt context.  When mutex
debugging is enabled, the above warns the user when we are in fact
exectuting in interrupt context
interrupt context.

After some discussion, It seems that a semaphore is the proper mechanism to use
here.  While mutexes are defined to be unusable in interrupt context, no such
condition exists for semaphores (save for the fact that the non blocking api
calls, like up and down_trylock must be used when in irq context).

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Reported-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
CC: Bart Van Assche &lt;bvanassche@acm.org&gt;
CC: David Miller &lt;davem@davemloft.net&gt;
CC: netdev@vger.kernel.org
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>net: vlan: add protocol argument to packet tagging functions</title>
<updated>2013-04-19T18:46:06+00:00</updated>
<author>
<name>Patrick McHardy</name>
<email>kaber@trash.net</email>
</author>
<published>2013-04-19T02:04:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=86a9bad3ab6b6f858fd4443b48738cabbb6d094c'/>
<id>86a9bad3ab6b6f858fd4443b48738cabbb6d094c</id>
<content type='text'>
Add a protocol argument to the VLAN packet tagging functions. In case of HW
tagging, we need that protocol available in the ndo_start_xmit functions,
so it is stored in a new field in the skb. The new field fits into a hole
(on 64 bit) and doesn't increase the sks's size.

Signed-off-by: Patrick McHardy &lt;kaber@trash.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add a protocol argument to the VLAN packet tagging functions. In case of HW
tagging, we need that protocol available in the ndo_start_xmit functions,
so it is stored in a new field in the skb. The new field fits into a hole
(on 64 bit) and doesn't increase the sks's size.

Signed-off-by: Patrick McHardy &lt;kaber@trash.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>net: vlan: rename NETIF_F_HW_VLAN_* feature flags to NETIF_F_HW_VLAN_CTAG_*</title>
<updated>2013-04-19T18:45:26+00:00</updated>
<author>
<name>Patrick McHardy</name>
<email>kaber@trash.net</email>
</author>
<published>2013-04-19T02:04:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f646968f8f7c624587de729115d802372b9063dd'/>
<id>f646968f8f7c624587de729115d802372b9063dd</id>
<content type='text'>
Rename the hardware VLAN acceleration features to include "CTAG" to indicate
that they only support CTAGs. Follow up patches will introduce 802.1ad
server provider tagging (STAGs) and require the distinction for hardware not
supporting acclerating both.

Signed-off-by: Patrick McHardy &lt;kaber@trash.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Rename the hardware VLAN acceleration features to include "CTAG" to indicate
that they only support CTAGs. Follow up patches will introduce 802.1ad
server provider tagging (STAGs) and require the distinction for hardware not
supporting acclerating both.

Signed-off-by: Patrick McHardy &lt;kaber@trash.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netpoll: use DEFINE_STATIC_SRCU() to define netpoll_srcu</title>
<updated>2013-03-17T16:42:43+00:00</updated>
<author>
<name>Lai Jiangshan</name>
<email>laijs@cn.fujitsu.com</email>
</author>
<published>2013-03-15T06:50:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7f9421c264f8a6e6137027a45ae576517f66fa56'/>
<id>7f9421c264f8a6e6137027a45ae576517f66fa56</id>
<content type='text'>
DEFINE_STATIC_SRCU() defines srcu struct and do init at build time.

Signed-off-by: Lai Jiangshan &lt;laijs@cn.fujitsu.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
DEFINE_STATIC_SRCU() defines srcu struct and do init at build time.

Signed-off-by: Lai Jiangshan &lt;laijs@cn.fujitsu.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netpoll: fix smatch warnings in netpoll core code</title>
<updated>2013-02-13T16:56:46+00:00</updated>
<author>
<name>Neil Horman</name>
<email>nhorman@tuxdriver.com</email>
</author>
<published>2013-02-13T16:32:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=959d5fdee7aa32fa04bc2c37e3d3871ad266fe97'/>
<id>959d5fdee7aa32fa04bc2c37e3d3871ad266fe97</id>
<content type='text'>
Dan Carpenter contacted me with some notes regarding some smatch warnings in the
netpoll code, some of which I introduced with my recent netpoll locking fixes,
some which were there prior.   Specifically they were:

net-next/net/core/netpoll.c:243 netpoll_poll_dev() warn: inconsistent
  returns mutex:&amp;ni-&gt;dev_lock: locked (213,217) unlocked (210,243)
net-next/net/core/netpoll.c:706 netpoll_neigh_reply() warn: potential
  pointer math issue ('skb_transport_header(send_skb)' is a 128 bit pointer)

This patch corrects the locking imbalance (the first error), and adds some
parenthesis to correct the second error.  Tested by myself. Applies to net-next

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
CC: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
CC: "David S. Miller" &lt;davem@davemloft.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Dan Carpenter contacted me with some notes regarding some smatch warnings in the
netpoll code, some of which I introduced with my recent netpoll locking fixes,
some which were there prior.   Specifically they were:

net-next/net/core/netpoll.c:243 netpoll_poll_dev() warn: inconsistent
  returns mutex:&amp;ni-&gt;dev_lock: locked (213,217) unlocked (210,243)
net-next/net/core/netpoll.c:706 netpoll_neigh_reply() warn: potential
  pointer math issue ('skb_transport_header(send_skb)' is a 128 bit pointer)

This patch corrects the locking imbalance (the first error), and adds some
parenthesis to correct the second error.  Tested by myself. Applies to net-next

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
CC: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
CC: "David S. Miller" &lt;davem@davemloft.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netpoll: cleanup sparse warnings</title>
<updated>2013-02-12T00:19:58+00:00</updated>
<author>
<name>Neil Horman</name>
<email>nhorman@tuxdriver.com</email>
</author>
<published>2013-02-11T10:25:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0790bbb68f9d483348c1d65381f3dd92602bfd05'/>
<id>0790bbb68f9d483348c1d65381f3dd92602bfd05</id>
<content type='text'>
With my recent commit I introduced two sparse warnings.  Looking closer there
were a few more in the same file, so I fixed them all up.  Basic rcu pointer
dereferencing suff.

I've validated these changes using CONFIG_PROVE_RCU while starting and stopping
netconsole repeatedly in bonded and non-bonded configurations

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
CC: fengguang.wu@intel.com
CC: David Miller &lt;davem@davemloft.net&gt;
CC: eric.dumazet@gmail.com

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
With my recent commit I introduced two sparse warnings.  Looking closer there
were a few more in the same file, so I fixed them all up.  Basic rcu pointer
dereferencing suff.

I've validated these changes using CONFIG_PROVE_RCU while starting and stopping
netconsole repeatedly in bonded and non-bonded configurations

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
CC: fengguang.wu@intel.com
CC: David Miller &lt;davem@davemloft.net&gt;
CC: eric.dumazet@gmail.com

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netpoll: Fix __netpoll_rcu_free so that it can hold the rtnl lock</title>
<updated>2013-02-12T00:19:33+00:00</updated>
<author>
<name>Neil Horman</name>
<email>nhorman@tuxdriver.com</email>
</author>
<published>2013-02-11T10:25:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2cde6acd49daca58b96f1fbc697492825511ad31'/>
<id>2cde6acd49daca58b96f1fbc697492825511ad31</id>
<content type='text'>
__netpoll_rcu_free is used to free netpoll structures when the rtnl_lock is
already held.  The mechanism is used to asynchronously call __netpoll_cleanup
outside of the holding of the rtnl_lock, so as to avoid deadlock.
Unfortunately, __netpoll_cleanup modifies pointers (dev-&gt;np), which means the
rtnl_lock must be held while calling it.  Further, it cannot be held, because
rcu callbacks may be issued in softirq contexts, which cannot sleep.

Fix this by converting the rcu callback to a work queue that is guaranteed to
get scheduled in process context, so that we can hold the rtnl properly while
calling __netpoll_cleanup

Tested successfully by myself.

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
CC: "David S. Miller" &lt;davem@davemloft.net&gt;
CC: Cong Wang &lt;amwang@redhat.com&gt;
CC: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
__netpoll_rcu_free is used to free netpoll structures when the rtnl_lock is
already held.  The mechanism is used to asynchronously call __netpoll_cleanup
outside of the holding of the rtnl_lock, so as to avoid deadlock.
Unfortunately, __netpoll_cleanup modifies pointers (dev-&gt;np), which means the
rtnl_lock must be held while calling it.  Further, it cannot be held, because
rcu callbacks may be issued in softirq contexts, which cannot sleep.

Fix this by converting the rcu callback to a work queue that is guaranteed to
get scheduled in process context, so that we can hold the rtnl properly while
calling __netpoll_cleanup

Tested successfully by myself.

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
CC: "David S. Miller" &lt;davem@davemloft.net&gt;
CC: Cong Wang &lt;amwang@redhat.com&gt;
CC: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netpoll: protect napi_poll and poll_controller during dev_[open|close]</title>
<updated>2013-02-06T20:45:03+00:00</updated>
<author>
<name>Neil Horman</name>
<email>nhorman@tuxdriver.com</email>
</author>
<published>2013-02-05T08:05:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ca99ca14c95ae49fb4c9cd3abf5f84d11a7e8a61'/>
<id>ca99ca14c95ae49fb4c9cd3abf5f84d11a7e8a61</id>
<content type='text'>
Ivan Vercera was recently backporting commit
9c13cb8bb477a83b9a3c9e5a5478a4e21294a760 to a RHEL kernel, and I noticed that,
while this patch protects the tg3 driver from having its ndo_poll_controller
routine called during device initalization, it does nothing for the driver
during shutdown. I.e. it would be entirely possible to have the
ndo_poll_controller method (or subsequently the ndo_poll) routine called for a
driver in the netpoll path on CPU A while in parallel on CPU B, the ndo_close or
ndo_open routine could be called.  Given that the two latter routines tend to
initizlize and free many data structures that the former two rely on, the result
can easily be data corruption or various other crashes.  Furthermore, it seems
that this is potentially a problem with all net drivers that support netpoll,
and so this should ideally be fixed in a common path.

As Ben H Pointed out to me, we can't preform dev_open/dev_close in atomic
context, so I've come up with this solution.  We can use a mutex to sleep in
open/close paths and just do a mutex_trylock in the napi poll path and abandon
the poll attempt if we're locked, as we'll just retry the poll on the next send
anyway.

I've tested this here by flooding netconsole with messages on a system whos nic
driver I modfied to periodically return NETDEV_TX_BUSY, so that the netpoll tx
workqueue would be forced to send frames and poll the device.  While this was
going on I rapidly ifdown/up'ed the interface and watched for any problems.
I've not found any.

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
CC: Ivan Vecera &lt;ivecera@redhat.com&gt;
CC: "David S. Miller" &lt;davem@davemloft.net&gt;
CC: Ben Hutchings &lt;bhutchings@solarflare.com&gt;
CC: Francois Romieu &lt;romieu@fr.zoreil.com&gt;
CC: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Ivan Vercera was recently backporting commit
9c13cb8bb477a83b9a3c9e5a5478a4e21294a760 to a RHEL kernel, and I noticed that,
while this patch protects the tg3 driver from having its ndo_poll_controller
routine called during device initalization, it does nothing for the driver
during shutdown. I.e. it would be entirely possible to have the
ndo_poll_controller method (or subsequently the ndo_poll) routine called for a
driver in the netpoll path on CPU A while in parallel on CPU B, the ndo_close or
ndo_open routine could be called.  Given that the two latter routines tend to
initizlize and free many data structures that the former two rely on, the result
can easily be data corruption or various other crashes.  Furthermore, it seems
that this is potentially a problem with all net drivers that support netpoll,
and so this should ideally be fixed in a common path.

As Ben H Pointed out to me, we can't preform dev_open/dev_close in atomic
context, so I've come up with this solution.  We can use a mutex to sleep in
open/close paths and just do a mutex_trylock in the napi poll path and abandon
the poll attempt if we're locked, as we'll just retry the poll on the next send
anyway.

I've tested this here by flooding netconsole with messages on a system whos nic
driver I modfied to periodically return NETDEV_TX_BUSY, so that the netpoll tx
workqueue would be forced to send frames and poll the device.  While this was
going on I rapidly ifdown/up'ed the interface and watched for any problems.
I've not found any.

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
CC: Ivan Vecera &lt;ivecera@redhat.com&gt;
CC: "David S. Miller" &lt;davem@davemloft.net&gt;
CC: Ben Hutchings &lt;bhutchings@solarflare.com&gt;
CC: Francois Romieu &lt;romieu@fr.zoreil.com&gt;
CC: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netpoll: use the net namespace of current process instead of init_net</title>
<updated>2013-01-28T23:32:55+00:00</updated>
<author>
<name>Cong Wang</name>
<email>amwang@redhat.com</email>
</author>
<published>2013-01-27T15:55:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=556e6256c813063b95a9f4e55109f77c1a7d3fdd'/>
<id>556e6256c813063b95a9f4e55109f77c1a7d3fdd</id>
<content type='text'>
This will allow us to setup netconsole in a different namespace
rather than where init_net is.

Cc: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Cong Wang &lt;amwang@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This will allow us to setup netconsole in a different namespace
rather than where init_net is.

Cc: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Cong Wang &lt;amwang@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
</feed>
