public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: DJ Delorie <dj@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [v4] Update mmap() flags and errors lists
Date: Fri, 21 Jun 2024 09:02:29 -0400	[thread overview]
Message-ID: <7b23e187-3d73-4eab-9ef6-c15679666676@efficios.com> (raw)
In-Reply-To: <xntthqq89e.fsf@greed.delorie.com>

On 2024-06-18 16:57, DJ Delorie wrote:
> Mathieu Desnoyers <mathieu.desnoyers@efficios.com> writes:
[...]
> 
>>> +@item MAP_FIXED_NOREPLACE
>>> +Similar to @code{MAP_FIXED} except the call will fail with
>>> +@code{EEXIST} if the new mapping would overwrite an existing mapping.
>>> +To test for this, specify MAP_FIXED_NOREPLACE without MAP_FIXED, and
>>> +check the actual address returned.  If it does not match the address
>>> +passed, then this flag is not supported.
>>
>> mmap(2) states that older kernels fallback to non-MAP_FIXED behavior if
>> the mapping would overwrite an existing mapping, which requires to
>> carefully handle the return value. Is this backward-compatibility
>> handling somehow abstracted within the libc wrapper ?
> 
> The man page says that older kernels which do not support
> MAP_FIXED_NOREPLACE would act as if that flag were just omitted, which
> means no MAP_FIXED either.  It does not imply that there's an older
> kernel that *does* support MAP_FIXED_NOREPLACE but acts differently than
> today.  In either case, testing the returned address to see if it
> matches the desired one is the correct response.
> 
> There's no special backwards compatibility for mmap() in glibc, other
> than to call mmap2 instead of mmap if available.

OK

[...]

> 
>>> +@item MAP_SYNC
>>> +This flag is used to map persistent memory devices into the running
>>> +program in such a way that writes to the mapping are immediately
>>> +written to the device as well.  Unlike most other flags, this one will
>>> +fail unless @code{MAP_SHARED_VALIDATE} is also given.
>>
>> Note that this wording is misleading. Users of persistent memory devices
>> need to issue explicit "flush" instructions to ensure that writes are
>> made persistent to the device. The MAP_SYNC merely guarantees that
>> memory mappings within a file on a dax-enabled filesystem will appear
>> at the same file offset after a crash/reboot. It goes not guarantee
>> anything about write persistence.
> 
>    "This flag is supported only for files supporting DAX (direct mapping
>     of persistent memory)"
> 
>    "it will be visible in the same file at the same offset even after the
>     system crashes or is rebooted."
> 
> That sounds like persistence to me?

AFAIU it states persistence of the mapping location within the file, but
it does not guarantee anything about persistence of the writes to that 
mapping.

In many cases, persistence of the writes to the mapping are only made
persistent after specific cache-flushing instructions have been issued.

See this man page for reference:

https://manpages.debian.org/experimental/libpmem-dev/pmem_flush.3

> 
>>> +@item EAGAIN
>>> +
>>> +The system has temporarily run out of resources.
>>
>> or file has been locked.
> 
> I was asked to avoid mentioning certiain types of locks that glibc
> chooses not to support...

OK

[...]

Thanks,

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


  reply	other threads:[~2024-06-21 13:01 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-10 18:59 DJ Delorie
2024-06-04 22:16 ` Florian Weimer
2024-06-05  4:10   ` DJ Delorie
2024-06-05  6:38     ` Florian Weimer
2024-06-05 18:42       ` DJ Delorie
2024-06-14  8:14         ` Florian Weimer
2024-06-14 16:40           ` DJ Delorie
2024-06-05 18:50       ` [v3] " DJ Delorie
2024-06-14  8:21         ` Florian Weimer
2024-06-14 18:19           ` DJ Delorie
2024-06-14 18:46           ` [v4] " DJ Delorie
2024-06-18 20:13             ` Mathieu Desnoyers
2024-06-18 20:57               ` DJ Delorie
2024-06-21 13:02                 ` Mathieu Desnoyers [this message]
2024-06-21 16:17                   ` DJ Delorie
2024-06-21 16:20                     ` Mathieu Desnoyers
2024-06-19  7:16             ` Florian Weimer
2024-06-05  4:11   ` [v2] " DJ Delorie
2024-06-05  7:44     ` Andreas Schwab
2024-06-05 18:42       ` DJ Delorie

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=7b23e187-3d73-4eab-9ef6-c15679666676@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=dj@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).