From: "Qiu, Michael" <michael.qiu@intel.com>
To: "Richardson, Bruce" <bruce.richardson@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] Avoid possible memory cpoy when sort hugepages
Date: Wed, 10 Dec 2014 10:59:23 +0000 [thread overview]
Message-ID: <533710CFB86FA344BFBF2D6802E60286C9E768@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <20141210104110.GB10056@bricha3-MOBL3>
On 12/10/2014 6:41 PM, Richardson, Bruce wrote:
> On Wed, Dec 10, 2014 at 10:25:41AM +0800, Michael Qiu wrote:
>> When the first address is the compared address in the loop,
>> it will also do memory copy, which is meaningless,
>> worse more, when hugepg_tbl is mostly in order. This should
>> be a big deal in large hugepage memory systerm(like hunderd
>> or thousand GB).
> I actually doubt the time taken by this sorting is a significant part of the
> initialization time taken, even for hundreds of GBs of memory. Do you have
> any measurements to confirm this?
> [However, that's not to say that we can't merge in this patch]
I've no hardware env of so huge memory, so I haven't do measurements on
this.
This is not a big improvement, but indeed it may do lots of useless
memory copy in initialize stat.
It could, at least could save time :)
Thanks,
Michael
>
>
>> Meanwhile smallest_idx never be a value of -1,so remove this check.
>>
>> This patch also includes some coding style fix.
>>
>> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
>> ---
>> lib/librte_eal/linuxapp/eal/eal_memory.c | 13 +++++--------
>> 1 file changed, 5 insertions(+), 8 deletions(-)
>>
>> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
>> index e6cb919..700aba2 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
>> @@ -678,14 +678,13 @@ error:
>> static int
>> sort_by_physaddr(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi)
>> {
>> - unsigned i, j;
>> - int compare_idx;
>> + unsigned i, j, compare_idx;
>> uint64_t compare_addr;
>> struct hugepage_file tmp;
>>
>> for (i = 0; i < hpi->num_pages[0]; i++) {
>> compare_addr = 0;
>> - compare_idx = -1;
>> + compare_idx = i;
>>
>> /*
>> * browse all entries starting at 'i', and find the
>> @@ -704,11 +703,9 @@ sort_by_physaddr(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi)
>> }
>> }
>>
>> - /* should not happen */
>> - if (compare_idx == -1) {
>> - RTE_LOG(ERR, EAL, "%s(): error in physaddr sorting\n", __func__);
>> - return -1;
>> - }
>> + /* avoid memory copy when the first entry is the compared */
>> + if (compare_idx == i)
>> + continue;
>>
>> /* swap the 2 entries in the table */
>> memcpy(&tmp, &hugepg_tbl[compare_idx],
>> --
>> 1.9.3
>>
next prev parent reply other threads:[~2014-12-10 10:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-10 2:25 Michael Qiu
2014-12-10 10:41 ` Bruce Richardson
2014-12-10 10:59 ` Qiu, Michael [this message]
2014-12-10 11:08 ` Ananyev, Konstantin
2014-12-10 17:58 ` Jay Rolette
[not found] ` <2601191342CEEE43887BDE71AB977258213BED0C@IRSMSX105.ger.corp.intel.com>
2014-12-10 18:39 ` Ananyev, Konstantin
2014-12-10 21:36 ` Jay Rolette
2014-12-11 1:44 ` Qiu, Michael
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=533710CFB86FA344BFBF2D6802E60286C9E768@SHSMSX101.ccr.corp.intel.com \
--to=michael.qiu@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.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 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).