From: Guo Hui <guohui@uniontech.com>
To: akpm@linux-foundation.org, linux-mm@kvack.org
Cc: wangxiaohua@uniontech.com, Guo Hui <guohui@uniontech.com>
Subject: [PATCH] mm: sparse: shift operation instead of division operation for root index
Date: Thu, 10 Aug 2023 18:38:29 +0800 [thread overview]
Message-ID: <20230810103829.10007-1-guohui@uniontech.com> (raw)
In the function __nr_to_section,
Use shift operation instead of division operation
in order to improve the performance of memory management.
There are no functional changes.
Some performance data is as follows:
Machine configuration: Hygon 128 cores, 256M memory
Stream single core:
with patch without patch promote
Copy 23376.7731 23907.1532 -1.27%
Scale 12580.2913 11679.7852 +7.71%
Add 11922.9562 11461.8669 +4.02%
Triad 12549.2735 11491.9798 +9.20%
Signed-off-by: Guo Hui <guohui@uniontech.com>
---
include/linux/mmzone.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 5e50b78d58ea..8dde6fb56109 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1818,7 +1818,8 @@ struct mem_section {
#define SECTIONS_PER_ROOT 1
#endif
-#define SECTION_NR_TO_ROOT(sec) ((sec) / SECTIONS_PER_ROOT)
+#define SECTION_ROOT_SHIFT (__builtin_popcount(SECTIONS_PER_ROOT - 1))
+#define SECTION_NR_TO_ROOT(sec) ((sec) >> SECTION_ROOT_SHIFT)
#define NR_SECTION_ROOTS DIV_ROUND_UP(NR_MEM_SECTIONS, SECTIONS_PER_ROOT)
#define SECTION_ROOT_MASK (SECTIONS_PER_ROOT - 1)
--
2.20.1
next reply other threads:[~2023-08-10 10:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 10:38 Guo Hui [this message]
2023-08-10 13:14 ` Matthew Wilcox
2023-08-12 8:07 ` Guo Hui
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=20230810103829.10007-1-guohui@uniontech.com \
--to=guohui@uniontech.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=wangxiaohua@uniontech.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