public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Szabolcs Nagy via Libc-alpha <libc-alpha@sourceware.org>
Cc: Szabolcs Nagy <szabolcs.nagy@arm.com>
Subject: Re: [PATCH 5/5] nptl: Add public rseq symbols and <sys/rseq.h>
Date: Tue, 07 Dec 2021 12:28:56 +0100	[thread overview]
Message-ID: <87pmq8k613.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20211207110142.GD3294453@arm.com> (Szabolcs Nagy via Libc-alpha's message of "Tue, 7 Dec 2021 11:01:42 +0000")

* Szabolcs Nagy via Libc-alpha:

>> +One use of the restartable sequences area is to read the current CPU
>> +number from its @code{cpu_id} field, as an inline version of
>> +@code{sched_getcpu}.  @Theglibc{} sets the @code{cpu_id} field to
>> +@code{RSEQ_CPU_ID_REGISTRATION_FAILED} if registration failed or was
>> +explicitly disabled.
>
> is it better to use RSEQ_CPU_ID_UNINITIALIZED for the disabled case?
>
> so code that uses rseq itself can distinguish enabled but failed rseq
> and disabled rseq (in the latter case it would try to register, in the
> former it would assume rseq is not supported).

I think RSEQ_CPU_ID_UNINITIALIZED was previously intended for a scenario
that is just not observable at all in the current glibc implementation,
basically an initialization ordering issue.

My expectation is that an application that knows about glibc's rseq
implementation will not want to use rseq if it has been explicitly
disabled.  That tunable is only for getting old rseq users to work
again.  If the application goes behind glibc's back and starts rseq
using again, it defeats the tunable (because there could be another rseq
user in the process image).

>> +@deftypevar {int} __rseq_offset
>> +@standards{Linux, sys/rseq.h}
>> +This variable contains the offset between the thread pointer (as defined
>> +by @code{__builtin_thread_pointer} or the thread pointer register for
>> +the architecture) and the restartable sequences area.  This value is the
>> +same for all threads in the process.  If the restartable sequences area
>> +is located at a lower address than the location to whic the  thread
>
> s/whic/which/
>
>> +pointer points, the value is negative.
>> +@end deftypevar
>> +
>> +@deftypevar {int} __rseq_size
>
> declaration below uses unsigned int.
>
>> +@standards{Linux, sys/rseq.h}
>> +This variable is either zero (if restartable sequence registration
>> +failed or has been disabled) or the size of the restartable sequence
>> +registration.  This can be less can be different from the size of
>
> s/can be less//
>
>> +@code{struct rseq} if the kernel has extended the size of the
>> +registration.  If registration is successful, @code{__rseq_size} is at
>> +least 32 (the initial size of @code{struct rseq}.
>
> missing )

All fixed, thanks.

>> +@end deftypevar
>> +
>> +@deftypevar {unsigned int} __rseq_flags
>> +@standards{Linux, sys/rseq.h}
>> +The flags used during restartable sequence registration with the kernel.
>
> the syscall argument is documented to be int and our header
> declares it as enum rseq_flags, not sure if this matters.

It shouldn't matter, unsigned int seems more conservative.  I'm always a
bit wary about enums and bitmasks.

Thanks,
Florian


  reply	other threads:[~2021-12-07 11:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-06 13:45 [PATCH 0/5] Extensible rseq support for glibc Florian Weimer
2021-12-06 13:46 ` [PATCH 1/5] nptl: Add <thread_pointer.h> for defining __thread_pointer Florian Weimer
2021-12-06 16:44   ` Mathieu Desnoyers
2021-12-06 17:01     ` Florian Weimer
2021-12-06 19:55       ` Florian Weimer
2021-12-06 13:46 ` [PATCH 2/5] nptl: Add rseq registration Florian Weimer
2021-12-06 16:53   ` Mathieu Desnoyers
2021-12-06 17:10     ` Florian Weimer
2021-12-06 16:59   ` Mathieu Desnoyers
2021-12-06 17:14     ` Florian Weimer
2021-12-06 18:52       ` Mathieu Desnoyers
2021-12-06 19:03         ` Florian Weimer
2021-12-06 20:11           ` Paul E. McKenney
2021-12-06 20:26             ` Florian Weimer
2021-12-06 21:08               ` Paul E. McKenney
2021-12-06 13:46 ` [PATCH 3/5] Linux: Use rseq to accelerate sched_getcpu Florian Weimer
2021-12-06 16:50   ` Szabolcs Nagy
2021-12-06 17:06     ` Florian Weimer
2021-12-06 17:45       ` Szabolcs Nagy
2021-12-07 15:48         ` Florian Weimer
2021-12-06 13:46 ` [PATCH 4/5] nptl: Add glibc.pthread.rseq tunable to control rseq registration Florian Weimer
2021-12-06 13:53 ` [PATCH 5/5] nptl: Add public rseq symbols and <sys/rseq.h> Florian Weimer
2021-12-07 11:01   ` Szabolcs Nagy
2021-12-07 11:28     ` Florian Weimer [this message]
2021-12-06 16:13 ` [PATCH 0/5] Extensible rseq support for glibc Mathieu Desnoyers

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=87pmq8k613.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=szabolcs.nagy@arm.com \
    /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).