Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1532957 > unrolled thread
| Started by | Jason Wang <jasowang@redhat.com> |
|---|---|
| First post | 2016-11-30 06:20 +0100 |
| Last post | 2016-11-30 15:00 +0100 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH net 1/2] tun: handle ubuf refcount correctly when meet erros Jason Wang <jasowang@redhat.com> - 2016-11-30 06:20 +0100
[PATCH net 2/2] macvtap: handle ubuf refcount correctly when meet erros Jason Wang <jasowang@redhat.com> - 2016-11-30 06:20 +0100
Re: [PATCH net 2/2] macvtap: handle ubuf refcount correctly when meet erros "Michael S. Tsirkin" <mst@redhat.com> - 2016-11-30 15:00 +0100
Re: [PATCH net 1/2] tun: handle ubuf refcount correctly when meet erros "Michael S. Tsirkin" <mst@redhat.com> - 2016-11-30 15:00 +0100
| From | Jason Wang <jasowang@redhat.com> |
|---|---|
| Date | 2016-11-30 06:20 +0100 |
| Subject | [PATCH net 1/2] tun: handle ubuf refcount correctly when meet erros |
| Message-ID | <sJ5tf-1Kz-9@gated-at.bofh.it> |
We trigger uarg->callback() immediately after we decide do datacopy
even if caller want to do zerocopy. This will cause the callback
(vhost_net_zerocopy_callback) decrease the refcount. But when we meet
an error afterwards, the error handling in vhost handle_tx() will try
to decrease it again. This is wrong and fix this by delay the
uarg->callback() until we're sure there's no errors.
Reported-by: wangyunjian <wangyunjian@huawei.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
The patch is needed for -stable.
---
drivers/net/tun.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 8093e39..db6acec 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1246,13 +1246,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
if (zerocopy)
err = zerocopy_sg_from_iter(skb, from);
- else {
+ else
err = skb_copy_datagram_from_iter(skb, 0, from, len);
- if (!err && msg_control) {
- struct ubuf_info *uarg = msg_control;
- uarg->callback(uarg, false);
- }
- }
if (err) {
this_cpu_inc(tun->pcpu_stats->rx_dropped);
@@ -1298,6 +1293,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
skb_shinfo(skb)->destructor_arg = msg_control;
skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
+ } else if (msg_control) {
+ struct ubuf_info *uarg = msg_control;
+ uarg->callback(uarg, false);
}
skb_reset_network_header(skb);
--
2.7.4
[toc] | [next] | [standalone]
| From | Jason Wang <jasowang@redhat.com> |
|---|---|
| Date | 2016-11-30 06:20 +0100 |
| Subject | [PATCH net 2/2] macvtap: handle ubuf refcount correctly when meet erros |
| Message-ID | <sJ5tg-1Kz-11@gated-at.bofh.it> |
| In reply to | #1532957 |
We trigger uarg->callback() immediately after we decide do datacopy
even if caller want to do zerocopy. This will cause the callback
(vhost_net_zerocopy_callback) decrease the refcount. But when we meet
an error afterwards, the error handling in vhost handle_tx() will try
to decrease it again. This is wrong and fix this by delay the
uarg->callback() until we're sure there's no errors.
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
The patch is needed for -stable.
---
drivers/net/macvtap.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index bceca28..7869b06 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -742,13 +742,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
if (zerocopy)
err = zerocopy_sg_from_iter(skb, from);
- else {
+ else
err = skb_copy_datagram_from_iter(skb, 0, from, len);
- if (!err && m && m->msg_control) {
- struct ubuf_info *uarg = m->msg_control;
- uarg->callback(uarg, false);
- }
- }
if (err)
goto err_kfree;
@@ -779,7 +774,11 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
skb_shinfo(skb)->destructor_arg = m->msg_control;
skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
+ } else if (m && m->msg_control) {
+ struct ubuf_info *uarg = m->msg_control;
+ uarg->callback(uarg, false);
}
+
if (vlan) {
skb->dev = vlan->dev;
dev_queue_xmit(skb);
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | "Michael S. Tsirkin" <mst@redhat.com> |
|---|---|
| Date | 2016-11-30 15:00 +0100 |
| Subject | Re: [PATCH net 2/2] macvtap: handle ubuf refcount correctly when meet erros |
| Message-ID | <sJdAu-6My-35@gated-at.bofh.it> |
| In reply to | #1532960 |
On Wed, Nov 30, 2016 at 01:17:52PM +0800, Jason Wang wrote:
> We trigger uarg->callback() immediately after we decide do datacopy
> even if caller want to do zerocopy. This will cause the callback
> (vhost_net_zerocopy_callback) decrease the refcount. But when we meet
> an error afterwards, the error handling in vhost handle_tx() will try
> to decrease it again. This is wrong and fix this by delay the
> uarg->callback() until we're sure there's no errors.
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> The patch is needed for -stable.
> ---
> drivers/net/macvtap.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
> index bceca28..7869b06 100644
> --- a/drivers/net/macvtap.c
> +++ b/drivers/net/macvtap.c
> @@ -742,13 +742,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
>
> if (zerocopy)
> err = zerocopy_sg_from_iter(skb, from);
> - else {
> + else
> err = skb_copy_datagram_from_iter(skb, 0, from, len);
> - if (!err && m && m->msg_control) {
> - struct ubuf_info *uarg = m->msg_control;
> - uarg->callback(uarg, false);
> - }
> - }
>
> if (err)
> goto err_kfree;
> @@ -779,7 +774,11 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
> skb_shinfo(skb)->destructor_arg = m->msg_control;
> skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
> skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
> + } else if (m && m->msg_control) {
> + struct ubuf_info *uarg = m->msg_control;
> + uarg->callback(uarg, false);
> }
> +
> if (vlan) {
> skb->dev = vlan->dev;
> dev_queue_xmit(skb);
> --
> 2.7.4
[toc] | [prev] | [next] | [standalone]
| From | "Michael S. Tsirkin" <mst@redhat.com> |
|---|---|
| Date | 2016-11-30 15:00 +0100 |
| Subject | Re: [PATCH net 1/2] tun: handle ubuf refcount correctly when meet erros |
| Message-ID | <sJdAt-6My-7@gated-at.bofh.it> |
| In reply to | #1532957 |
On Wed, Nov 30, 2016 at 01:17:51PM +0800, Jason Wang wrote:
> We trigger uarg->callback() immediately after we decide do datacopy
> even if caller want to do zerocopy. This will cause the callback
> (vhost_net_zerocopy_callback) decrease the refcount. But when we meet
> an error afterwards, the error handling in vhost handle_tx() will try
> to decrease it again. This is wrong and fix this by delay the
> uarg->callback() until we're sure there's no errors.
>
> Reported-by: wangyunjian <wangyunjian@huawei.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> The patch is needed for -stable.
> ---
> drivers/net/tun.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 8093e39..db6acec 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1246,13 +1246,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
>
> if (zerocopy)
> err = zerocopy_sg_from_iter(skb, from);
> - else {
> + else
> err = skb_copy_datagram_from_iter(skb, 0, from, len);
> - if (!err && msg_control) {
> - struct ubuf_info *uarg = msg_control;
> - uarg->callback(uarg, false);
> - }
> - }
>
> if (err) {
> this_cpu_inc(tun->pcpu_stats->rx_dropped);
> @@ -1298,6 +1293,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
> skb_shinfo(skb)->destructor_arg = msg_control;
> skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
> skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
> + } else if (msg_control) {
> + struct ubuf_info *uarg = msg_control;
> + uarg->callback(uarg, false);
> }
>
> skb_reset_network_header(skb);
> --
> 2.7.4
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web