Re: [PATCH] tcp: splice as many packets as possible at once

From: Willy Tarreau
Date: Thu Jan 15 2009 - 18:33:44 EST


On Fri, Jan 16, 2009 at 10:19:35AM +1100, Herbert Xu wrote:
> On Fri, Jan 16, 2009 at 12:03:31AM +0100, Willy Tarreau wrote:
> >
> > I'm leaving the patch below for comments, maybe someone will spot
> > something ? Don't we need at least one kfree() somewhere to match
> > alloc_pages() ?
>
> Indeed.
>
> > > static inline int spd_fill_page(struct splice_pipe_desc *spd, struct page *page,
> > > unsigned int len, unsigned int offset,
> > > - struct sk_buff *skb)
> > > + struct sk_buff *skb, int linear)
> > > {
> > > if (unlikely(spd->nr_pages == PIPE_BUFFERS))
> > > return 1;
> > >
> > > + if (linear) {
> > > + page = linear_to_page(page, len, offset);
> > > + if (!page)
> > > + return 1;
> > > + }
> > > +
> > > spd->pages[spd->nr_pages] = page;
> > > spd->partial[spd->nr_pages].len = len;
> > > spd->partial[spd->nr_pages].offset = offset;
> > > - spd->partial[spd->nr_pages].private = (unsigned long) skb_get(skb);
> > > spd->nr_pages++;
> > > + get_page(page);
>
> This get_page needs to be moved into an else clause of the previous
> if block.

Good catch Herbert, it's working fine now. The performance I get
(30.6 MB/s) is between the original splice version (24.1) and the
recently optimized one (35.7). That's not that bad considering
we're copying the data.

Cheers,
Willy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/