lkml.org 
[lkml]   [2004]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [6/7] Xen VMM patch set : add alloc_skb_from_cache
    On Fri, 19 Nov 2004, Ian Pratt wrote:

    > + /* Get the DATA. */
    > + size = SKB_DATA_ALIGN(size);
    > + data = kmem_cache_alloc(cp, gfp_mask);
    > + if (!data)
    > + goto nodata;
    > +
    > + memset(skb, 0, offsetof(struct sk_buff, truesize));
    > + skb->truesize = size + sizeof(struct sk_buff);
    > + atomic_set(&skb->users, 1);
    > + skb->head = data;
    > + skb->data = data;
    > + skb->tail = data;
    > + skb->end = data + size;
    > +
    > + atomic_set(&(skb_shinfo(skb)->dataref), 1);
    > + skb_shinfo(skb)->nr_frags = 0;
    > + skb_shinfo(skb)->tso_size = 0;
    > + skb_shinfo(skb)->tso_segs = 0;
    > + skb_shinfo(skb)->frag_list = NULL;
    > +out:
    > + return skb;
    > +nodata:
    > + kmem_cache_free(skbuff_head_cache, skb);
    > + skb = NULL;
    > + goto out;
    > +}
    > +

    Most of this is duplicated code with alloc_skb(), perhaps make a function:

    __alloc_skb(size, gfp_mask, alloc_func)

    Then alloc_skb() and alloc_skb_from_cache() can just be wrappers which
    pass in different alloc_funcs. I'm not sure what peformance impact this
    might have though.

    Thoughts?


    - James
    --
    James Morris
    <jmorris@redhat.com>


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

    \
     
     \ /
      Last update: 2005-03-22 14:08    [W:0.021 / U:91.668 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site