On Thu, 15 Aug 2019, Dmitry Safonov 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. > > Introduce vdso_static_branch_unlikely(), which is similar to > static_branch_unlikely(); alias it with timens_static_branch_unlikely() > under CONFIG_TIME_NS. > > The timens code in vdso will look like this: > > if (timens_static_branch_unlikely()) { > clk_to_ns(clk, ts); Please name that clk_to_namespace(). _ns() is widely used for nanoseconds. > } > > The version of vdso which is compiled from sources will never execute > clk_to_ns(). And then we can patch the 'no-op' in the straight-line > codepath with a 'jump' instruction to the out-of-line true branch and > get the timens version of the vdso library. Colour me confused. Why do we need that static branch at all? Why don't we compile VDSO_NO_NAMESPACE and VDSO_NAMESPACE right away? One has the clk_to_namespace() one does not. The you can spare the whole static key patching and the NO_NAMESPACE variant does not have extra 5 NOPS. The VDSO is one page IIRC, so having the extra namespace variant around does really not matter at all. Thanks, tglx