Re: [PATCHv5 28/37] x86/vdso: Enable static branches for the timens vdso

From: Andy Lutomirski
Date: Thu Aug 01 2019 - 01:21:51 EST


On Mon, Jul 29, 2019 at 2:58 PM Dmitry Safonov <dima@xxxxxxxxxx> wrote:
>
> From: Andrei Vagin <avagin@xxxxxxxxx>
>
> As it has been discussed on timens RFC, adding a new conditional branch
> `if (inside_time_ns)` on VDSO for all processes is undesirable.
>
> Addressing those problems, there are two versions of VDSO's .so:
> for host tasks (without any penalty) and for processes inside of time
> namespace with clk_to_ns() that subtracts offsets from host's time.
>
> The timens code in vdso looks like this:
>
> if (timens_static_branch_unlikely()) {
> clk_to_ns(clk, ts);
> }

I'm confused. Now we effectively have *three* versions: the vDSO
without timens, and vDSO with timens but with it switched off, and the
vDSO with timens on. This seems like too much.

What you need is, IMO, a static-branch-ish thing that is per mm. This
has a fundamental problem that the vDSO can be modified using
FOLL_FORCE. Perhaps any CoW of the vDSO should implicitly switch the
static branch on, which at least gives some degree of correctness even
if it's a bit surprising.

--Andy