Re: [INFO] ratio of const vs dynamic usercopy

From: Josh Poimboeuf
Date: Tue Sep 20 2016 - 10:19:13 EST

On Mon, Sep 19, 2016 at 09:58:39PM -0700, Kees Cook wrote:
> Hi,
> Al had asked me a couple weeks back what the ratio of const vs dynamic
> usercopying was. With Josh's cleanup and my fix-up to only call the
> hardened usercopy when non-const, I can actually gather these statistics
> on a build. It's a bit of a hack (see attached patch that should not go
> into the tree), but with my not-very-defconfig, it's rougly 2 to 1 const
> vs dynamic. However, this doesn't take into account the frequency at
> _runtime_, which maybe could be discovered via perf comparing copy*user()
> calls to __check_object_size() calls, but I didn't try that. Does someone
> have perf setup to check this?

Maybe do something like this with your patch?

trace-cmd record -p function -l __check_object_size -l __skip_check_object_size [command you want to benchmark]
trace-cmd report