From: Alex Shi <alex.shi@linux.alibaba.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>,
Matthew Wilcox <willy@infradead.org>,
David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Hugh Dickins <hughd@google.com>,
Alexander Duyck <alexander.h.duyck@linux.intel.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] mm/pageblock: mitigation cmpxchg false sharing in pageblock flags
Date: Sun, 30 Aug 2020 18:14:33 +0800 [thread overview]
Message-ID: <01c846d4-2fe4-eeef-6c79-e71fda1f9a39@linux.alibaba.com> (raw)
In-Reply-To: <8ec2a4b0-9e51-abf9-fa7a-29989d3f1fac@arm.com>
在 2020/8/19 下午3:55, Anshuman Khandual 写道:
>
>
> On 08/19/2020 11:17 AM, Alex Shi wrote:
>> pageblock_flags is used as long, since every pageblock_flags is just 4
>> bits, 'long' size will include 8(32bit machine) or 16 pageblocks' flags,
>> that flag setting has to sync in cmpxchg with 7 or 15 other pageblock
>> flags. It would cause long waiting for sync.
>>
>> If we could change the pageblock_flags variable as char, we could use
>> char size cmpxchg, which just sync up with 2 pageblock flags. it could
>> relief much false sharing in cmpxchg.
>
> Do you have numbers demonstrating claimed performance improvement
> after this change ?
>
the performance data show in another email.
LKP reported the arm6 has a bug on this patchset, since it has no cmpxchgb
solution, so maybe let's fallback to cmpxchg on it.
From db3d97ba8cc5e206b440bd40a92ef6955ad86bc0 Mon Sep 17 00:00:00 2001
From: Alex Shi <alex.shi@linux.alibaba.com>
Date: Tue, 18 Aug 2020 15:51:18 +0800
Subject: [PATCH v2 3/3] armv6: fix armv6 build issue
Arm v6 can not simulate cmpxchg1 func, so we have to use cmpxchg4 on it.
arm-linux-gnueabi-ld: mm/page_alloc.o: in function `set_pfnblock_flags_mask':
(.text+0x32b4): undefined reference to `__bad_cmpxchg'
arm-linux-gnueabi-ld: (.text+0x32e0): undefined reference to `__bad_cmpxchg'
arm-linux-gnueabi-ld: drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.o: in function `hw_atl_b0_get_mac_temp':
hw_atl_b0.c:(.text+0x30fc): undefined reference to `__bad_udelay'
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
---
mm/page_alloc.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 7da09d66233b..c09146a8946c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -517,7 +517,11 @@ void set_pfnblock_flags_mask(struct page *page, unsigned long flags,
{
unsigned char *bitmap;
unsigned long bitidx, byte_bitidx;
+#ifdef CONFIG_CPU_V6
+ unsigned long old_byte, byte;
+#else
unsigned char old_byte, byte;
+#endif
BUILD_BUG_ON(NR_PAGEBLOCK_BITS != BITS_PER_BYTE);
BUILD_BUG_ON(MIGRATE_TYPES > (1 << PB_migratetype_bits));
@@ -532,9 +536,18 @@ void set_pfnblock_flags_mask(struct page *page, unsigned long flags,
mask <<= bitidx;
flags <<= bitidx;
+#ifdef CONFIG_CPU_V6
+ byte = (unsigned long)READ_ONCE(bitmap[byte_bitidx]);
+#else
byte = READ_ONCE(bitmap[byte_bitidx]);
+#endif
for (;;) {
+#ifdef CONFIG_CPU_V6
+ /* arm v6 has no cmpxchgb function, so still false sharing long word */
+ old_byte = cmpxchg((unsigned long*)&bitmap[byte_bitidx], byte, (byte & ~mask) | flags);
+#else
old_byte = cmpxchg(&bitmap[byte_bitidx], byte, (byte & ~mask) | flags);
+#endif
if (byte == old_byte)
break;
byte = old_byte;
--
1.8.3.1
next prev parent reply other threads:[~2020-08-30 10:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-19 5:47 Alex Shi
2020-08-19 5:47 ` [PATCH v2 2/2] mm/pageblock: remove false sharing in pageblock_flags Alex Shi
2020-08-19 7:57 ` Anshuman Khandual
2020-08-19 8:09 ` Alex Shi
2020-08-19 8:13 ` David Hildenbrand
2020-08-19 8:36 ` Alex Shi
2020-08-19 16:50 ` Alexander Duyck
2020-08-30 10:00 ` Alex Shi
2020-08-30 20:32 ` Alexander Duyck
2020-09-03 5:35 ` Alex Shi
2020-09-01 17:04 ` Vlastimil Babka
2020-08-19 7:55 ` [PATCH v2 1/2] mm/pageblock: mitigation cmpxchg false sharing in pageblock flags Anshuman Khandual
2020-08-19 8:04 ` David Hildenbrand
2020-08-30 10:08 ` Alex Shi
2020-08-30 10:14 ` Alex Shi [this message]
2020-08-30 10:18 ` Matthew Wilcox
2020-08-31 8:40 ` Alex Shi
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=01c846d4-2fe4-eeef-6c79-e71fda1f9a39@linux.alibaba.com \
--to=alex.shi@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.h.duyck@linux.intel.com \
--cc=anshuman.khandual@arm.com \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.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