From: haoxin <xhao@linux.alibaba.com>
To: Huang Ying <ying.huang@intel.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Zi Yan <ziy@nvidia.com>, Yang Shi <shy828301@gmail.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Oscar Salvador <osalvador@suse.de>,
Matthew Wilcox <willy@infradead.org>,
Bharata B Rao <bharata@amd.com>,
Alistair Popple <apopple@nvidia.com>,
Minchan Kim <minchan@kernel.org>,
Mike Kravetz <mike.kravetz@oracle.com>,
Hyeonggon Yoo <42.hyeyoo@gmail.com>
Subject: Re: [PATCH -v4 0/9] migrate_pages(): batch TLB flushing
Date: Wed, 8 Feb 2023 14:21:48 +0800 [thread overview]
Message-ID: <b01e8657-76bd-71e6-929a-4b1131d1aebd@linux.alibaba.com> (raw)
In-Reply-To: <20230206063313.635011-1-ying.huang@intel.com>
[-- Attachment #1: Type: text/plain, Size: 4359 bytes --]
On my arm64 server with 128 cores, 2 numa nodes.
I used memhog as benchmark :
numactl -m -C 5 memhog -r100000 1G
The test result as below:
With this patch:
#time migratepages 8490 0 1
real 0m1.161s
user 0m0.000s
sys 0m1.161s
without this patch:
#time migratepages 8460 0 1
real 0m2.068s
user 0m0.001s
sys 0m2.068s
So you can see the migration performance improvement about *+78%*
This is the perf record info.
w/o
+ 51.07% 0.09% migratepages [kernel.kallsyms] [k]
migrate_folio_extra
+ 42.43% 0.04% migratepages [kernel.kallsyms] [k] folio_copy
+ 42.34% 42.34% migratepages [kernel.kallsyms] [k] __pi_copy_page
+ 33.99% 0.09% migratepages [kernel.kallsyms] [k] rmap_walk_anon
+ 32.35% 0.04% migratepages [kernel.kallsyms] [k] try_to_migrate
*+ 27.78% 27.78% migratepages [kernel.kallsyms] [k]
ptep_clear_flush *
+ 8.19% 6.64% migratepages [kernel.kallsyms] [k]
folio_migrate_flagsmigrati_tlb_flush
w/ this patch
+ 18.57% 0.13% migratepages [kernel.kallsyms] [k]
migrate_pages
+ 18.23% 0.07% migratepages [kernel.kallsyms] [k]
migrate_pages_batch
+ 16.29% 0.13% migratepages [kernel.kallsyms] [k]
migrate_folio_move
+ 12.73% 0.10% migratepages [kernel.kallsyms] [k]
move_to_new_folio
+ 12.52% 0.06% migratepages [kernel.kallsyms] [k]
migrate_folio_extra
Therefore, this patch helps improve performance in page migration
So, you can add Tested-by: Xin Hao <xhao@linux.alibaba.com>
在 2023/2/6 下午2:33, Huang Ying 写道:
> From: "Huang, Ying"<ying.huang@intel.com>
>
> Now, migrate_pages() migrate folios one by one, like the fake code as
> follows,
>
> for each folio
> unmap
> flush TLB
> copy
> restore map
>
> If multiple folios are passed to migrate_pages(), there are
> opportunities to batch the TLB flushing and copying. That is, we can
> change the code to something as follows,
>
> for each folio
> unmap
> for each folio
> flush TLB
> for each folio
> copy
> for each folio
> restore map
>
> The total number of TLB flushing IPI can be reduced considerably. And
> we may use some hardware accelerator such as DSA to accelerate the
> folio copying.
>
> So in this patch, we refactor the migrate_pages() implementation and
> implement the TLB flushing batching. Base on this, hardware
> accelerated folio copying can be implemented.
>
> If too many folios are passed to migrate_pages(), in the naive batched
> implementation, we may unmap too many folios at the same time. The
> possibility for a task to wait for the migrated folios to be mapped
> again increases. So the latency may be hurt. To deal with this
> issue, the max number of folios be unmapped in batch is restricted to
> no more than HPAGE_PMD_NR in the unit of page. That is, the influence
> is at the same level of THP migration.
>
> We use the following test to measure the performance impact of the
> patchset,
>
> On a 2-socket Intel server,
>
> - Run pmbench memory accessing benchmark
>
> - Run `migratepages` to migrate pages of pmbench between node 0 and
> node 1 back and forth.
>
> With the patch, the TLB flushing IPI reduces 99.1% during the test and
> the number of pages migrated successfully per second increases 291.7%.
>
> This patchset is based on v6.2-rc4.
>
> Changes:
>
> v4:
>
> - Fixed another bug about non-LRU folio migration. Thanks Hyeonggon!
>
> v3:
>
> - Rebased on v6.2-rc4
>
> - Fixed a bug about non-LRU folio migration. Thanks Mike!
>
> - Fixed some comments. Thanks Baolin!
>
> - Collected reviewed-by.
>
> v2:
>
> - Rebased on v6.2-rc3
>
> - Fixed type force cast warning. Thanks Kees!
>
> - Added more comments and cleaned up the code. Thanks Andrew, Zi, Alistair, Dan!
>
> - Collected reviewed-by.
>
> from rfc to v1:
>
> - Rebased on v6.2-rc1
>
> - Fix the deadlock issue caused by locking multiple pages synchronously
> per Alistair's comments. Thanks!
>
> - Fix the autonumabench panic per Rao's comments and fix. Thanks!
>
> - Other minor fixes per comments. Thanks!
>
> Best Regards,
> Huang, Ying
[-- Attachment #2: Type: text/html, Size: 19511 bytes --]
next prev parent reply other threads:[~2023-02-08 6:22 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-06 6:33 Huang Ying
2023-02-06 6:33 ` [PATCH -v4 1/9] migrate_pages: organize stats with struct migrate_pages_stats Huang Ying
2023-02-07 16:28 ` haoxin
2023-02-06 6:33 ` [PATCH -v4 2/9] migrate_pages: separate hugetlb folios migration Huang Ying
2023-02-07 16:42 ` haoxin
2023-02-08 11:35 ` Huang, Ying
2023-02-06 6:33 ` [PATCH -v4 3/9] migrate_pages: restrict number of pages to migrate in batch Huang Ying
2023-02-07 17:01 ` haoxin
2023-02-06 6:33 ` [PATCH -v4 4/9] migrate_pages: split unmap_and_move() to _unmap() and _move() Huang Ying
2023-02-07 17:11 ` haoxin
2023-02-07 17:27 ` haoxin
2023-02-06 6:33 ` [PATCH -v4 5/9] migrate_pages: batch _unmap and _move Huang Ying
2023-02-06 16:10 ` Zi Yan
2023-02-07 5:58 ` Huang, Ying
2023-02-13 6:55 ` Huang, Ying
2023-02-07 17:33 ` haoxin
2023-02-06 6:33 ` [PATCH -v4 6/9] migrate_pages: move migrate_folio_unmap() Huang Ying
2023-02-07 14:40 ` Zi Yan
2023-02-06 6:33 ` [PATCH -v4 7/9] migrate_pages: share more code between _unmap and _move Huang Ying
2023-02-07 14:50 ` Zi Yan
2023-02-08 12:02 ` Huang, Ying
2023-02-08 19:47 ` Zi Yan
2023-02-10 7:09 ` Huang, Ying
2023-02-06 6:33 ` [PATCH -v4 8/9] migrate_pages: batch flushing TLB Huang Ying
2023-02-07 14:52 ` Zi Yan
2023-02-08 11:27 ` Huang, Ying
2023-02-07 17:44 ` haoxin
2023-02-06 6:33 ` [PATCH -v4 9/9] migrate_pages: move THP/hugetlb migration support check to simplify code Huang Ying
2023-02-07 14:53 ` Zi Yan
2023-02-08 6:21 ` haoxin [this message]
2023-02-08 6:27 ` [PATCH -v4 0/9] migrate_pages(): batch TLB flushing haoxin
2023-02-08 11:04 ` Jonathan Cameron
2023-02-08 11:25 ` Huang, Ying
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=b01e8657-76bd-71e6-929a-4b1131d1aebd@linux.alibaba.com \
--to=xhao@linux.alibaba.com \
--cc=42.hyeyoo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=bharata@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=minchan@kernel.org \
--cc=osalvador@suse.de \
--cc=shy828301@gmail.com \
--cc=willy@infradead.org \
--cc=ying.huang@intel.com \
--cc=ziy@nvidia.com \
/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