* [PATCH net-next 0/2] net: ubuf_info.refcnt conversion
@ 2017-08-31 20:30 Eric Dumazet
2017-08-31 20:30 ` [PATCH net-next 1/2] net: prepare (struct ubuf_info)->refcnt conversion Eric Dumazet
2017-08-31 20:30 ` [PATCH net-next 2/2] net: convert (struct ubuf_info)->refcnt to refcount_t Eric Dumazet
0 siblings, 2 replies; 9+ messages in thread
From: Eric Dumazet @ 2017-08-31 20:30 UTC (permalink / raw)
To: David S . Miller; +Cc: netdev, Willem de Bruijn, Eric Dumazet, Eric Dumazet
Yet another atomic_t -> refcount_t conversion, split in two patches.
First patch prepares the automatic conversion done in the second patch.
Eric Dumazet (2):
net: prepare (struct ubuf_info)->refcnt conversion
net: convert (struct ubuf_info)->refcnt to refcount_t
include/linux/skbuff.h | 5 +++--
net/core/skbuff.c | 9 +++++----
net/ipv4/tcp.c | 2 --
3 files changed, 8 insertions(+), 8 deletions(-)
--
2.14.1.581.gf28d330327-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net-next 1/2] net: prepare (struct ubuf_info)->refcnt conversion
2017-08-31 20:30 [PATCH net-next 0/2] net: ubuf_info.refcnt conversion Eric Dumazet
@ 2017-08-31 20:30 ` Eric Dumazet
2017-08-31 22:35 ` Willem de Bruijn
2017-08-31 20:30 ` [PATCH net-next 2/2] net: convert (struct ubuf_info)->refcnt to refcount_t Eric Dumazet
1 sibling, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2017-08-31 20:30 UTC (permalink / raw)
To: David S . Miller; +Cc: netdev, Willem de Bruijn, Eric Dumazet, Eric Dumazet
In order to convert this atomic_t refcnt to refcount_t,
we need to init the refcount to one to not trigger
a 0 -> 1 transition.
This also removes one atomic operation in fast path.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/core/skbuff.c | 3 ++-
net/ipv4/tcp.c | 2 --
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 917da73d3ab3b82163cf0a9ee944da09cb5a391f..65b9ca3945f8fd2b1bef4aef5dd774be04e5d128 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -963,7 +963,7 @@ struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size)
uarg->len = 1;
uarg->bytelen = size;
uarg->zerocopy = 1;
- atomic_set(&uarg->refcnt, 0);
+ atomic_set(&uarg->refcnt, 1);
sock_hold(sk);
return uarg;
@@ -1005,6 +1005,7 @@ struct ubuf_info *sock_zerocopy_realloc(struct sock *sk, size_t size,
uarg->len++;
uarg->bytelen = bytelen;
atomic_set(&sk->sk_zckey, ++next);
+ sock_zerocopy_get(uarg);
return uarg;
}
}
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 21ca2df274c5130a13d31a391a1408d779af34af..fff4d7bc3b8b46174e7bd0a04d7c212307e55cb5 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1190,8 +1190,6 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
goto out_err;
}
- /* skb may be freed in main loop, keep extra ref on uarg */
- sock_zerocopy_get(uarg);
if (!(sk_check_csum_caps(sk) && sk->sk_route_caps & NETIF_F_SG))
uarg->zerocopy = 0;
}
--
2.14.1.581.gf28d330327-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next 2/2] net: convert (struct ubuf_info)->refcnt to refcount_t
2017-08-31 20:30 [PATCH net-next 0/2] net: ubuf_info.refcnt conversion Eric Dumazet
2017-08-31 20:30 ` [PATCH net-next 1/2] net: prepare (struct ubuf_info)->refcnt conversion Eric Dumazet
@ 2017-08-31 20:30 ` Eric Dumazet
2017-08-31 22:45 ` Willem de Bruijn
` (2 more replies)
1 sibling, 3 replies; 9+ messages in thread
From: Eric Dumazet @ 2017-08-31 20:30 UTC (permalink / raw)
To: David S . Miller; +Cc: netdev, Willem de Bruijn, Eric Dumazet, Eric Dumazet
refcount_t type and corresponding API should be
used instead of atomic_t when the variable is used as
a reference counter. This allows to avoid accidental
refcounter overflows that might lead to use-after-free
situations.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/linux/skbuff.h | 5 +++--
net/core/skbuff.c | 8 ++++----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 7594e19bce622a38dc39c054093c3da15b99b67b..316a92b45351f53709886ee0099cbc83b66f1b15 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -22,6 +22,7 @@
#include <linux/cache.h>
#include <linux/rbtree.h>
#include <linux/socket.h>
+#include <linux/refcount.h>
#include <linux/atomic.h>
#include <asm/types.h>
@@ -456,7 +457,7 @@ struct ubuf_info {
u32 bytelen;
};
};
- atomic_t refcnt;
+ refcount_t refcnt;
struct mmpin {
struct user_struct *user;
@@ -472,7 +473,7 @@ struct ubuf_info *sock_zerocopy_realloc(struct sock *sk, size_t size,
static inline void sock_zerocopy_get(struct ubuf_info *uarg)
{
- atomic_inc(&uarg->refcnt);
+ refcount_inc(&uarg->refcnt);
}
void sock_zerocopy_put(struct ubuf_info *uarg);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 65b9ca3945f8fd2b1bef4aef5dd774be04e5d128..ed86ca9afd9d8d1ac47983acf6006c179285a612 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -963,7 +963,7 @@ struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size)
uarg->len = 1;
uarg->bytelen = size;
uarg->zerocopy = 1;
- atomic_set(&uarg->refcnt, 1);
+ refcount_set(&uarg->refcnt, 1);
sock_hold(sk);
return uarg;
@@ -1086,7 +1086,7 @@ EXPORT_SYMBOL_GPL(sock_zerocopy_callback);
void sock_zerocopy_put(struct ubuf_info *uarg)
{
- if (uarg && atomic_dec_and_test(&uarg->refcnt)) {
+ if (uarg && refcount_dec_and_test(&uarg->refcnt)) {
if (uarg->callback)
uarg->callback(uarg, uarg->zerocopy);
else
@@ -1108,7 +1108,7 @@ void sock_zerocopy_put_abort(struct ubuf_info *uarg)
* avoid an skb send inside the main loop triggering uarg free.
*/
if (sk->sk_type != SOCK_STREAM)
- atomic_inc(&uarg->refcnt);
+ refcount_inc(&uarg->refcnt);
sock_zerocopy_put(uarg);
}
@@ -1490,7 +1490,7 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
if (skb_orphan_frags(skb, gfp_mask))
goto nofrags;
if (skb_zcopy(skb))
- atomic_inc(&skb_uarg(skb)->refcnt);
+ refcount_inc(&skb_uarg(skb)->refcnt);
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
skb_frag_ref(skb, i);
--
2.14.1.581.gf28d330327-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net-next 1/2] net: prepare (struct ubuf_info)->refcnt conversion
2017-08-31 20:30 ` [PATCH net-next 1/2] net: prepare (struct ubuf_info)->refcnt conversion Eric Dumazet
@ 2017-08-31 22:35 ` Willem de Bruijn
0 siblings, 0 replies; 9+ messages in thread
From: Willem de Bruijn @ 2017-08-31 22:35 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David S . Miller, netdev, Willem de Bruijn, Eric Dumazet
On Thu, Aug 31, 2017 at 4:30 PM, Eric Dumazet <edumazet@google.com> wrote:
> In order to convert this atomic_t refcnt to refcount_t,
> we need to init the refcount to one to not trigger
> a 0 -> 1 transition.
>
> This also removes one atomic operation in fast path.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Thanks, Eric.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next 2/2] net: convert (struct ubuf_info)->refcnt to refcount_t
2017-08-31 20:30 ` [PATCH net-next 2/2] net: convert (struct ubuf_info)->refcnt to refcount_t Eric Dumazet
@ 2017-08-31 22:45 ` Willem de Bruijn
2017-08-31 23:15 ` Eric Dumazet
2017-09-02 21:58 ` kbuild test robot
2017-09-02 21:58 ` kbuild test robot
2 siblings, 1 reply; 9+ messages in thread
From: Willem de Bruijn @ 2017-08-31 22:45 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David S . Miller, netdev, Willem de Bruijn, Eric Dumazet
On Thu, Aug 31, 2017 at 4:30 PM, Eric Dumazet <edumazet@google.com> wrote:
> refcount_t type and corresponding API should be
> used instead of atomic_t when the variable is used as
> a reference counter. This allows to avoid accidental
> refcounter overflows that might lead to use-after-free
> situations.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
> include/linux/skbuff.h | 5 +++--
> net/core/skbuff.c | 8 ++++----
> 2 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index 7594e19bce622a38dc39c054093c3da15b99b67b..316a92b45351f53709886ee0099cbc83b66f1b15 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -22,6 +22,7 @@
> #include <linux/cache.h>
> #include <linux/rbtree.h>
> #include <linux/socket.h>
> +#include <linux/refcount.h>
>
> #include <linux/atomic.h>
> #include <asm/types.h>
> @@ -456,7 +457,7 @@ struct ubuf_info {
> u32 bytelen;
> };
> };
> - atomic_t refcnt;
> + refcount_t refcnt;
>
> struct mmpin {
> struct user_struct *user;
> @@ -472,7 +473,7 @@ struct ubuf_info *sock_zerocopy_realloc(struct sock *sk, size_t size,
>
> static inline void sock_zerocopy_get(struct ubuf_info *uarg)
> {
> - atomic_inc(&uarg->refcnt);
> + refcount_inc(&uarg->refcnt);
> }
>
> void sock_zerocopy_put(struct ubuf_info *uarg);
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 65b9ca3945f8fd2b1bef4aef5dd774be04e5d128..ed86ca9afd9d8d1ac47983acf6006c179285a612 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -963,7 +963,7 @@ struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size)
> uarg->len = 1;
> uarg->bytelen = size;
> uarg->zerocopy = 1;
> - atomic_set(&uarg->refcnt, 1);
> + refcount_set(&uarg->refcnt, 1);
> sock_hold(sk);
>
> return uarg;
> @@ -1086,7 +1086,7 @@ EXPORT_SYMBOL_GPL(sock_zerocopy_callback);
>
> void sock_zerocopy_put(struct ubuf_info *uarg)
> {
> - if (uarg && atomic_dec_and_test(&uarg->refcnt)) {
> + if (uarg && refcount_dec_and_test(&uarg->refcnt)) {
> if (uarg->callback)
> uarg->callback(uarg, uarg->zerocopy);
> else
> @@ -1108,7 +1108,7 @@ void sock_zerocopy_put_abort(struct ubuf_info *uarg)
> * avoid an skb send inside the main loop triggering uarg free.
> */
> if (sk->sk_type != SOCK_STREAM)
> - atomic_inc(&uarg->refcnt);
> + refcount_inc(&uarg->refcnt);
This would be a 0 -> 1 transition. It is taken only on the error path from
a socket that does not take an explicit hold at the start of sendmsg.
The code is vestigial, really, as the final patchset only includes tcp.
It is safe to leave as is for now, or I can remove it.
In 1f8b977ab32d ("sock: enable MSG_ZEROCOPY") I also updated
other users of ubuf_info to initialize refcnt. We probably also want to
convert the call in handle_tx in drivers/vhost/net.c.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next 2/2] net: convert (struct ubuf_info)->refcnt to refcount_t
2017-08-31 22:45 ` Willem de Bruijn
@ 2017-08-31 23:15 ` Eric Dumazet
0 siblings, 0 replies; 9+ messages in thread
From: Eric Dumazet @ 2017-08-31 23:15 UTC (permalink / raw)
To: Willem de Bruijn; +Cc: Eric Dumazet, David S . Miller, netdev, Willem de Bruijn
On Thu, 2017-08-31 at 18:45 -0400, Willem de Bruijn wrote:
> On Thu, Aug 31, 2017 at 4:30 PM, Eric Dumazet <edumazet@google.com> wrote:
> > refcount_t type and corresponding API should be
> > used instead of atomic_t when the variable is used as
> > a reference counter. This allows to avoid accidental
> > refcounter overflows that might lead to use-after-free
> > situations.
> >
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
> > ---
> > include/linux/skbuff.h | 5 +++--
> > net/core/skbuff.c | 8 ++++----
> > 2 files changed, 7 insertions(+), 6 deletions(-)
> >
> > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> > index 7594e19bce622a38dc39c054093c3da15b99b67b..316a92b45351f53709886ee0099cbc83b66f1b15 100644
> > --- a/include/linux/skbuff.h
> > +++ b/include/linux/skbuff.h
> > @@ -22,6 +22,7 @@
> > #include <linux/cache.h>
> > #include <linux/rbtree.h>
> > #include <linux/socket.h>
> > +#include <linux/refcount.h>
> >
> > #include <linux/atomic.h>
> > #include <asm/types.h>
> > @@ -456,7 +457,7 @@ struct ubuf_info {
> > u32 bytelen;
> > };
> > };
> > - atomic_t refcnt;
> > + refcount_t refcnt;
> >
> > struct mmpin {
> > struct user_struct *user;
> > @@ -472,7 +473,7 @@ struct ubuf_info *sock_zerocopy_realloc(struct sock *sk, size_t size,
> >
> > static inline void sock_zerocopy_get(struct ubuf_info *uarg)
> > {
> > - atomic_inc(&uarg->refcnt);
> > + refcount_inc(&uarg->refcnt);
> > }
> >
> > void sock_zerocopy_put(struct ubuf_info *uarg);
> > diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> > index 65b9ca3945f8fd2b1bef4aef5dd774be04e5d128..ed86ca9afd9d8d1ac47983acf6006c179285a612 100644
> > --- a/net/core/skbuff.c
> > +++ b/net/core/skbuff.c
> > @@ -963,7 +963,7 @@ struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size)
> > uarg->len = 1;
> > uarg->bytelen = size;
> > uarg->zerocopy = 1;
> > - atomic_set(&uarg->refcnt, 1);
> > + refcount_set(&uarg->refcnt, 1);
> > sock_hold(sk);
> >
> > return uarg;
> > @@ -1086,7 +1086,7 @@ EXPORT_SYMBOL_GPL(sock_zerocopy_callback);
> >
> > void sock_zerocopy_put(struct ubuf_info *uarg)
> > {
> > - if (uarg && atomic_dec_and_test(&uarg->refcnt)) {
> > + if (uarg && refcount_dec_and_test(&uarg->refcnt)) {
> > if (uarg->callback)
> > uarg->callback(uarg, uarg->zerocopy);
> > else
> > @@ -1108,7 +1108,7 @@ void sock_zerocopy_put_abort(struct ubuf_info *uarg)
> > * avoid an skb send inside the main loop triggering uarg free.
> > */
> > if (sk->sk_type != SOCK_STREAM)
> > - atomic_inc(&uarg->refcnt);
> > + refcount_inc(&uarg->refcnt);
>
> This would be a 0 -> 1 transition. It is taken only on the error path from
> a socket that does not take an explicit hold at the start of sendmsg.
>
Arg.
> The code is vestigial, really, as the final patchset only includes tcp.
> It is safe to leave as is for now, or I can remove it.
>
OK I probably should remove this chunk in patch 1/2 then.
> In 1f8b977ab32d ("sock: enable MSG_ZEROCOPY") I also updated
> other users of ubuf_info to initialize refcnt. We probably also want to
> convert the call in handle_tx in drivers/vhost/net.c.
Thanks ! :)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next 2/2] net: convert (struct ubuf_info)->refcnt to refcount_t
2017-08-31 20:30 ` [PATCH net-next 2/2] net: convert (struct ubuf_info)->refcnt to refcount_t Eric Dumazet
2017-08-31 22:45 ` Willem de Bruijn
2017-09-02 21:58 ` kbuild test robot
@ 2017-09-02 21:58 ` kbuild test robot
2 siblings, 0 replies; 9+ messages in thread
From: kbuild test robot @ 2017-09-02 21:58 UTC (permalink / raw)
To: Eric Dumazet
Cc: kbuild-all, David S . Miller, netdev, Willem de Bruijn,
Eric Dumazet, Eric Dumazet
[-- Attachment #1: Type: text/plain, Size: 12764 bytes --]
Hi Eric,
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Eric-Dumazet/net-ubuf_info-refcnt-conversion/20170903-043506
config: x86_64-acpi-redef (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
drivers//vhost/net.c: In function 'handle_tx':
>> drivers//vhost/net.c:536:15: error: passing argument 1 of 'atomic_set' from incompatible pointer type [-Werror=incompatible-pointer-types]
atomic_set(&ubuf->refcnt, 1);
^
In file included from include/linux/atomic.h:4:0,
from include/linux/jump_label.h:183,
from arch/x86/include/asm/string_64.h:5,
from arch/x86/include/asm/string.h:4,
from include/linux/string.h:18,
from include/linux/bitmap.h:8,
from include/linux/cpumask.h:11,
from arch/x86/include/asm/cpumask.h:4,
from arch/x86/include/asm/msr.h:10,
from arch/x86/include/asm/processor.h:20,
from arch/x86/include/asm/cpufeature.h:4,
from arch/x86/include/asm/thread_info.h:52,
from include/linux/thread_info.h:37,
from arch/x86/include/asm/preempt.h:6,
from include/linux/preempt.h:80,
from include/linux/spinlock.h:50,
from include/linux/seqlock.h:35,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/compat.h:12,
from drivers//vhost/net.c:9:
arch/x86/include/asm/atomic.h:36:29: note: expected 'atomic_t * {aka struct <anonymous> *}' but argument is of type 'refcount_t * {aka struct refcount_struct *}'
static __always_inline void atomic_set(atomic_t *v, int i)
^~~~~~~~~~
cc1: some warnings being treated as errors
vim +/atomic_set +536 drivers//vhost/net.c
0ed005ce0 Jason Wang 2017-01-18 442
3a4d5c94e Michael S. Tsirkin 2010-01-14 443 /* Expects to be always run from workqueue - which acts as
3a4d5c94e Michael S. Tsirkin 2010-01-14 444 * read-size critical section for our kind of RCU. */
3a4d5c94e Michael S. Tsirkin 2010-01-14 445 static void handle_tx(struct vhost_net *net)
3a4d5c94e Michael S. Tsirkin 2010-01-14 446 {
2839400f8 Asias He 2013-04-27 447 struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_TX];
81f95a558 Michael S. Tsirkin 2013-04-28 448 struct vhost_virtqueue *vq = &nvq->vq;
98a527aac Al Viro 2014-12-10 449 unsigned out, in;
d5675bd20 Michael S. Tsirkin 2010-06-24 450 int head;
3a4d5c94e Michael S. Tsirkin 2010-01-14 451 struct msghdr msg = {
3a4d5c94e Michael S. Tsirkin 2010-01-14 452 .msg_name = NULL,
3a4d5c94e Michael S. Tsirkin 2010-01-14 453 .msg_namelen = 0,
3a4d5c94e Michael S. Tsirkin 2010-01-14 454 .msg_control = NULL,
3a4d5c94e Michael S. Tsirkin 2010-01-14 455 .msg_controllen = 0,
3a4d5c94e Michael S. Tsirkin 2010-01-14 456 .msg_flags = MSG_DONTWAIT,
3a4d5c94e Michael S. Tsirkin 2010-01-14 457 };
3a4d5c94e Michael S. Tsirkin 2010-01-14 458 size_t len, total_len = 0;
70181d512 Jason Wang 2013-04-10 459 int err;
3a4d5c94e Michael S. Tsirkin 2010-01-14 460 size_t hdr_size;
28457ee69 Arnd Bergmann 2010-03-09 461 struct socket *sock;
fe729a57c Asias He 2013-05-06 462 struct vhost_net_ubuf_ref *uninitialized_var(ubufs);
cedb9bdce Michael S. Tsirkin 2012-12-06 463 bool zcopy, zcopy_used;
28457ee69 Arnd Bergmann 2010-03-09 464
2e26af79b Asias He 2013-05-07 465 mutex_lock(&vq->mutex);
2e26af79b Asias He 2013-05-07 466 sock = vq->private_data;
3a4d5c94e Michael S. Tsirkin 2010-01-14 467 if (!sock)
2e26af79b Asias He 2013-05-07 468 goto out;
3a4d5c94e Michael S. Tsirkin 2010-01-14 469
6b1e6cc78 Jason Wang 2016-06-23 470 if (!vq_iotlb_prefetch(vq))
6b1e6cc78 Jason Wang 2016-06-23 471 goto out;
6b1e6cc78 Jason Wang 2016-06-23 472
8ea8cf89e Michael S. Tsirkin 2011-05-20 473 vhost_disable_notify(&net->dev, vq);
3a4d5c94e Michael S. Tsirkin 2010-01-14 474
81f95a558 Michael S. Tsirkin 2013-04-28 475 hdr_size = nvq->vhost_hlen;
2839400f8 Asias He 2013-04-27 476 zcopy = nvq->ubufs;
3a4d5c94e Michael S. Tsirkin 2010-01-14 477
3a4d5c94e Michael S. Tsirkin 2010-01-14 478 for (;;) {
bab632d69 Michael S. Tsirkin 2011-07-18 479 /* Release DMAs done buffers first */
bab632d69 Michael S. Tsirkin 2011-07-18 480 if (zcopy)
eaae8132e Michael S. Tsirkin 2012-11-01 481 vhost_zerocopy_signal_used(net, vq);
bab632d69 Michael S. Tsirkin 2011-07-18 482
f7c6be404 Jason Wang 2013-09-02 483 /* If more outstanding DMAs, queue the work.
f7c6be404 Jason Wang 2013-09-02 484 * Handle upend_idx wrap around
f7c6be404 Jason Wang 2013-09-02 485 */
0ed005ce0 Jason Wang 2017-01-18 486 if (unlikely(vhost_exceeds_maxpend(net)))
f7c6be404 Jason Wang 2013-09-02 487 break;
f7c6be404 Jason Wang 2013-09-02 488
030881372 Jason Wang 2016-03-04 489 head = vhost_net_tx_get_vq_desc(net, vq, vq->iov,
3a4d5c94e Michael S. Tsirkin 2010-01-14 490 ARRAY_SIZE(vq->iov),
030881372 Jason Wang 2016-03-04 491 &out, &in);
d5675bd20 Michael S. Tsirkin 2010-06-24 492 /* On error, stop handling until the next kick. */
7b3384fc3 Michael S. Tsirkin 2010-07-01 493 if (unlikely(head < 0))
d5675bd20 Michael S. Tsirkin 2010-06-24 494 break;
3a4d5c94e Michael S. Tsirkin 2010-01-14 495 /* Nothing new? Wait for eventfd to tell us they refilled. */
3a4d5c94e Michael S. Tsirkin 2010-01-14 496 if (head == vq->num) {
8ea8cf89e Michael S. Tsirkin 2011-05-20 497 if (unlikely(vhost_enable_notify(&net->dev, vq))) {
8ea8cf89e Michael S. Tsirkin 2011-05-20 498 vhost_disable_notify(&net->dev, vq);
3a4d5c94e Michael S. Tsirkin 2010-01-14 499 continue;
3a4d5c94e Michael S. Tsirkin 2010-01-14 500 }
3a4d5c94e Michael S. Tsirkin 2010-01-14 501 break;
3a4d5c94e Michael S. Tsirkin 2010-01-14 502 }
3a4d5c94e Michael S. Tsirkin 2010-01-14 503 if (in) {
3a4d5c94e Michael S. Tsirkin 2010-01-14 504 vq_err(vq, "Unexpected descriptor format for TX: "
3a4d5c94e Michael S. Tsirkin 2010-01-14 505 "out %d, int %d\n", out, in);
3a4d5c94e Michael S. Tsirkin 2010-01-14 506 break;
3a4d5c94e Michael S. Tsirkin 2010-01-14 507 }
3a4d5c94e Michael S. Tsirkin 2010-01-14 508 /* Skip header. TODO: support TSO. */
3a4d5c94e Michael S. Tsirkin 2010-01-14 509 len = iov_length(vq->iov, out);
c0371da60 Al Viro 2014-11-24 510 iov_iter_init(&msg.msg_iter, WRITE, vq->iov, out, len);
98a527aac Al Viro 2014-12-10 511 iov_iter_advance(&msg.msg_iter, hdr_size);
3a4d5c94e Michael S. Tsirkin 2010-01-14 512 /* Sanity check */
01e97e651 Al Viro 2014-12-15 513 if (!msg_data_left(&msg)) {
3a4d5c94e Michael S. Tsirkin 2010-01-14 514 vq_err(vq, "Unexpected header len for TX: "
3a4d5c94e Michael S. Tsirkin 2010-01-14 515 "%zd expected %zd\n",
98a527aac Al Viro 2014-12-10 516 len, hdr_size);
3a4d5c94e Michael S. Tsirkin 2010-01-14 517 break;
3a4d5c94e Michael S. Tsirkin 2010-01-14 518 }
01e97e651 Al Viro 2014-12-15 519 len = msg_data_left(&msg);
ce21a0291 Jason Wang 2013-09-02 520
ce21a0291 Jason Wang 2013-09-02 521 zcopy_used = zcopy && len >= VHOST_GOODCOPY_LEN
ce21a0291 Jason Wang 2013-09-02 522 && (nvq->upend_idx + 1) % UIO_MAXIOV !=
ce21a0291 Jason Wang 2013-09-02 523 nvq->done_idx
ce21a0291 Jason Wang 2013-09-02 524 && vhost_net_tx_select_zcopy(net);
cedb9bdce Michael S. Tsirkin 2012-12-06 525
bab632d69 Michael S. Tsirkin 2011-07-18 526 /* use msg_control to pass vhost zerocopy ubuf info to skb */
cedb9bdce Michael S. Tsirkin 2012-12-06 527 if (zcopy_used) {
46aa92d1b Michael S. Tsirkin 2013-03-17 528 struct ubuf_info *ubuf;
2839400f8 Asias He 2013-04-27 529 ubuf = nvq->ubuf_info + nvq->upend_idx;
bab632d69 Michael S. Tsirkin 2011-07-18 530
8b38694a2 Michael S. Tsirkin 2014-10-24 531 vq->heads[nvq->upend_idx].id = cpu_to_vhost32(vq, head);
ce21a0291 Jason Wang 2013-09-02 532 vq->heads[nvq->upend_idx].len = VHOST_DMA_IN_PROGRESS;
bab632d69 Michael S. Tsirkin 2011-07-18 533 ubuf->callback = vhost_zerocopy_callback;
2839400f8 Asias He 2013-04-27 534 ubuf->ctx = nvq->ubufs;
2839400f8 Asias He 2013-04-27 535 ubuf->desc = nvq->upend_idx;
1f8b977ab Willem de Bruijn 2017-08-03 @536 atomic_set(&ubuf->refcnt, 1);
bab632d69 Michael S. Tsirkin 2011-07-18 537 msg.msg_control = ubuf;
bab632d69 Michael S. Tsirkin 2011-07-18 538 msg.msg_controllen = sizeof(ubuf);
2839400f8 Asias He 2013-04-27 539 ubufs = nvq->ubufs;
0ad8b480d Michael S. Tsirkin 2014-02-13 540 atomic_inc(&ubufs->refcount);
2839400f8 Asias He 2013-04-27 541 nvq->upend_idx = (nvq->upend_idx + 1) % UIO_MAXIOV;
ce21a0291 Jason Wang 2013-09-02 542 } else {
4364d5f96 Jason Wang 2013-06-05 543 msg.msg_control = NULL;
ce21a0291 Jason Wang 2013-09-02 544 ubufs = NULL;
ce21a0291 Jason Wang 2013-09-02 545 }
0ed005ce0 Jason Wang 2017-01-18 546
0ed005ce0 Jason Wang 2017-01-18 547 total_len += len;
0ed005ce0 Jason Wang 2017-01-18 548 if (total_len < VHOST_NET_WEIGHT &&
0ed005ce0 Jason Wang 2017-01-18 549 !vhost_vq_avail_empty(&net->dev, vq) &&
0ed005ce0 Jason Wang 2017-01-18 550 likely(!vhost_exceeds_maxpend(net))) {
0ed005ce0 Jason Wang 2017-01-18 551 msg.msg_flags |= MSG_MORE;
0ed005ce0 Jason Wang 2017-01-18 552 } else {
0ed005ce0 Jason Wang 2017-01-18 553 msg.msg_flags &= ~MSG_MORE;
0ed005ce0 Jason Wang 2017-01-18 554 }
0ed005ce0 Jason Wang 2017-01-18 555
3a4d5c94e Michael S. Tsirkin 2010-01-14 556 /* TODO: Check specific error and bomb out unless ENOBUFS? */
1b7841404 Ying Xue 2015-03-02 557 err = sock->ops->sendmsg(sock, &msg, len);
3a4d5c94e Michael S. Tsirkin 2010-01-14 558 if (unlikely(err < 0)) {
cedb9bdce Michael S. Tsirkin 2012-12-06 559 if (zcopy_used) {
fe729a57c Asias He 2013-05-06 560 vhost_net_ubuf_put(ubufs);
2839400f8 Asias He 2013-04-27 561 nvq->upend_idx = ((unsigned)nvq->upend_idx - 1)
2839400f8 Asias He 2013-04-27 562 % UIO_MAXIOV;
bab632d69 Michael S. Tsirkin 2011-07-18 563 }
8dd014adf David Stevens 2010-07-27 564 vhost_discard_vq_desc(vq, 1);
3a4d5c94e Michael S. Tsirkin 2010-01-14 565 break;
3a4d5c94e Michael S. Tsirkin 2010-01-14 566 }
3a4d5c94e Michael S. Tsirkin 2010-01-14 567 if (err != len)
95c0ec6a9 Michael S. Tsirkin 2010-06-24 568 pr_debug("Truncated TX packet: "
3a4d5c94e Michael S. Tsirkin 2010-01-14 569 " len %d != %zd\n", err, len);
cedb9bdce Michael S. Tsirkin 2012-12-06 570 if (!zcopy_used)
3a4d5c94e Michael S. Tsirkin 2010-01-14 571 vhost_add_used_and_signal(&net->dev, vq, head, 0);
c8fb217af Jason Wang 2012-05-02 572 else
eaae8132e Michael S. Tsirkin 2012-11-01 573 vhost_zerocopy_signal_used(net, vq);
eaae8132e Michael S. Tsirkin 2012-11-01 574 vhost_net_tx_packet(net);
3a4d5c94e Michael S. Tsirkin 2010-01-14 575 if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
3a4d5c94e Michael S. Tsirkin 2010-01-14 576 vhost_poll_queue(&vq->poll);
3a4d5c94e Michael S. Tsirkin 2010-01-14 577 break;
3a4d5c94e Michael S. Tsirkin 2010-01-14 578 }
3a4d5c94e Michael S. Tsirkin 2010-01-14 579 }
2e26af79b Asias He 2013-05-07 580 out:
3a4d5c94e Michael S. Tsirkin 2010-01-14 581 mutex_unlock(&vq->mutex);
3a4d5c94e Michael S. Tsirkin 2010-01-14 582 }
3a4d5c94e Michael S. Tsirkin 2010-01-14 583
:::::: The code at line 536 was first introduced by commit
:::::: 1f8b977ab32dc5d148f103326e80d9097f1cefb5 sock: enable MSG_ZEROCOPY
:::::: TO: Willem de Bruijn <willemb@google.com>
:::::: CC: David S. Miller <davem@davemloft.net>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30263 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next 2/2] net: convert (struct ubuf_info)->refcnt to refcount_t
2017-08-31 20:30 ` [PATCH net-next 2/2] net: convert (struct ubuf_info)->refcnt to refcount_t Eric Dumazet
2017-08-31 22:45 ` Willem de Bruijn
@ 2017-09-02 21:58 ` kbuild test robot
2017-09-03 3:39 ` Willem de Bruijn
2017-09-02 21:58 ` kbuild test robot
2 siblings, 1 reply; 9+ messages in thread
From: kbuild test robot @ 2017-09-02 21:58 UTC (permalink / raw)
To: Eric Dumazet
Cc: kbuild-all, David S . Miller, netdev, Willem de Bruijn,
Eric Dumazet, Eric Dumazet
[-- Attachment #1: Type: text/plain, Size: 11970 bytes --]
Hi Eric,
[auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/Eric-Dumazet/net-ubuf_info-refcnt-conversion/20170903-043506
config: i386-randconfig-i1-201736 (attached as .config)
compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All warnings (new ones prefixed by >>):
drivers//vhost/net.c: In function 'handle_tx':
>> drivers//vhost/net.c:536:4: warning: passing argument 1 of 'atomic_set' from incompatible pointer type [enabled by default]
atomic_set(&ubuf->refcnt, 1);
^
In file included from include/linux/atomic.h:4:0,
from arch/x86/include/asm/thread_info.h:53,
from include/linux/thread_info.h:37,
from arch/x86/include/asm/preempt.h:6,
from include/linux/preempt.h:80,
from include/linux/spinlock.h:50,
from include/linux/wait.h:8,
from include/linux/eventfd.h:12,
from drivers//vhost/net.c:10:
arch/x86/include/asm/atomic.h:36:29: note: expected 'struct atomic_t *' but argument is of type 'struct refcount_t *'
static __always_inline void atomic_set(atomic_t *v, int i)
^
vim +/atomic_set +536 drivers//vhost/net.c
0ed005ce0 Jason Wang 2017-01-18 442
3a4d5c94e Michael S. Tsirkin 2010-01-14 443 /* Expects to be always run from workqueue - which acts as
3a4d5c94e Michael S. Tsirkin 2010-01-14 444 * read-size critical section for our kind of RCU. */
3a4d5c94e Michael S. Tsirkin 2010-01-14 445 static void handle_tx(struct vhost_net *net)
3a4d5c94e Michael S. Tsirkin 2010-01-14 446 {
2839400f8 Asias He 2013-04-27 447 struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_TX];
81f95a558 Michael S. Tsirkin 2013-04-28 448 struct vhost_virtqueue *vq = &nvq->vq;
98a527aac Al Viro 2014-12-10 449 unsigned out, in;
d5675bd20 Michael S. Tsirkin 2010-06-24 450 int head;
3a4d5c94e Michael S. Tsirkin 2010-01-14 451 struct msghdr msg = {
3a4d5c94e Michael S. Tsirkin 2010-01-14 452 .msg_name = NULL,
3a4d5c94e Michael S. Tsirkin 2010-01-14 453 .msg_namelen = 0,
3a4d5c94e Michael S. Tsirkin 2010-01-14 454 .msg_control = NULL,
3a4d5c94e Michael S. Tsirkin 2010-01-14 455 .msg_controllen = 0,
3a4d5c94e Michael S. Tsirkin 2010-01-14 456 .msg_flags = MSG_DONTWAIT,
3a4d5c94e Michael S. Tsirkin 2010-01-14 457 };
3a4d5c94e Michael S. Tsirkin 2010-01-14 458 size_t len, total_len = 0;
70181d512 Jason Wang 2013-04-10 459 int err;
3a4d5c94e Michael S. Tsirkin 2010-01-14 460 size_t hdr_size;
28457ee69 Arnd Bergmann 2010-03-09 461 struct socket *sock;
fe729a57c Asias He 2013-05-06 462 struct vhost_net_ubuf_ref *uninitialized_var(ubufs);
cedb9bdce Michael S. Tsirkin 2012-12-06 463 bool zcopy, zcopy_used;
28457ee69 Arnd Bergmann 2010-03-09 464
2e26af79b Asias He 2013-05-07 465 mutex_lock(&vq->mutex);
2e26af79b Asias He 2013-05-07 466 sock = vq->private_data;
3a4d5c94e Michael S. Tsirkin 2010-01-14 467 if (!sock)
2e26af79b Asias He 2013-05-07 468 goto out;
3a4d5c94e Michael S. Tsirkin 2010-01-14 469
6b1e6cc78 Jason Wang 2016-06-23 470 if (!vq_iotlb_prefetch(vq))
6b1e6cc78 Jason Wang 2016-06-23 471 goto out;
6b1e6cc78 Jason Wang 2016-06-23 472
8ea8cf89e Michael S. Tsirkin 2011-05-20 473 vhost_disable_notify(&net->dev, vq);
3a4d5c94e Michael S. Tsirkin 2010-01-14 474
81f95a558 Michael S. Tsirkin 2013-04-28 475 hdr_size = nvq->vhost_hlen;
2839400f8 Asias He 2013-04-27 476 zcopy = nvq->ubufs;
3a4d5c94e Michael S. Tsirkin 2010-01-14 477
3a4d5c94e Michael S. Tsirkin 2010-01-14 478 for (;;) {
bab632d69 Michael S. Tsirkin 2011-07-18 479 /* Release DMAs done buffers first */
bab632d69 Michael S. Tsirkin 2011-07-18 480 if (zcopy)
eaae8132e Michael S. Tsirkin 2012-11-01 481 vhost_zerocopy_signal_used(net, vq);
bab632d69 Michael S. Tsirkin 2011-07-18 482
f7c6be404 Jason Wang 2013-09-02 483 /* If more outstanding DMAs, queue the work.
f7c6be404 Jason Wang 2013-09-02 484 * Handle upend_idx wrap around
f7c6be404 Jason Wang 2013-09-02 485 */
0ed005ce0 Jason Wang 2017-01-18 486 if (unlikely(vhost_exceeds_maxpend(net)))
f7c6be404 Jason Wang 2013-09-02 487 break;
f7c6be404 Jason Wang 2013-09-02 488
030881372 Jason Wang 2016-03-04 489 head = vhost_net_tx_get_vq_desc(net, vq, vq->iov,
3a4d5c94e Michael S. Tsirkin 2010-01-14 490 ARRAY_SIZE(vq->iov),
030881372 Jason Wang 2016-03-04 491 &out, &in);
d5675bd20 Michael S. Tsirkin 2010-06-24 492 /* On error, stop handling until the next kick. */
7b3384fc3 Michael S. Tsirkin 2010-07-01 493 if (unlikely(head < 0))
d5675bd20 Michael S. Tsirkin 2010-06-24 494 break;
3a4d5c94e Michael S. Tsirkin 2010-01-14 495 /* Nothing new? Wait for eventfd to tell us they refilled. */
3a4d5c94e Michael S. Tsirkin 2010-01-14 496 if (head == vq->num) {
8ea8cf89e Michael S. Tsirkin 2011-05-20 497 if (unlikely(vhost_enable_notify(&net->dev, vq))) {
8ea8cf89e Michael S. Tsirkin 2011-05-20 498 vhost_disable_notify(&net->dev, vq);
3a4d5c94e Michael S. Tsirkin 2010-01-14 499 continue;
3a4d5c94e Michael S. Tsirkin 2010-01-14 500 }
3a4d5c94e Michael S. Tsirkin 2010-01-14 501 break;
3a4d5c94e Michael S. Tsirkin 2010-01-14 502 }
3a4d5c94e Michael S. Tsirkin 2010-01-14 503 if (in) {
3a4d5c94e Michael S. Tsirkin 2010-01-14 504 vq_err(vq, "Unexpected descriptor format for TX: "
3a4d5c94e Michael S. Tsirkin 2010-01-14 505 "out %d, int %d\n", out, in);
3a4d5c94e Michael S. Tsirkin 2010-01-14 506 break;
3a4d5c94e Michael S. Tsirkin 2010-01-14 507 }
3a4d5c94e Michael S. Tsirkin 2010-01-14 508 /* Skip header. TODO: support TSO. */
3a4d5c94e Michael S. Tsirkin 2010-01-14 509 len = iov_length(vq->iov, out);
c0371da60 Al Viro 2014-11-24 510 iov_iter_init(&msg.msg_iter, WRITE, vq->iov, out, len);
98a527aac Al Viro 2014-12-10 511 iov_iter_advance(&msg.msg_iter, hdr_size);
3a4d5c94e Michael S. Tsirkin 2010-01-14 512 /* Sanity check */
01e97e651 Al Viro 2014-12-15 513 if (!msg_data_left(&msg)) {
3a4d5c94e Michael S. Tsirkin 2010-01-14 514 vq_err(vq, "Unexpected header len for TX: "
3a4d5c94e Michael S. Tsirkin 2010-01-14 515 "%zd expected %zd\n",
98a527aac Al Viro 2014-12-10 516 len, hdr_size);
3a4d5c94e Michael S. Tsirkin 2010-01-14 517 break;
3a4d5c94e Michael S. Tsirkin 2010-01-14 518 }
01e97e651 Al Viro 2014-12-15 519 len = msg_data_left(&msg);
ce21a0291 Jason Wang 2013-09-02 520
ce21a0291 Jason Wang 2013-09-02 521 zcopy_used = zcopy && len >= VHOST_GOODCOPY_LEN
ce21a0291 Jason Wang 2013-09-02 522 && (nvq->upend_idx + 1) % UIO_MAXIOV !=
ce21a0291 Jason Wang 2013-09-02 523 nvq->done_idx
ce21a0291 Jason Wang 2013-09-02 524 && vhost_net_tx_select_zcopy(net);
cedb9bdce Michael S. Tsirkin 2012-12-06 525
bab632d69 Michael S. Tsirkin 2011-07-18 526 /* use msg_control to pass vhost zerocopy ubuf info to skb */
cedb9bdce Michael S. Tsirkin 2012-12-06 527 if (zcopy_used) {
46aa92d1b Michael S. Tsirkin 2013-03-17 528 struct ubuf_info *ubuf;
2839400f8 Asias He 2013-04-27 529 ubuf = nvq->ubuf_info + nvq->upend_idx;
bab632d69 Michael S. Tsirkin 2011-07-18 530
8b38694a2 Michael S. Tsirkin 2014-10-24 531 vq->heads[nvq->upend_idx].id = cpu_to_vhost32(vq, head);
ce21a0291 Jason Wang 2013-09-02 532 vq->heads[nvq->upend_idx].len = VHOST_DMA_IN_PROGRESS;
bab632d69 Michael S. Tsirkin 2011-07-18 533 ubuf->callback = vhost_zerocopy_callback;
2839400f8 Asias He 2013-04-27 534 ubuf->ctx = nvq->ubufs;
2839400f8 Asias He 2013-04-27 535 ubuf->desc = nvq->upend_idx;
1f8b977ab Willem de Bruijn 2017-08-03 @536 atomic_set(&ubuf->refcnt, 1);
bab632d69 Michael S. Tsirkin 2011-07-18 537 msg.msg_control = ubuf;
bab632d69 Michael S. Tsirkin 2011-07-18 538 msg.msg_controllen = sizeof(ubuf);
2839400f8 Asias He 2013-04-27 539 ubufs = nvq->ubufs;
0ad8b480d Michael S. Tsirkin 2014-02-13 540 atomic_inc(&ubufs->refcount);
2839400f8 Asias He 2013-04-27 541 nvq->upend_idx = (nvq->upend_idx + 1) % UIO_MAXIOV;
ce21a0291 Jason Wang 2013-09-02 542 } else {
4364d5f96 Jason Wang 2013-06-05 543 msg.msg_control = NULL;
ce21a0291 Jason Wang 2013-09-02 544 ubufs = NULL;
ce21a0291 Jason Wang 2013-09-02 545 }
0ed005ce0 Jason Wang 2017-01-18 546
0ed005ce0 Jason Wang 2017-01-18 547 total_len += len;
0ed005ce0 Jason Wang 2017-01-18 548 if (total_len < VHOST_NET_WEIGHT &&
0ed005ce0 Jason Wang 2017-01-18 549 !vhost_vq_avail_empty(&net->dev, vq) &&
0ed005ce0 Jason Wang 2017-01-18 550 likely(!vhost_exceeds_maxpend(net))) {
0ed005ce0 Jason Wang 2017-01-18 551 msg.msg_flags |= MSG_MORE;
0ed005ce0 Jason Wang 2017-01-18 552 } else {
0ed005ce0 Jason Wang 2017-01-18 553 msg.msg_flags &= ~MSG_MORE;
0ed005ce0 Jason Wang 2017-01-18 554 }
0ed005ce0 Jason Wang 2017-01-18 555
3a4d5c94e Michael S. Tsirkin 2010-01-14 556 /* TODO: Check specific error and bomb out unless ENOBUFS? */
1b7841404 Ying Xue 2015-03-02 557 err = sock->ops->sendmsg(sock, &msg, len);
3a4d5c94e Michael S. Tsirkin 2010-01-14 558 if (unlikely(err < 0)) {
cedb9bdce Michael S. Tsirkin 2012-12-06 559 if (zcopy_used) {
fe729a57c Asias He 2013-05-06 560 vhost_net_ubuf_put(ubufs);
2839400f8 Asias He 2013-04-27 561 nvq->upend_idx = ((unsigned)nvq->upend_idx - 1)
2839400f8 Asias He 2013-04-27 562 % UIO_MAXIOV;
bab632d69 Michael S. Tsirkin 2011-07-18 563 }
8dd014adf David Stevens 2010-07-27 564 vhost_discard_vq_desc(vq, 1);
3a4d5c94e Michael S. Tsirkin 2010-01-14 565 break;
3a4d5c94e Michael S. Tsirkin 2010-01-14 566 }
3a4d5c94e Michael S. Tsirkin 2010-01-14 567 if (err != len)
95c0ec6a9 Michael S. Tsirkin 2010-06-24 568 pr_debug("Truncated TX packet: "
3a4d5c94e Michael S. Tsirkin 2010-01-14 569 " len %d != %zd\n", err, len);
cedb9bdce Michael S. Tsirkin 2012-12-06 570 if (!zcopy_used)
3a4d5c94e Michael S. Tsirkin 2010-01-14 571 vhost_add_used_and_signal(&net->dev, vq, head, 0);
c8fb217af Jason Wang 2012-05-02 572 else
eaae8132e Michael S. Tsirkin 2012-11-01 573 vhost_zerocopy_signal_used(net, vq);
eaae8132e Michael S. Tsirkin 2012-11-01 574 vhost_net_tx_packet(net);
3a4d5c94e Michael S. Tsirkin 2010-01-14 575 if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
3a4d5c94e Michael S. Tsirkin 2010-01-14 576 vhost_poll_queue(&vq->poll);
3a4d5c94e Michael S. Tsirkin 2010-01-14 577 break;
3a4d5c94e Michael S. Tsirkin 2010-01-14 578 }
3a4d5c94e Michael S. Tsirkin 2010-01-14 579 }
2e26af79b Asias He 2013-05-07 580 out:
3a4d5c94e Michael S. Tsirkin 2010-01-14 581 mutex_unlock(&vq->mutex);
3a4d5c94e Michael S. Tsirkin 2010-01-14 582 }
3a4d5c94e Michael S. Tsirkin 2010-01-14 583
:::::: The code at line 536 was first introduced by commit
:::::: 1f8b977ab32dc5d148f103326e80d9097f1cefb5 sock: enable MSG_ZEROCOPY
:::::: TO: Willem de Bruijn <willemb@google.com>
:::::: CC: David S. Miller <davem@davemloft.net>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32722 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next 2/2] net: convert (struct ubuf_info)->refcnt to refcount_t
2017-09-02 21:58 ` kbuild test robot
@ 2017-09-03 3:39 ` Willem de Bruijn
0 siblings, 0 replies; 9+ messages in thread
From: Willem de Bruijn @ 2017-09-03 3:39 UTC (permalink / raw)
To: kbuild test robot
Cc: Eric Dumazet, kbuild-all, David S . Miller, netdev,
Willem de Bruijn, Eric Dumazet
On Sat, Sep 2, 2017 at 5:58 PM, kbuild test robot <lkp@intel.com> wrote:
> Hi Eric,
>
> [auto build test WARNING on net-next/master]
>
> url: https://github.com/0day-ci/linux/commits/Eric-Dumazet/net-ubuf_info-refcnt-conversion/20170903-043506
> config: i386-randconfig-i1-201736 (attached as .config)
> compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386
>
> All warnings (new ones prefixed by >>):
>
> drivers//vhost/net.c: In function 'handle_tx':
>>> drivers//vhost/net.c:536:4: warning: passing argument 1 of 'atomic_set' from incompatible pointer type [enabled by default]
> atomic_set(&ubuf->refcnt, 1);
> ^
> In file included from include/linux/atomic.h:4:0,
> from arch/x86/include/asm/thread_info.h:53,
> from include/linux/thread_info.h:37,
> from arch/x86/include/asm/preempt.h:6,
> from include/linux/preempt.h:80,
> from include/linux/spinlock.h:50,
> from include/linux/wait.h:8,
> from include/linux/eventfd.h:12,
> from drivers//vhost/net.c:10:
> arch/x86/include/asm/atomic.h:36:29: note: expected 'struct atomic_t *' but argument is of type 'struct refcount_t *'
> static __always_inline void atomic_set(atomic_t *v, int i)
> ^
This is a false positive. This patch
[net-next,2/2] net: convert (struct ubuf_info)->refcnt to refcount_t
http://patchwork.ozlabs.org/patch/808402/
was superseded by
[v2,net-next,2/2] net: convert (struct ubuf_info)->refcnt to refcount_t
http://patchwork.ozlabs.org/patch/808477/
which has been merged into net-next as commit c1d1b437816f
That patch has the necessary change:
- atomic_set(&ubuf->refcnt, 1);
+ refcount_set(&ubuf->refcnt, 1);
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-09-03 3:39 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-31 20:30 [PATCH net-next 0/2] net: ubuf_info.refcnt conversion Eric Dumazet
2017-08-31 20:30 ` [PATCH net-next 1/2] net: prepare (struct ubuf_info)->refcnt conversion Eric Dumazet
2017-08-31 22:35 ` Willem de Bruijn
2017-08-31 20:30 ` [PATCH net-next 2/2] net: convert (struct ubuf_info)->refcnt to refcount_t Eric Dumazet
2017-08-31 22:45 ` Willem de Bruijn
2017-08-31 23:15 ` Eric Dumazet
2017-09-02 21:58 ` kbuild test robot
2017-09-03 3:39 ` Willem de Bruijn
2017-09-02 21:58 ` kbuild test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.