From: Yin Fengwei <fengwei.yin@intel.com>
To: Yang Shi <shy828301@gmail.com>
Cc: kernel test robot <oliver.sang@intel.com>,
Rik van Riel <riel@surriel.com>, <oe-lkp@lists.linux.dev>,
<lkp@intel.com>,
"Linux Memory Management List" <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>,
Christopher Lameter <cl@linux.com>, <ying.huang@intel.com>,
<feng.tang@intel.com>
Subject: Re: [linux-next:master] [mm] 1111d46b5c: stress-ng.pthread.ops_per_sec -84.3% regression
Date: Thu, 21 Dec 2023 09:02:54 +0800 [thread overview]
Message-ID: <c739da04-9ea7-49c5-80b0-d9117f2c8f44@intel.com> (raw)
In-Reply-To: <b1974dc2-0e25-4075-a9ba-5e1face6c0cd@intel.com>
>>>>
>>>> https://github.com/lattera/glibc/blob/master/nptl/allocatestack.c#L384
>>>> https://github.com/lattera/glibc/blob/master/nptl/pthread_create.c#L576
>>>
>>> It explains the problem. The madvise() does have some extra overhead
>>> for handling THP (splitting pmd, deferred split queue, etc).
>>>
>>>>
>>>> Another thing is whether it's worthy to make stack use THP? It may be
>>>> useful for some apps which need large stack size?
>>>
>>> Kernel actually doesn't apply THP to stack (see
>>> vma_is_temporary_stack()). But kernel can't know whether the VMA is
>>> stack or not by checking VM_GROWSDOWN | VM_GROWSUP flags. So if glibc
>>> doesn't set the proper flags to tell kernel the area is stack, kernel
>>> just treats it as normal anonymous area. So glibc should set up stack
>>> properly IMHO.
>>
>> If I read the code correctly, nptl allocates stack by the below code:
>>
>> mem = __mmap (NULL, size, (guardsize == 0) ? prot : PROT_NONE,
>> MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
>>
>> See
>> https://github.com/lattera/glibc/blob/master/nptl/allocatestack.c#L563
>>
>> The MAP_STACK is used, but it is a no-op on Linux. So the alternative
>> is to make MAP_STACK useful on Linux instead of changing glibc. But
>> the blast radius seems much wider.
> Yes. MAP_STACK is also mentioned in manpage of mmap. I did test to
> filter out of the MAP_STACK mapping based on this patch. The regression
> in stress-ng.pthread was gone. I suppose this is kind of safe because
> the madvise call is only applied to glibc allocated stack.
The patch I tested against stress-ng.pthread:
diff --git a/mm/mmap.c b/mm/mmap.c
index b78e83d351d2..1fd510aef82e 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1829,7 +1829,8 @@ get_unmapped_area(struct file *file, unsigned long
addr, unsigned long len,
*/
pgoff = 0;
get_area = shmem_get_unmapped_area;
- } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
+ } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) &&
+ !(flags & MAP_STACK)) {
/* Ensures that larger anonymous mappings are THP
aligned. */
get_area = thp_get_unmapped_area;
}
>
>
> But what I am not sure was whether it's worthy to do such kind of change
> as the regression only is seen obviously in micro-benchmark. No evidence
> showed the other regressionsin this report is related with madvise. At
> least from the perf statstics. Need to check more on stream/ramspeed.
> Thanks.
>
>
> Regards
> Yin, Fengwei
>
>>
>>>
>>>>
>>>>
>>>> Regards
>>>> Yin, Fengwei
next prev parent reply other threads:[~2023-12-21 1:08 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 15:41 [linux-next:master] [mm] 1111d46b5c: stress-ng.pthread.ops_per_sec -84.3% regression kernel test robot
2023-12-20 5:27 ` Yang Shi
2023-12-20 8:29 ` Yin Fengwei
2023-12-20 15:42 ` Christoph Lameter (Ampere)
2023-12-20 20:14 ` Yang Shi
2023-12-20 20:09 ` Yang Shi
2023-12-21 0:26 ` Yang Shi
2023-12-21 0:58 ` Yin Fengwei
2023-12-21 1:02 ` Yin Fengwei [this message]
2023-12-21 4:49 ` Matthew Wilcox
2023-12-21 4:58 ` Yin Fengwei
2023-12-21 18:07 ` Yang Shi
2023-12-21 18:14 ` Matthew Wilcox
2023-12-22 1:06 ` Yin, Fengwei
2023-12-22 2:23 ` Huang, Ying
2023-12-21 13:39 ` Yin, Fengwei
2023-12-21 18:11 ` Yang Shi
2023-12-22 1:13 ` Yin, Fengwei
2024-01-04 1:32 ` Yang Shi
2024-01-04 8:18 ` Yin Fengwei
2024-01-04 8:39 ` Oliver Sang
2024-01-05 9:29 ` Oliver Sang
2024-01-05 14:52 ` Yin, Fengwei
2024-01-05 18:49 ` Yang 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=c739da04-9ea7-49c5-80b0-d9117f2c8f44@intel.com \
--to=fengwei.yin@intel.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=feng.tang@intel.com \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=oe-lkp@lists.linux.dev \
--cc=oliver.sang@intel.com \
--cc=riel@surriel.com \
--cc=shy828301@gmail.com \
--cc=willy@infradead.org \
--cc=ying.huang@intel.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