netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: fix comment above build_skb()
@ 2013-07-23 15:39 Florian Fainelli
  2013-07-23 15:49 ` Eric Dumazet
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Fainelli @ 2013-07-23 15:39 UTC (permalink / raw)
  To: davem; +Cc: eric.dumazet, netdev, Florian Fainelli

build_skb() specifies that the data parameter must come from a kmalloc'd
area, this is only true if frag_size equals 0, because then build_skb()
will use kzsize(data) to figure out the actual data size. Update the
comment to reflect that special condition.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 net/core/skbuff.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 20e02d2..d3174db 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -309,7 +309,8 @@ EXPORT_SYMBOL(__alloc_skb);
  * @frag_size: size of fragment, or 0 if head was kmalloced
  *
  * Allocate a new &sk_buff. Caller provides space holding head and
- * skb_shared_info. @data must have been allocated by kmalloc()
+ * skb_shared_info. @data must have been allocated by kmalloc() only if
+ * @frag_size is 0.
  * The return is the new skb buffer.
  * On a failure the return is %NULL, and @data is not freed.
  * Notes :
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: fix comment above build_skb()
  2013-07-23 15:39 [PATCH] net: fix comment above build_skb() Florian Fainelli
@ 2013-07-23 15:49 ` Eric Dumazet
  2013-07-23 18:04   ` Florian Fainelli
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2013-07-23 15:49 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: davem, netdev

On Tue, 2013-07-23 at 16:39 +0100, Florian Fainelli wrote:
> build_skb() specifies that the data parameter must come from a kmalloc'd
> area, this is only true if frag_size equals 0, because then build_skb()
> will use kzsize(data) to figure out the actual data size. Update the
> comment to reflect that special condition.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  net/core/skbuff.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 20e02d2..d3174db 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -309,7 +309,8 @@ EXPORT_SYMBOL(__alloc_skb);
>   * @frag_size: size of fragment, or 0 if head was kmalloced
>   *
>   * Allocate a new &sk_buff. Caller provides space holding head and
> - * skb_shared_info. @data must have been allocated by kmalloc()
> + * skb_shared_info. @data must have been allocated by kmalloc() only if
> + * @frag_size is 0.
>   * The return is the new skb buffer.
>   * On a failure the return is %NULL, and @data is not freed.
>   * Notes :

Hmm, why not explaining the other case ? (frag_size > 0)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: fix comment above build_skb()
  2013-07-23 15:49 ` Eric Dumazet
@ 2013-07-23 18:04   ` Florian Fainelli
  2013-07-23 18:46     ` Ben Hutchings
  2013-07-23 18:54     ` Eric Dumazet
  0 siblings, 2 replies; 5+ messages in thread
From: Florian Fainelli @ 2013-07-23 18:04 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev

2013/7/23 Eric Dumazet <eric.dumazet@gmail.com>:
> On Tue, 2013-07-23 at 16:39 +0100, Florian Fainelli wrote:
>> build_skb() specifies that the data parameter must come from a kmalloc'd
>> area, this is only true if frag_size equals 0, because then build_skb()
>> will use kzsize(data) to figure out the actual data size. Update the
>> comment to reflect that special condition.
>>
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>> ---
>>  net/core/skbuff.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
>> index 20e02d2..d3174db 100644
>> --- a/net/core/skbuff.c
>> +++ b/net/core/skbuff.c
>> @@ -309,7 +309,8 @@ EXPORT_SYMBOL(__alloc_skb);
>>   * @frag_size: size of fragment, or 0 if head was kmalloced
>>   *
>>   * Allocate a new &sk_buff. Caller provides space holding head and
>> - * skb_shared_info. @data must have been allocated by kmalloc()
>> + * skb_shared_info. @data must have been allocated by kmalloc() only if
>> + * @frag_size is 0.
>>   * The return is the new skb buffer.
>>   * On a failure the return is %NULL, and @data is not freed.
>>   * Notes :
>
> Hmm, why not explaining the other case ? (frag_size > 0)

Sure, would something like:

"@data must have been allocated by kmalloc() if frag_size is 0,
otherwise any data buffer (vmalloc, DMA..) is suitable"

work for you?
--
Florian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: fix comment above build_skb()
  2013-07-23 18:04   ` Florian Fainelli
@ 2013-07-23 18:46     ` Ben Hutchings
  2013-07-23 18:54     ` Eric Dumazet
  1 sibling, 0 replies; 5+ messages in thread
From: Ben Hutchings @ 2013-07-23 18:46 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: Eric Dumazet, David Miller, netdev

On Tue, 2013-07-23 at 19:04 +0100, Florian Fainelli wrote:
> 2013/7/23 Eric Dumazet <eric.dumazet@gmail.com>:
> > On Tue, 2013-07-23 at 16:39 +0100, Florian Fainelli wrote:
> >> build_skb() specifies that the data parameter must come from a kmalloc'd
> >> area, this is only true if frag_size equals 0, because then build_skb()
> >> will use kzsize(data) to figure out the actual data size. Update the
> >> comment to reflect that special condition.
> >>
> >> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> >> ---
> >>  net/core/skbuff.c | 3 ++-
> >>  1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> >> index 20e02d2..d3174db 100644
> >> --- a/net/core/skbuff.c
> >> +++ b/net/core/skbuff.c
> >> @@ -309,7 +309,8 @@ EXPORT_SYMBOL(__alloc_skb);
> >>   * @frag_size: size of fragment, or 0 if head was kmalloced
> >>   *
> >>   * Allocate a new &sk_buff. Caller provides space holding head and
> >> - * skb_shared_info. @data must have been allocated by kmalloc()
> >> + * skb_shared_info. @data must have been allocated by kmalloc() only if
> >> + * @frag_size is 0.
> >>   * The return is the new skb buffer.
> >>   * On a failure the return is %NULL, and @data is not freed.
> >>   * Notes :
> >
> > Hmm, why not explaining the other case ? (frag_size > 0)
> 
> Sure, would something like:
> 
> "@data must have been allocated by kmalloc() if frag_size is 0,
> otherwise any data buffer (vmalloc, DMA..) is suitable"

The other case is that the buffer must have been allocated using the
page allocator directly.  It will be freed using
put_page(virt_to_head_page(data)).

Using vmalloc() to allocate the buffer would definitely be incorrect.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: fix comment above build_skb()
  2013-07-23 18:04   ` Florian Fainelli
  2013-07-23 18:46     ` Ben Hutchings
@ 2013-07-23 18:54     ` Eric Dumazet
  1 sibling, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2013-07-23 18:54 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: David Miller, netdev

On Tue, 2013-07-23 at 19:04 +0100, Florian Fainelli wrote:

> Sure, would something like:
> 
> "@data must have been allocated by kmalloc() if frag_size is 0,
> otherwise any data buffer (vmalloc, DMA..) is suitable"
> 

Actually not, the other case must be a page frag, because we are going
to use get_page() and put_page() during skb lifetime.

netlink case is really special/hacky, because it makes sure those
get_page()/put_page() calls wont ever happen.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-07-23 18:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-23 15:39 [PATCH] net: fix comment above build_skb() Florian Fainelli
2013-07-23 15:49 ` Eric Dumazet
2013-07-23 18:04   ` Florian Fainelli
2013-07-23 18:46     ` Ben Hutchings
2013-07-23 18:54     ` Eric Dumazet

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).