All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhou Jie <zhoujie2011@cn.fujitsu.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>, <qemu-devel@nongnu.org>
Cc: <qemu-trivial@nongnu.org>, <jasowang@redhat.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] net/tap: Allocating Large sized arrays to heap
Date: Tue, 26 Apr 2016 16:26:18 +0800	[thread overview]
Message-ID: <571F262A.3020705@cn.fujitsu.com> (raw)
In-Reply-To: <571F1CA4.70306@de.ibm.com>

On 2016/4/26 15:45, Christian Borntraeger wrote:
> On 04/26/2016 03:26 AM, Zhou Jie wrote:
>> net_init_tap has a huge stack usage of 8192 bytes approx.
>> Moving large arrays to heap to reduce stack usage.
>
> I am wondering. Why is 8k a problem for a user space program?
For 64bit machine it will be 16k.

> Please note that malloc/new like allocations are much more expensive
> than stack allocation in terms of performance. This does not matter
> here, but in your other patch that deals with the xmit function, I would
> not be surprised if that actually harms performance.
OK. I will note it.

Sincerely,
Zhou Jie

>
> Christian
>
>
>
>>
>> Signed-off-by: Zhou Jie <zhoujie2011@cn.fujitsu.com>
>> ---
>>   net/tap.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/tap.c b/net/tap.c
>> index 740e8a2..49817c7 100644
>> --- a/net/tap.c
>> +++ b/net/tap.c
>> @@ -769,8 +769,8 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
>>               return -1;
>>           }
>>       } else if (tap->has_fds) {
>> -        char *fds[MAX_TAP_QUEUES];
>> -        char *vhost_fds[MAX_TAP_QUEUES];
>> +        char **fds = g_new(char *, MAX_TAP_QUEUES);
>> +        char **vhost_fds = g_new(char *, MAX_TAP_QUEUES);
>>           int nfds, nvhosts;
>>
>>           if (tap->has_ifname || tap->has_script || tap->has_downscript ||
>> @@ -818,6 +818,8 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
>>                   return -1;
>>               }
>>           }
>> +        g_free(fds);
>> +        g_free(vhost_fds);
>>       } else if (tap->has_helper) {
>>           if (tap->has_ifname || tap->has_script || tap->has_downscript ||
>>               tap->has_vnet_hdr || tap->has_queues || tap->has_vhostfds) {
>>
>
>
>
>

-- 
------------------------------------------------
周潔
Dept 1
No. 6 Wenzhu Road,
Nanjing, 210012, China
TEL:+86+25-86630566-8557
FUJITSU INTERNAL:7998-8557
E-Mail:zhoujie2011@cn.fujitsu.com
------------------------------------------------




WARNING: multiple messages have this Message-ID (diff)
From: Zhou Jie <zhoujie2011@cn.fujitsu.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, jasowang@redhat.com
Subject: Re: [Qemu-devel] [PATCH] net/tap: Allocating Large sized arrays to heap
Date: Tue, 26 Apr 2016 16:26:18 +0800	[thread overview]
Message-ID: <571F262A.3020705@cn.fujitsu.com> (raw)
In-Reply-To: <571F1CA4.70306@de.ibm.com>

On 2016/4/26 15:45, Christian Borntraeger wrote:
> On 04/26/2016 03:26 AM, Zhou Jie wrote:
>> net_init_tap has a huge stack usage of 8192 bytes approx.
>> Moving large arrays to heap to reduce stack usage.
>
> I am wondering. Why is 8k a problem for a user space program?
For 64bit machine it will be 16k.

> Please note that malloc/new like allocations are much more expensive
> than stack allocation in terms of performance. This does not matter
> here, but in your other patch that deals with the xmit function, I would
> not be surprised if that actually harms performance.
OK. I will note it.

Sincerely,
Zhou Jie

>
> Christian
>
>
>
>>
>> Signed-off-by: Zhou Jie <zhoujie2011@cn.fujitsu.com>
>> ---
>>   net/tap.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/tap.c b/net/tap.c
>> index 740e8a2..49817c7 100644
>> --- a/net/tap.c
>> +++ b/net/tap.c
>> @@ -769,8 +769,8 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
>>               return -1;
>>           }
>>       } else if (tap->has_fds) {
>> -        char *fds[MAX_TAP_QUEUES];
>> -        char *vhost_fds[MAX_TAP_QUEUES];
>> +        char **fds = g_new(char *, MAX_TAP_QUEUES);
>> +        char **vhost_fds = g_new(char *, MAX_TAP_QUEUES);
>>           int nfds, nvhosts;
>>
>>           if (tap->has_ifname || tap->has_script || tap->has_downscript ||
>> @@ -818,6 +818,8 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
>>                   return -1;
>>               }
>>           }
>> +        g_free(fds);
>> +        g_free(vhost_fds);
>>       } else if (tap->has_helper) {
>>           if (tap->has_ifname || tap->has_script || tap->has_downscript ||
>>               tap->has_vnet_hdr || tap->has_queues || tap->has_vhostfds) {
>>
>
>
>
>

-- 
------------------------------------------------
周潔
Dept 1
No. 6 Wenzhu Road,
Nanjing, 210012, China
TEL:+86+25-86630566-8557
FUJITSU INTERNAL:7998-8557
E-Mail:zhoujie2011@cn.fujitsu.com
------------------------------------------------

  reply	other threads:[~2016-04-26 13:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-26  1:26 [Qemu-trivial] [PATCH] net/tap: Allocating Large sized arrays to heap Zhou Jie
2016-04-26  1:26 ` [Qemu-devel] " Zhou Jie
2016-04-26  7:14 ` [Qemu-trivial] " Jason Wang
2016-04-26  7:14   ` Jason Wang
2016-04-26  7:45 ` [Qemu-trivial] " Christian Borntraeger
2016-04-26  7:45   ` Christian Borntraeger
2016-04-26  8:26   ` Zhou Jie [this message]
2016-04-26  8:26     ` Zhou Jie
2016-04-26  8:39     ` [Qemu-trivial] " Christian Borntraeger
2016-04-26  8:39       ` Christian Borntraeger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=571F262A.3020705@cn.fujitsu.com \
    --to=zhoujie2011@cn.fujitsu.com \
    --cc=borntraeger@de.ibm.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.