public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Cupertino Miranda <cupertino.miranda@oracle.com>,
	Florian Weimer <fweimer@redhat.com>
Cc: Cupertino Miranda via Libc-alpha <libc-alpha@sourceware.org>,
	jose.marchesi@oracle.com, elena.zannoni@oracle.com
Subject: Re: [PATCH] Created tunable to force small pages on stack allocation.
Date: Mon, 13 Mar 2023 14:15:11 -0300	[thread overview]
Message-ID: <d3a17e50-f6d4-2d26-7613-c34031c56808@linaro.org> (raw)
In-Reply-To: <87y1o10xs7.fsf@oracle.com>



On 13/03/23 07:07, Cupertino Miranda wrote:
> 
> Hi Florian
> 
>> * Cupertino Miranda via Libc-alpha:
>>
>>> +static void
>>> +TUNABLE_CALLBACK (set_stack_hugetlb) (tunable_val_t *valp)
>>> +{
>>> +  enum malloc_thp_mode_t thp_mode = __malloc_thp_mode ();
>>> +  /*
>>> +     Only allow to change the default of this tunable if the system
>>> +     does support and has either 'madvise' or 'always' mode. Otherwise
>>> +     the madvise() call is wasteful.
>>> +  */
>>> +  switch(thp_mode)
>>> +    {
>>> +    case malloc_thp_mode_always:
>>> +    case malloc_thp_mode_madvise:
>>> +      __nptl_stack_hugetlb = (int32_t) valp->numval;
>>> +      break;
>>> +    default:
>>> +      break;
>>> +    }
>>> +}
>>
>> I suspect that quite a few failing madvise calls are cheaper than the
>> those three system calls in __malloc_thp_mode.  In addition,
>> __malloc_thp_mode may fail due to future kernel changes, disabling the
>> tunable by accident.
> Thanks for your review. Ok, I did not check the inner workings of
> malloc_thp_mode. I used it by suggestion from the RFC thread.
> I will prepare a version removing it.

It only make sense to madvise iff __malloc_thp_mode is set as 'always',
and tunable is a opt-in feature.  So I think it would make sense to
check the sysfs is tunable is used; the startup code will be amortized
on high threads workloads. 

  parent reply	other threads:[~2023-03-13 17:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10 14:35 Cupertino Miranda
2023-03-10 14:35 ` Cupertino Miranda
2023-03-13  7:54   ` Florian Weimer
2023-03-13 10:07     ` Cupertino Miranda
2023-03-13 17:10       ` Cupertino Miranda
2023-03-13 17:18         ` Cupertino Miranda
2023-03-13 17:15       ` Adhemerval Zanella Netto [this message]
2023-03-13 17:32         ` Cupertino Miranda
2023-03-13 17:17     ` Cupertino Miranda
2023-03-20 15:41 [v2] Created tunable to force small pages on stack Cupertino Miranda
2023-03-20 15:41 ` [PATCH] Created tunable to force small pages on stack allocation 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=d3a17e50-f6d4-2d26-7613-c34031c56808@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=cupertino.miranda@oracle.com \
    --cc=elena.zannoni@oracle.com \
    --cc=fweimer@redhat.com \
    --cc=jose.marchesi@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).