* [PATCH] fix multi-buffer logging with mergeable buffers
@ 2010-05-07 20:11 David L Stevens
2010-05-09 11:10 ` Michael S. Tsirkin
0 siblings, 1 reply; 3+ messages in thread
From: David L Stevens @ 2010-05-07 20:11 UTC (permalink / raw)
To: mst; +Cc: netdev
This patch fixes the multibuffer case of logging with
mergeable buffers.
Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 85519b4..d526b68 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -236,8 +236,9 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
int seg = 0;
int headcount = 0;
unsigned d;
- int r;
+ int r, nlogs;
+ nlogs = 0;
while (datalen > 0) {
if (unlikely(headcount >= VHOST_NET_MAX_SG)) {
r = -ENOBUFS;
@@ -245,7 +246,8 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
}
d = vhost_get_desc(vq->dev, vq, vq->iov + seg,
ARRAY_SIZE(vq->iov) - seg, &out,
- &in, log, log_num);
+ &in, log+nlogs, log_num);
+ nlogs += log ? *log_num : 0;
if (d == vq->num) {
r = 0;
goto err;
@@ -263,6 +265,8 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
seg += in;
}
*iovcount = seg;
+ if (unlikely(log))
+ *log_num = nlogs;
return headcount;
err:
vhost_discard_desc(vq, headcount);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fix multi-buffer logging with mergeable buffers
2010-05-07 20:11 [PATCH] fix multi-buffer logging with mergeable buffers David L Stevens
@ 2010-05-09 11:10 ` Michael S. Tsirkin
2010-05-09 15:46 ` David Stevens
0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2010-05-09 11:10 UTC (permalink / raw)
To: David L Stevens; +Cc: netdev
On Fri, May 07, 2010 at 01:11:08PM -0700, David L Stevens wrote:
> This patch fixes the multibuffer case of logging with
> mergeable buffers.
>
> Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
So, I folded this into your original patch submission,
this way we don't get broken logging followed
by a fix (better for bisect). Further, I think it's better to only use log_num
on success. After fixing whitespace (+ needs space around it:
didn't checkpatch complain?) I merged the below,
and rebased my tweaks patch on top.
The result can be found here:
git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost-mrg-rxbuf
Compiles fine but I'm a bit busy with other things,
and didn't test at all yet, I'd appreciate testing and reports.
--
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 8ef5e3f..1964ab0 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -877,7 +877,7 @@ int vhost_get_desc_n(struct vhost_virtqueue *vq, struct vring_used_elem *heads,
unsigned int out, in;
int seg = 0;
int headcount = 0;
- int r;
+ int r, nlogs = 0;
while (datalen > 0) {
if (headcount >= VHOST_NET_MAX_SG) {
@@ -897,12 +897,18 @@ int vhost_get_desc_n(struct vhost_virtqueue *vq, struct vring_used_elem *heads,
r = -EINVAL;
goto err;
}
+ if (unlikely(log)) {
+ nlogs += *log_num;
+ log += *log_num;
+ }
heads[headcount].len = iov_length(vq->iov + seg, in);
datalen -= heads[headcount].len;
++headcount;
seg += in;
}
*iovcount = seg;
+ if (unlikely(log))
+ *log_num = nlogs;
return headcount;
err:
vhost_discard_desc(vq, headcount);
--
MST
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fix multi-buffer logging with mergeable buffers
2010-05-09 11:10 ` Michael S. Tsirkin
@ 2010-05-09 15:46 ` David Stevens
0 siblings, 0 replies; 3+ messages in thread
From: David Stevens @ 2010-05-09 15:46 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: netdev
"Michael S. Tsirkin" <mst@redhat.com> wrote on 05/09/2010 04:10:16 AM:
> On Fri, May 07, 2010 at 01:11:08PM -0700, David L Stevens wrote:
> > This patch fixes the multibuffer case of logging with
> > mergeable buffers.
> >
> > Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
>
> So, I folded this into your original patch submission,
> this way we don't get broken logging followed
> by a fix (better for bisect). Further, I think it's better to only use
log_num
> on success. After fixing whitespace (+ needs space around it:
> didn't checkpatch complain?) I merged the below,
> and rebased my tweaks patch on top.
>
> The result can be found here:
> git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git
vhost-mrg-rxbuf
>
> Compiles fine but I'm a bit busy with other things,
> and didn't test at all yet, I'd appreciate testing and reports.
Looks good, and works. Thanks!
+-DLS
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-09 15:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-07 20:11 [PATCH] fix multi-buffer logging with mergeable buffers David L Stevens
2010-05-09 11:10 ` Michael S. Tsirkin
2010-05-09 15:46 ` David Stevens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).