* alloc skb based on a given data buffer [not found] ` <20090914130612.GA11778@csn.ul.ie> @ 2009-09-15 8:30 ` Zhu Yi 2009-09-15 8:33 ` David Miller 0 siblings, 1 reply; 8+ messages in thread From: Zhu Yi @ 2009-09-15 8:30 UTC (permalink / raw) To: Mel Gorman Cc: Chatre, Reinette, Frans Pop, Larry Finger, John W. Linville, Pekka Enberg, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, ipw3945-devel@lists.sourceforge.net, Andrew Morton, cl@linux-foundation.org, Krauss, Assaf, Johannes Berg, Abbas, Mohamed, netdev [ Cc netdev and change the subject ] On Mon, 2009-09-14 at 21:06 +0800, Mel Gorman wrote: > > Essentially, the hardware only requires an order-1 allocation aligned on > > 256 bytes boundary. But as it is used as an SKB, a trailing struct > > skb_shared_info is added. This forces us to both increase the order and > > do alignment ourselves. I believe some improvement could be done here. > > But it should not be an easy one. > > > > Probably not. I can only assume that moving the location of > skb_shared_info such that it is sometimes located after the buffer and > sometimes allocated via a separate kmalloc() would be a significant > undertaking. Shall I propose below function as a variant to alloc_skb()? struct sk_buff *alloc_skb_attach_buff(void *data_buff, unsigned int real_size, unsigned int size, gfp_t mask); If real_size >= size + sizeof(struct skb_shared_info), we can still put the shinfo at the end of the buffer. Otherwise we can allocate from a new slab that put sk_buff and shinfo together. Of course, kfree_skbmem() needs to recognize it. This way, device drivers can allocate the Rx buffers with their own size and alignment requirement. i.e. do an order-1 page allocation directly with free_pages() in the iwlagn driver for a 256 bytes aligned 8K Rx buffer. After DMA is finished, drivers can use the above function to assemble an skb based on the Rx buffer. It should resolve the problem for requiring an order-2 allocation by alloc_skb() in the first place. Comments are welcome. Thanks, -yi ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: alloc skb based on a given data buffer 2009-09-15 8:30 ` alloc skb based on a given data buffer Zhu Yi @ 2009-09-15 8:33 ` David Miller 2009-09-15 8:57 ` Zhu Yi 0 siblings, 1 reply; 8+ messages in thread From: David Miller @ 2009-09-15 8:33 UTC (permalink / raw) To: yi.zhu-ral2JQCrhuEAvxtiuMwx3w Cc: mel-wPRd99KPJ+uzQB+pC5nmwQ, reinette.chatre-ral2JQCrhuEAvxtiuMwx3w, elendil-EIBgga6/0yRmR6Xm/wNWPw, Larry.Finger-tQ5ms3gMjBLk1uMJSBkQmQ, linville-2XuSBdqkA4R54TAoqtyWWQ, penberg-bbCR+/B0CizivPeTLB3BmA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-wireless-u79uwXL29TY76Z2rM5mHXA, ipw3945-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b, cl-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b, assaf.krauss-ral2JQCrhuEAvxtiuMwx3w, johannes-cdvu00un1VgdHxzADdlk8Q, mohamed.abbas-ral2JQCrhuEAvxtiuMwx3w, netdev-u79uwXL29TY76Z2rM5mHXA From: Zhu Yi <yi.zhu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> Date: Tue, 15 Sep 2009 16:30:20 +0800 > This way, device drivers can allocate the Rx buffers with their own size > and alignment requirement. i.e. do an order-1 page allocation directly > with free_pages() in the iwlagn driver for a 256 bytes aligned 8K Rx > buffer. After DMA is finished, drivers can use the above function to > assemble an skb based on the Rx buffer. It should resolve the problem > for requiring an order-2 allocation by alloc_skb() in the first place. You can create paged RX skbs just like drivers such as niu.c and others already do, there is no need for special APIs for this. -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: alloc skb based on a given data buffer 2009-09-15 8:33 ` David Miller @ 2009-09-15 8:57 ` Zhu Yi 2009-09-15 9:09 ` David Miller 0 siblings, 1 reply; 8+ messages in thread From: Zhu Yi @ 2009-09-15 8:57 UTC (permalink / raw) To: David Miller Cc: mel@csn.ul.ie, Chatre, Reinette, elendil@planet.nl, Larry.Finger@lwfinger.net, linville@tuxdriver.com, penberg@cs.helsinki.fi, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, ipw3945-devel@lists.sourceforge.net, akpm@linux-foundation.org, cl@linux-foundation.org, Krauss, Assaf, johannes@sipsolutions.net, Abbas, Mohamed, netdev@vger.kernel.org On Tue, 2009-09-15 at 16:33 +0800, David Miller wrote: > From: Zhu Yi <yi.zhu@intel.com> > Date: Tue, 15 Sep 2009 16:30:20 +0800 > > > This way, device drivers can allocate the Rx buffers with their own size > > and alignment requirement. i.e. do an order-1 page allocation directly > > with free_pages() in the iwlagn driver for a 256 bytes aligned 8K Rx > > buffer. After DMA is finished, drivers can use the above function to > > assemble an skb based on the Rx buffer. It should resolve the problem > > for requiring an order-2 allocation by alloc_skb() in the first place. > > You can create paged RX skbs just like drivers such as niu.c > and others already do, there is no need for special APIs for > this. Thanks. So we can put the 8K buffer into 2 skb_shinfo()->frags[] slots and set nr_frags to 2, right? Is this supported allover the network code already? At a first glance, I didn't find any frags handling in mac80211 stack. Thanks, -yi ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: alloc skb based on a given data buffer 2009-09-15 8:57 ` Zhu Yi @ 2009-09-15 9:09 ` David Miller 2009-09-15 9:15 ` Zhu Yi 0 siblings, 1 reply; 8+ messages in thread From: David Miller @ 2009-09-15 9:09 UTC (permalink / raw) To: yi.zhu Cc: mel, reinette.chatre, elendil, Larry.Finger, linville, penberg, linux-kernel, linux-wireless, ipw3945-devel, akpm, cl, assaf.krauss, johannes, mohamed.abbas, netdev From: Zhu Yi <yi.zhu@intel.com> Date: Tue, 15 Sep 2009 16:57:29 +0800 > Thanks. So we can put the 8K buffer into 2 skb_shinfo()->frags[] slots > and set nr_frags to 2, right? Is this supported allover the network code > already? At a first glance, I didn't find any frags handling in mac80211 > stack. You have to pre-pull the link level protocol headers into the linear area, but that's it. Again, see niu.c for details, it does: static void niu_rx_skb_append(struct sk_buff *skb, struct page *page, u32 offset, u32 size) { int i = skb_shinfo(skb)->nr_frags; skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; frag->page = page; frag->page_offset = offset; frag->size = size; skb->len += size; skb->data_len += size; skb->truesize += size; skb_shinfo(skb)->nr_frags = i + 1; } to add pages to SKBs and then at the end it goes: skb_reserve(skb, NET_IP_ALIGN); __pskb_pull_tail(skb, min(len, NIU_RXPULL_MAX)); Right before giving the SKB to the networking stack. NIU_RXPULL_MAX should be a value that will be large enough to cover the largest possible link level header. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: alloc skb based on a given data buffer 2009-09-15 9:09 ` David Miller @ 2009-09-15 9:15 ` Zhu Yi 2009-09-15 15:30 ` Johannes Berg 0 siblings, 1 reply; 8+ messages in thread From: Zhu Yi @ 2009-09-15 9:15 UTC (permalink / raw) To: David Miller Cc: mel@csn.ul.ie, Chatre, Reinette, elendil@planet.nl, Larry.Finger@lwfinger.net, linville@tuxdriver.com, penberg@cs.helsinki.fi, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, ipw3945-devel@lists.sourceforge.net, akpm@linux-foundation.org, cl@linux-foundation.org, Krauss, Assaf, johannes@sipsolutions.net, Abbas, Mohamed, netdev@vger.kernel.org On Tue, 2009-09-15 at 17:09 +0800, David Miller wrote: > From: Zhu Yi <yi.zhu@intel.com> > Date: Tue, 15 Sep 2009 16:57:29 +0800 > > > Thanks. So we can put the 8K buffer into 2 skb_shinfo()->frags[] slots > > and set nr_frags to 2, right? Is this supported allover the network code > > already? At a first glance, I didn't find any frags handling in mac80211 > > stack. > > You have to pre-pull the link level protocol headers into the > linear area, but that's it. > > Again, see niu.c for details, it does: > > static void niu_rx_skb_append(struct sk_buff *skb, struct page *page, > u32 offset, u32 size) > { > int i = skb_shinfo(skb)->nr_frags; > skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; > > frag->page = page; > frag->page_offset = offset; > frag->size = size; > > skb->len += size; > skb->data_len += size; > skb->truesize += size; > > skb_shinfo(skb)->nr_frags = i + 1; > } > > to add pages to SKBs and then at the end it goes: > > skb_reserve(skb, NET_IP_ALIGN); > __pskb_pull_tail(skb, min(len, NIU_RXPULL_MAX)); > > Right before giving the SKB to the networking stack. NIU_RXPULL_MAX > should be a value that will be large enough to cover the largest > possible link level header. I see. Thanks for this info. I'll try implementing the same for iwlagn. Thanks, -yi ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: alloc skb based on a given data buffer 2009-09-15 9:15 ` Zhu Yi @ 2009-09-15 15:30 ` Johannes Berg [not found] ` <1253028631.23427.55.camel-YfaajirXv2244ywRPIzf9A@public.gmane.org> 0 siblings, 1 reply; 8+ messages in thread From: Johannes Berg @ 2009-09-15 15:30 UTC (permalink / raw) To: Zhu Yi Cc: David Miller, mel-wPRd99KPJ+uzQB+pC5nmwQ@public.gmane.org, Chatre, Reinette, elendil-EIBgga6/0yRmR6Xm/wNWPw@public.gmane.org, Larry.Finger-tQ5ms3gMjBLk1uMJSBkQmQ@public.gmane.org, linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org, penberg-bbCR+/B0CizivPeTLB3BmA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, ipw3945-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, cl-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, Krauss, Assaf, Abbas, Mohamed, netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org [-- Attachment #1: Type: text/plain, Size: 1611 bytes --] On Tue, 2009-09-15 at 17:15 +0800, Zhu Yi wrote: > On Tue, 2009-09-15 at 17:09 +0800, David Miller wrote: > > From: Zhu Yi <yi.zhu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > > Date: Tue, 15 Sep 2009 16:57:29 +0800 > > > > > Thanks. So we can put the 8K buffer into 2 skb_shinfo()->frags[] slots > > > and set nr_frags to 2, right? Is this supported allover the network code > > > already? At a first glance, I didn't find any frags handling in mac80211 > > > stack. > > > > You have to pre-pull the link level protocol headers into the > > linear area, but that's it. > > > > Again, see niu.c for details, it does: > > > > static void niu_rx_skb_append(struct sk_buff *skb, struct page *page, > > u32 offset, u32 size) > > { > > int i = skb_shinfo(skb)->nr_frags; > > skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; > > > > frag->page = page; > > frag->page_offset = offset; > > frag->size = size; > > > > skb->len += size; > > skb->data_len += size; > > skb->truesize += size; > > > > skb_shinfo(skb)->nr_frags = i + 1; > > } > > > > to add pages to SKBs and then at the end it goes: > > > > skb_reserve(skb, NET_IP_ALIGN); > > __pskb_pull_tail(skb, min(len, NIU_RXPULL_MAX)); > > > > Right before giving the SKB to the networking stack. NIU_RXPULL_MAX > > should be a value that will be large enough to cover the largest > > possible link level header. > > I see. Thanks for this info. I'll try implementing the same for iwlagn. Hold, mac80211 can't cope with that at this point for sw crypto and possibly other things. johannes [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 801 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <1253028631.23427.55.camel-YfaajirXv2244ywRPIzf9A@public.gmane.org>]
* Re: alloc skb based on a given data buffer [not found] ` <1253028631.23427.55.camel-YfaajirXv2244ywRPIzf9A@public.gmane.org> @ 2009-09-15 21:16 ` David Miller 2009-09-19 5:56 ` Johannes Berg 0 siblings, 1 reply; 8+ messages in thread From: David Miller @ 2009-09-15 21:16 UTC (permalink / raw) To: johannes-cdvu00un1VgdHxzADdlk8Q Cc: yi.zhu-ral2JQCrhuEAvxtiuMwx3w, mel-wPRd99KPJ+uzQB+pC5nmwQ, reinette.chatre-ral2JQCrhuEAvxtiuMwx3w, elendil-EIBgga6/0yRmR6Xm/wNWPw, Larry.Finger-tQ5ms3gMjBLk1uMJSBkQmQ, linville-2XuSBdqkA4R54TAoqtyWWQ, penberg-bbCR+/B0CizivPeTLB3BmA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-wireless-u79uwXL29TY76Z2rM5mHXA, ipw3945-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b, cl-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b, assaf.krauss-ral2JQCrhuEAvxtiuMwx3w, mohamed.abbas-ral2JQCrhuEAvxtiuMwx3w, netdev-u79uwXL29TY76Z2rM5mHXA From: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org> Date: Tue, 15 Sep 2009 08:30:31 -0700 > Hold, mac80211 can't cope with that at this point for sw crypto and > possibly other things. Then it should skb_linearize() at input, or similar. -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: alloc skb based on a given data buffer 2009-09-15 21:16 ` David Miller @ 2009-09-19 5:56 ` Johannes Berg 0 siblings, 0 replies; 8+ messages in thread From: Johannes Berg @ 2009-09-19 5:56 UTC (permalink / raw) To: David Miller Cc: yi.zhu, mel, reinette.chatre, elendil, Larry.Finger, linville, penberg, linux-kernel, linux-wireless, ipw3945-devel, akpm, cl, assaf.krauss, mohamed.abbas, netdev [-- Attachment #1: Type: text/plain, Size: 473 bytes --] On Tue, 2009-09-15 at 14:16 -0700, David Miller wrote: > From: Johannes Berg <johannes@sipsolutions.net> > Date: Tue, 15 Sep 2009 08:30:31 -0700 > > > Hold, mac80211 can't cope with that at this point for sw crypto and > > possibly other things. > > Then it should skb_linearize() at input, or similar. Not all that much won then since that again means an order-2 allocation. Fewer, certainly, as most packets are actually much smaller than that. johannes [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 801 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-09-19 5:56 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <200909060941.01810.elendil@planet.nl> [not found] ` <4AA67139.80301@lwfinger.net> [not found] ` <20090909150418.GI24614@csn.ul.ie> [not found] ` <200909091759.33655.elendil@planet.nl> [not found] ` <20090909165545.GK24614@csn.ul.ie> [not found] ` <1252526738.30150.91.camel@rc-desk> [not found] ` <20090910090206.GA22276@csn.ul.ie> [not found] ` <1252617290.30150.321.camel@rc-desk> [not found] ` <20090911084717.GB32497@csn.ul.ie> [not found] ` <1252897270.5650.169.camel@debian> [not found] ` <20090914130612.GA11778@csn.ul.ie> 2009-09-15 8:30 ` alloc skb based on a given data buffer Zhu Yi 2009-09-15 8:33 ` David Miller 2009-09-15 8:57 ` Zhu Yi 2009-09-15 9:09 ` David Miller 2009-09-15 9:15 ` Zhu Yi 2009-09-15 15:30 ` Johannes Berg [not found] ` <1253028631.23427.55.camel-YfaajirXv2244ywRPIzf9A@public.gmane.org> 2009-09-15 21:16 ` David Miller 2009-09-19 5:56 ` Johannes Berg
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).