linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/fq_impl: Switch to kvmalloc() for memory allocation
@ 2019-11-05 15:49 Toke Høiland-Jørgensen
  2019-11-05 15:51 ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Toke Høiland-Jørgensen @ 2019-11-05 15:49 UTC (permalink / raw)
  To: linux-wireless; +Cc: Toke Høiland-Jørgensen, Johannes Berg

The FQ implementation used by mac80211 allocates memory using kmalloc(),
which can fail; and Johannes reported that this actually happens in
practice.

To avoid this, switch the allocation to kvmalloc() instead; this also
brings fq_impl in line with all the FQ qdiscs.

Fixes: 557fc4a09803 ("fq: add fair queuing framework")
Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 include/net/fq_impl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/fq_impl.h b/include/net/fq_impl.h
index 107c0d700ed6..d3873db91c71 100644
--- a/include/net/fq_impl.h
+++ b/include/net/fq_impl.h
@@ -313,7 +313,7 @@ static int fq_init(struct fq *fq, int flows_cnt)
 	fq->limit = 8192;
 	fq->memory_limit = 16 << 20; /* 16 MBytes */
 
-	fq->flows = kcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL);
+	fq->flows = kvcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL);
 	if (!fq->flows)
 		return -ENOMEM;
 
-- 
2.23.0


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

* Re: [PATCH] net/fq_impl: Switch to kvmalloc() for memory allocation
  2019-11-05 15:49 [PATCH] net/fq_impl: Switch to kvmalloc() for memory allocation Toke Høiland-Jørgensen
@ 2019-11-05 15:51 ` Johannes Berg
  2019-11-05 15:56   ` Toke Høiland-Jørgensen
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2019-11-05 15:51 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, linux-wireless

On Tue, 2019-11-05 at 16:49 +0100, Toke Høiland-Jørgensen wrote:
> The FQ implementation used by mac80211 allocates memory using kmalloc(),
> which can fail; and Johannes reported that this actually happens in
> practice.
> 
> To avoid this, switch the allocation to kvmalloc() instead; this also
> brings fq_impl in line with all the FQ qdiscs.
> 
> Fixes: 557fc4a09803 ("fq: add fair queuing framework")
> Reported-by: Johannes Berg <johannes@sipsolutions.net>
> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
> ---
>  include/net/fq_impl.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/net/fq_impl.h b/include/net/fq_impl.h
> index 107c0d700ed6..d3873db91c71 100644
> --- a/include/net/fq_impl.h
> +++ b/include/net/fq_impl.h
> @@ -313,7 +313,7 @@ static int fq_init(struct fq *fq, int flows_cnt)
>  	fq->limit = 8192;
>  	fq->memory_limit = 16 << 20; /* 16 MBytes */
>  
> -	fq->flows = kcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL);
> +	fq->flows = kvcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL);

You need a corresponding kvfree(), no?

johannes


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

* Re: [PATCH] net/fq_impl: Switch to kvmalloc() for memory allocation
  2019-11-05 15:51 ` Johannes Berg
@ 2019-11-05 15:56   ` Toke Høiland-Jørgensen
  2019-11-05 15:58     ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Toke Høiland-Jørgensen @ 2019-11-05 15:56 UTC (permalink / raw)
  To: Johannes Berg, linux-wireless

Johannes Berg <johannes@sipsolutions.net> writes:

> On Tue, 2019-11-05 at 16:49 +0100, Toke Høiland-Jørgensen wrote:
>> The FQ implementation used by mac80211 allocates memory using kmalloc(),
>> which can fail; and Johannes reported that this actually happens in
>> practice.
>> 
>> To avoid this, switch the allocation to kvmalloc() instead; this also
>> brings fq_impl in line with all the FQ qdiscs.
>> 
>> Fixes: 557fc4a09803 ("fq: add fair queuing framework")
>> Reported-by: Johannes Berg <johannes@sipsolutions.net>
>> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
>> ---
>>  include/net/fq_impl.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/include/net/fq_impl.h b/include/net/fq_impl.h
>> index 107c0d700ed6..d3873db91c71 100644
>> --- a/include/net/fq_impl.h
>> +++ b/include/net/fq_impl.h
>> @@ -313,7 +313,7 @@ static int fq_init(struct fq *fq, int flows_cnt)
>>  	fq->limit = 8192;
>>  	fq->memory_limit = 16 << 20; /* 16 MBytes */
>>  
>> -	fq->flows = kcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL);
>> +	fq->flows = kvcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL);
>
> You need a corresponding kvfree(), no?

Oh, right, of course; silly me. Guess I was a bit too trigger-happy on
the nice one-character patch ;)

Will send a v2

-Toke


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

* Re: [PATCH] net/fq_impl: Switch to kvmalloc() for memory allocation
  2019-11-05 15:56   ` Toke Høiland-Jørgensen
@ 2019-11-05 15:58     ` Johannes Berg
  2019-11-05 16:08       ` Toke Høiland-Jørgensen
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2019-11-05 15:58 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, linux-wireless

On Tue, 2019-11-05 at 16:56 +0100, Toke Høiland-Jørgensen wrote:
> 
> Oh, right, of course; silly me. Guess I was a bit too trigger-happy on
> the nice one-character patch ;)
> 

I guess two characters is still pretty good ;)

johannes


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

* Re: [PATCH] net/fq_impl: Switch to kvmalloc() for memory allocation
  2019-11-05 15:58     ` Johannes Berg
@ 2019-11-05 16:08       ` Toke Høiland-Jørgensen
  0 siblings, 0 replies; 5+ messages in thread
From: Toke Høiland-Jørgensen @ 2019-11-05 16:08 UTC (permalink / raw)
  To: Johannes Berg, linux-wireless

Johannes Berg <johannes@sipsolutions.net> writes:

> On Tue, 2019-11-05 at 16:56 +0100, Toke Høiland-Jørgensen wrote:
>> 
>> Oh, right, of course; silly me. Guess I was a bit too trigger-happy on
>> the nice one-character patch ;)
>> 
>
> I guess two characters is still pretty good ;)

Hehe, yeah, I can live with that ;)

-Toke


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

end of thread, other threads:[~2019-11-05 16:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05 15:49 [PATCH] net/fq_impl: Switch to kvmalloc() for memory allocation Toke Høiland-Jørgensen
2019-11-05 15:51 ` Johannes Berg
2019-11-05 15:56   ` Toke Høiland-Jørgensen
2019-11-05 15:58     ` Johannes Berg
2019-11-05 16:08       ` Toke Høiland-Jørgensen

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