From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA35DC43461 for ; Thu, 3 Sep 2020 08:33:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4A0F8205F4 for ; Thu, 3 Sep 2020 08:33:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A0F8205F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BB6666B005D; Thu, 3 Sep 2020 04:33:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B65ED8E0001; Thu, 3 Sep 2020 04:33:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7B196B0068; Thu, 3 Sep 2020 04:33:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 91E896B005D for ; Thu, 3 Sep 2020 04:33:10 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4A8C11F0A for ; Thu, 3 Sep 2020 08:33:10 +0000 (UTC) X-FDA: 77221085340.28.pet42_2f0bc6e270a8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 1B1E06C05 for ; Thu, 3 Sep 2020 08:33:10 +0000 (UTC) X-HE-Tag: pet42_2f0bc6e270a8 X-Filterd-Recvd-Size: 4845 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Thu, 3 Sep 2020 08:33:05 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04420;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0U7nlKYs_1599121981; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U7nlKYs_1599121981) by smtp.aliyun-inc.com(127.0.0.1); Thu, 03 Sep 2020 16:33:02 +0800 Subject: Re: [PATCH v4 1/4] mm/pageblock: mitigation cmpxchg false sharing in pageblock flags To: Mel Gorman Cc: Anshuman Khandual , David Hildenbrand , Matthew Wilcox , Vlastimil Babka , Alexander Duyck , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <1599116482-7410-1-git-send-email-alex.shi@linux.alibaba.com> <20200903072447.GB3179@techsingularity.net> From: Alex Shi Message-ID: <8275cc70-fd35-25c8-36d4-525a10f05e41@linux.alibaba.com> Date: Thu, 3 Sep 2020 16:32:54 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200903072447.GB3179@techsingularity.net> Content-Type: text/plain; charset=UTF-8 X-Rspamd-Queue-Id: 1B1E06C05 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: =E5=9C=A8 2020/9/3 =E4=B8=8B=E5=8D=883:24, Mel Gorman =E5=86=99=E9=81=93: > On Thu, Sep 03, 2020 at 03:01:20PM +0800, 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' flag= s, >> 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 the false sharing in cmpxchg. >> >> Signed-off-by: Alex Shi >=20 > Page block types were not known to change at high frequency that would > cause a measurable performance drop. If anything, the performance hit > from pageblocks is the lookup paths which is a lot more frequent. Yes, it is not hot path. But it's still a meaningful points to reduce cmp= xchg level false sharing which isn't right on logical. >=20 > What was the workload you were running that altered pageblocks at a hig= h > enough frequency for collisions to occur when updating adjacent > pageblocks? >=20 I have run thpscale with 'always' defrag setting of THP. The Amean stddev= is much larger than a very little average run time reducing. But the left patch 4 could show the cmpxchg retry reduce from thousands t= o hundreds or less. Subject: [PATCH v4 4/4] add cmpxchg tracing Signed-off-by: Alex Shi --- include/trace/events/pageblock.h | 30 ++++++++++++++++++++++++++++++ mm/page_alloc.c | 4 ++++ 2 files changed, 34 insertions(+) create mode 100644 include/trace/events/pageblock.h diff --git a/include/trace/events/pageblock.h b/include/trace/events/page= block.h new file mode 100644 index 000000000000..003c2d716f82 --- /dev/null +++ b/include/trace/events/pageblock.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM pageblock + +#if !defined(_TRACE_PAGEBLOCK_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_PAGEBLOCK_H + +#include + +TRACE_EVENT(hit_cmpxchg, + + TP_PROTO(char byte), + + TP_ARGS(byte), + + TP_STRUCT__entry( + __field(char, byte) + ), + + TP_fast_assign( + __entry->byte =3D byte; + ), + + TP_printk("%d", __entry->byte) +); + +#endif /* _TRACE_PAGE_ISOLATION_H */ + +/* This part must be outside protection */ +#include diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8b65d83d8be6..a6d7159295bc 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -509,6 +509,9 @@ static __always_inline int get_pfnblock_migratetype(s= truct page *page, unsigned * @pfn: The target page frame number * @mask: mask of bits that the caller is interested in */ +#define CREATE_TRACE_POINTS +#include + void set_pfnblock_flags_mask(struct page *page, unsigned long flags, unsigned long pfn, unsigned long mask) @@ -532,6 +535,7 @@ void set_pfnblock_flags_mask(struct page *page, unsig= ned long flags, if (byte =3D=3D old_byte) break; byte =3D old_byte; + trace_hit_cmpxchg(byte); } } -- 1.8.3.1