From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: 'GNU C Library' <libc-alpha@sourceware.org>
Subject: Re: [PATCH] malloc: Use correct C11 atomics for fastbin
Date: Mon, 21 Nov 2022 16:55:50 +0000 [thread overview]
Message-ID: <PAWPR08MB8982C0DF3B7A01A5BAE9B473830A9@PAWPR08MB8982.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <87fsecth5r.fsf@oldenburg.str.redhat.com>
Hi Florian,
>> Fix memory ordering issues in the fastbin implementation: in REMOVE_FB the
>> next pointer is read before any MO synchronization, however in the C11 atomic
>> model this is only correct after a load acquire. Refactor the fastbin code
>> and add a dedicated fastbin_push/pop implementation. The number of acquire
>> or release atomics remains the same, and the new functions are inlined, so
>> performance is unaffected.
>>
>> Passes regress, OK for commit?
>
> Did you actually observe any problems resulting from this? We
> previously concluded that the dependency chain would mae this valid
> (outside the C11 memory model).
No, I believe it works in most weak memory models (except for Alpha).
However the code always looked weird with the acquire done after several
non-atomic accesses... The key is that we need to do the acquire/release
only once per iteration in the CAS loop, and that avoids regressions.
Cheers,
Wilco
WARNING: multiple messages have this Message-ID
From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: 'GNU C Library' <libc-alpha@sourceware.org>
Subject: Re: [PATCH] malloc: Use correct C11 atomics for fastbin
Date: Mon, 21 Nov 2022 16:56:19 +0000 [thread overview]
Message-ID: <PAWPR08MB8982C0DF3B7A01A5BAE9B473830A9@PAWPR08MB8982.eurprd08.prod.outlook.com> (raw)
Message-ID: <20221121165619.1XXGdv8oIMATy51qKHfqUYmCR9UrXl9aQl_hyjOnvAk@z> (raw)
In-Reply-To: <87fsecth5r.fsf@oldenburg.str.redhat.com>
Hi Florian,
>> Fix memory ordering issues in the fastbin implementation: in REMOVE_FB the
>> next pointer is read before any MO synchronization, however in the C11 atomic
>> model this is only correct after a load acquire. Refactor the fastbin code
>> and add a dedicated fastbin_push/pop implementation. The number of acquire
>> or release atomics remains the same, and the new functions are inlined, so
>> performance is unaffected.
>>
>> Passes regress, OK for commit?
>
> Did you actually observe any problems resulting from this? We
> previously concluded that the dependency chain would mae this valid
> (outside the C11 memory model).
No, I believe it works in most weak memory models (except for Alpha).
However the code always looked weird with the acquire done after several
non-atomic accesses... The key is that we need to do the acquire/release
only once per iteration in the CAS loop, and that avoids regressions.
Cheers,
Wilco
next prev parent reply other threads:[~2022-11-21 16:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 16:09 Wilco Dijkstra
2022-11-21 16:18 ` Florian Weimer
2022-11-21 16:55 ` Wilco Dijkstra [this message]
2022-11-21 16:56 ` Wilco Dijkstra
2022-11-21 17:00 ` Florian Weimer
2022-12-02 5:11 ` DJ Delorie
2022-12-02 6:36 ` Florian Weimer
2022-12-02 10:56 ` Wilco Dijkstra
2022-12-02 11:24 ` Florian Weimer
2022-12-02 12:02 ` Wilco Dijkstra
2022-12-02 18:55 ` DJ Delorie
2022-12-05 18:39 ` Zack Weinberg
2022-12-06 16:19 ` DJ Delorie
2022-12-12 3:35 ` Zack Weinberg
2022-12-12 11:57 ` Florian Weimer
2022-12-12 11:56 ` Florian Weimer
2022-12-06 13:29 ` Wilco Dijkstra
2022-12-06 13:37 ` Adhemerval Zanella Netto
2022-12-06 14:31 ` Zack Weinberg
2022-12-06 16:23 ` DJ Delorie
2022-12-15 15:43 ` Wilco Dijkstra
2022-12-02 18:55 ` DJ Delorie
2022-12-06 15:04 Wilco Dijkstra
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=PAWPR08MB8982C0DF3B7A01A5BAE9B473830A9@PAWPR08MB8982.eurprd08.prod.outlook.com \
--to=wilco.dijkstra@arm.com \
--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).