public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v5 0/1] *** Created tunable to force small pages on stack allocation.
@ 2023-03-28 15:22 Cupertino Miranda
  2023-03-28 15:22 ` [PATCH v5 1/1] " Cupertino Miranda
  2023-04-10  8:59 ` [PING] Re: [PATCH v5 0/1] *** " Cupertino Miranda
  0 siblings, 2 replies; 22+ messages in thread
From: Cupertino Miranda @ 2023-03-28 15:22 UTC (permalink / raw)
  To: libc-alpha; +Cc: jose.marchesi, elena.zannoni, Cupertino Miranda

Hi,

Fixes in tunables.texi by suggestion of Adhemerval.
Thanks for the improvements.

Regards,
Cupertino

Cupertino Miranda (1):
  Created tunable to force small pages on stack allocation.

 manual/tunables.texi          | 15 +++++++++++++++
 nptl/allocatestack.c          |  6 ++++++
 nptl/nptl-stack.c             |  1 +
 nptl/nptl-stack.h             |  3 +++
 nptl/pthread_mutex_conf.c     |  8 ++++++++
 sysdeps/nptl/dl-tunables.list |  6 ++++++
 6 files changed, 39 insertions(+)

-- 
2.38.1


^ permalink raw reply	[flat|nested] 22+ messages in thread
* [PATCH v5 1/1] Created tunable to force small pages on stack allocation.
@ 2023-04-13 15:43 Wilco Dijkstra
  2023-04-13 16:23 ` Cupertino Miranda
  0 siblings, 1 reply; 22+ messages in thread
From: Wilco Dijkstra @ 2023-04-13 15:43 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: 'GNU C Library', Cupertino Miranda

Hi Adhemerval,

I agree doing this automatically sounds like a better solution.
However:

+static __always_inline int
+advise_thp (void *mem, size_t size, size_t guardsize)
+{
+  enum malloc_thp_mode_t thpmode = __malloc_thp_mode ();
+  if (thpmode != malloc_thp_mode_always)
+    return 0;
+
+  unsigned long int thpsize = __malloc_default_thp_pagesize ();
+  if ((uintptr_t) mem % thpsize != 0
+      || size % thpsize != 0
+      || (size - guardsize) % thpsize != 0)
+    return 0;

Isn't the last part always true currently given the guard page size is based on
the standard page size? IIRC the issue was the mmap succeeds but the guard
page is taken from the original mmap which then causes the decomposition.

So you'd need something like:

|| guardsize % thpsize == 0)

Ie. we return without the madvise if the size and alignment is wrong for a huge
page or it is correct and the guardsize is a multiple of a huge page (in which
case it shouldn't decompose). 

+  return __madvise (mem, size, MADV_NOHUGEPAGE);
+}

Cheers,
Wilco

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-04-14 23:11 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28 15:22 [PATCH v5 0/1] *** Created tunable to force small pages on stack allocation 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
2023-04-10  8:59 ` [PING] Re: [PATCH v5 0/1] *** " Cupertino Miranda
2023-04-13 15:43 [PATCH v5 1/1] " 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
2023-04-14 16:27             ` Cupertino Miranda

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).