From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v5 2/2] csu: Implement and use _dl_early_allocate during static startup
Date: Mon, 16 May 2022 10:04:34 -0300 [thread overview]
Message-ID: <13d3a2db-7851-f744-59fc-190dfd7be2a9@linaro.org> (raw)
In-Reply-To: <87lev6siky.fsf@oldenburg.str.redhat.com>
On 12/05/2022 15:37, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>>> +void *
>>> +_dl_early_allocate (size_t size)
>>> +{
>>> + void *result;
>>> +
>>> + if (__curbrk != NULL)
>>> + /* If the break has been initialized, brk must have run before,
>>> + so just call it once more. */
>>> + {
>>> + result = __sbrk (size);
>>> + if (result == (void *) -1)
>>> + result = NULL;
>>> + }
>>> + else
>>> + {
>>> + /* If brk has not been invoked, there is no need to update
>>> + __curbrk. The first call to brk will take care of that. */
>>> + void *previous = __brk_call (0);
>>> + result = __brk_call (previous + size);
>>> + if (result == previous)
>>> + result = NULL;
>>> + else
>>> + result = previous;
>>> + }
>>
>> Why do you need to avoid update __curbrk here? Otherwise it seems that a
>> __sbrk() should be suffice here.
>
> A subsequent call to _dl_early_allocate would then take the first (sbrk)
> branch, which may or may not be correct, depending on whether the TCB
> has been initialized at that point or not.
OK, LGTM then. I think I might try later to consolidate the mmap
syscall, although not sure if it would be worth.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
next prev parent reply other threads:[~2022-05-16 13:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-09 18:18 [PATCH v5 1/2] Linux: Introduce __brk_call for invoking the brk system call Florian Weimer
2022-05-09 18:18 ` [PATCH v5 2/2] csu: Implement and use _dl_early_allocate during static startup Florian Weimer
2022-05-12 13:15 ` Adhemerval Zanella
2022-05-12 18:37 ` Florian Weimer
2022-05-16 13:04 ` Adhemerval Zanella [this message]
2022-05-12 13:01 ` [PATCH v5 1/2] Linux: Introduce __brk_call for invoking the brk system call Adhemerval Zanella
2022-05-12 13:25 ` Andreas Schwab
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=13d3a2db-7851-f744-59fc-190dfd7be2a9@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=fweimer@redhat.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).