public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: Cupertino Miranda <cupertino.miranda@oracle.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	'GNU C Library' <libc-alpha@sourceware.org>
Subject: Re: [PATCH v5 1/1] Created tunable to force small pages on stack allocation.
Date: Fri, 14 Apr 2023 23:10:49 +0000	[thread overview]
Message-ID: <PAWPR08MB89821F7B5841C6DC5C3506D483999@PAWPR08MB8982.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <87r0smbevu.fsf@oracle.com>

Hi Cupertino,

> I had a test application demonstrating the problem.

So I don't see the problem discussed of huge pages being
split into small pages due to the guard page. If you ask for
N huge pages of stack, you actually get either N-1 or N huge
pages. That's irrespectively of the size of the guard page.

If you get N-1 huge pages the first/last part of the stack consist
of small pages. This depends on the alignment of the previous
mmap by accident since the stack allocation code does not
request huge pages (ie. you get transparent huge pages if they
happen to fit in the mmap range).

Even in your basic example you always get exactly 1 huge page
for all threads when the mmap is aligned. Interestingly in the
unaligned mmap case (ie. N-1 huge pages), the RSS size can
actually end up twice as large as the RSS size of aligned huge
pages (eg. if you use ~2MBytes of stack it will exactly fit in one
huge page if aligned, so 2MB RSS, but if not aligned might use
1.9MB of small pages with the rest falling into the next huge
page, making RSS ~4MB).

So the underlying problem is that the stack allocation code doesn't
really support huge pages. It's bad to get random huge pages in
stack allocations based on alignment from unrelated mmap calls -
it affects RSS size randomly as well as TLB misses etc. Overall it seems
best to disable huge pages in stacks until this is fixed.

Cheers,
Wilco

  reply	other threads:[~2023-04-14 23:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13 15:43 Wilco Dijkstra
2023-04-13 16:23 ` Cupertino Miranda
2023-04-13 17:48   ` Adhemerval Zanella Netto
2023-04-14 11:28     ` Cupertino Miranda
2023-04-14 13:24       ` Wilco Dijkstra
2023-04-14 14:49         ` Cupertino Miranda
2023-04-14 15:32           ` Wilco Dijkstra
2023-04-14 16:03             ` Wilco Dijkstra
2023-04-14 16:35               ` Cupertino Miranda
2023-04-14 23:10                 ` Wilco Dijkstra [this message]
2023-04-14 16:27             ` Cupertino Miranda
  -- strict thread matches above, loose matches on Subject: below --
2023-03-28 15:22 [PATCH v5 0/1] *** " Cupertino Miranda
2023-03-28 15:22 ` [PATCH v5 1/1] " Cupertino Miranda
2023-04-11 19:56   ` Adhemerval Zanella Netto
2023-04-12  8:53     ` Cupertino Miranda
2023-04-12 14:10       ` Adhemerval Zanella Netto
2023-04-13 16:13         ` Cupertino Miranda
2023-04-14 11:41       ` Adhemerval Zanella Netto
2023-04-14 12:27         ` Cupertino Miranda
2023-04-14 13:06           ` Adhemerval Zanella Netto
2023-04-14 14:33             ` Cupertino Miranda

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=PAWPR08MB89821F7B5841C6DC5C3506D483999@PAWPR08MB8982.eurprd08.prod.outlook.com \
    --to=wilco.dijkstra@arm.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=cupertino.miranda@oracle.com \
    --cc=libc-alpha@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).