diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2012-11-01 05:16:22 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-02 21:29:57 -0400 |
commit | e19d6763cc300fcb706bd291b24ac06be71e1ce6 (patch) | |
tree | 05608ee69740360480b4c66a368eb21987993058 | |
parent | 202975b4c522c197e4e2269d389aafbf056a4c37 (diff) |
skb: report completion status for zero copy skbs
Even if skb is marked for zero copy, net core might still decide
to copy it later which is somewhat slower than a copy in user context:
besides copying the data we need to pin/unpin the pages.
Add a parameter reporting such cases through zero copy callback:
if this happens a lot, device can take this into account
and switch to copying in user context.
This patch updates all users but ignores the passed value for now:
it will be used by follow-up patches.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/vhost/vhost.c | 2 | ||||
-rw-r--r-- | drivers/vhost/vhost.h | 2 | ||||
-rw-r--r-- | include/linux/skbuff.h | 4 | ||||
-rw-r--r-- | net/core/skbuff.c | 4 |
4 files changed, 7 insertions, 5 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 99ac2cb08b43..73d08db2e677 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c | |||
@@ -1600,7 +1600,7 @@ void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *ubufs) | |||
1600 | kfree(ubufs); | 1600 | kfree(ubufs); |
1601 | } | 1601 | } |
1602 | 1602 | ||
1603 | void vhost_zerocopy_callback(struct ubuf_info *ubuf) | 1603 | void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool status) |
1604 | { | 1604 | { |
1605 | struct vhost_ubuf_ref *ubufs = ubuf->ctx; | 1605 | struct vhost_ubuf_ref *ubufs = ubuf->ctx; |
1606 | struct vhost_virtqueue *vq = ubufs->vq; | 1606 | struct vhost_virtqueue *vq = ubufs->vq; |
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 1125af3d27d1..2de4ce2fec40 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h | |||
@@ -191,7 +191,7 @@ bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *); | |||
191 | 191 | ||
192 | int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log, | 192 | int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log, |
193 | unsigned int log_num, u64 len); | 193 | unsigned int log_num, u64 len); |
194 | void vhost_zerocopy_callback(struct ubuf_info *); | 194 | void vhost_zerocopy_callback(struct ubuf_info *, bool); |
195 | int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq); | 195 | int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq); |
196 | 196 | ||
197 | #define vq_err(vq, fmt, ...) do { \ | 197 | #define vq_err(vq, fmt, ...) do { \ |
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index a2a0bdb95a8f..e5eae5bc1d4d 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -235,11 +235,13 @@ enum { | |||
235 | /* | 235 | /* |
236 | * The callback notifies userspace to release buffers when skb DMA is done in | 236 | * The callback notifies userspace to release buffers when skb DMA is done in |
237 | * lower device, the skb last reference should be 0 when calling this. | 237 | * lower device, the skb last reference should be 0 when calling this. |
238 | * The zerocopy_success argument is true if zero copy transmit occurred, | ||
239 | * false on data copy or out of memory error caused by data copy attempt. | ||
238 | * The ctx field is used to track device context. | 240 | * The ctx field is used to track device context. |
239 | * The desc field is used to track userspace buffer index. | 241 | * The desc field is used to track userspace buffer index. |
240 | */ | 242 | */ |
241 | struct ubuf_info { | 243 | struct ubuf_info { |
242 | void (*callback)(struct ubuf_info *); | 244 | void (*callback)(struct ubuf_info *, bool zerocopy_success); |
243 | void *ctx; | 245 | void *ctx; |
244 | unsigned long desc; | 246 | unsigned long desc; |
245 | }; | 247 | }; |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 6e04b1fa11f2..4abdf71a23f8 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -519,7 +519,7 @@ static void skb_release_data(struct sk_buff *skb) | |||
519 | 519 | ||
520 | uarg = skb_shinfo(skb)->destructor_arg; | 520 | uarg = skb_shinfo(skb)->destructor_arg; |
521 | if (uarg->callback) | 521 | if (uarg->callback) |
522 | uarg->callback(uarg); | 522 | uarg->callback(uarg, true); |
523 | } | 523 | } |
524 | 524 | ||
525 | if (skb_has_frag_list(skb)) | 525 | if (skb_has_frag_list(skb)) |
@@ -797,7 +797,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) | |||
797 | for (i = 0; i < num_frags; i++) | 797 | for (i = 0; i < num_frags; i++) |
798 | skb_frag_unref(skb, i); | 798 | skb_frag_unref(skb, i); |
799 | 799 | ||
800 | uarg->callback(uarg); | 800 | uarg->callback(uarg, false); |
801 | 801 | ||
802 | /* skb frags point to kernel buffers */ | 802 | /* skb frags point to kernel buffers */ |
803 | for (i = num_frags - 1; i >= 0; i--) { | 803 | for (i = num_frags - 1; i >= 0; i--) { |