time_bench: Benchmarking code execution time inside the kernel

A framework for benchmarking code execution time inside the kernel.

This have been imported from one of my many hanging kernel git tree
branches in the hope I don't loose it.  The PMU counter setup
is currently broken, I hope I find time to fix this later.

I plan to use this framework for micro benchmarking the performance
of different lock-less and wait-free queue implementations.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
kbuild: do more correct addition of include path

According to Documentation/kbuild/modules.txt using:
 ccflags-y := -I$(KDIR)/include

Is a more correct use of the kbuild system to add extra include paths.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Add a .gitignore file as the kernel generate lots of tmp files

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
time_bench: Disable usage of PMU as the config/setup does not work

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
time_bench_sample: Example of benchmarking execution time

Sample measures different sync primitives the kernel uses often.

The output is avail in the kernel log.

Notice "per elem" cost indicate that e.g. for locking the cost
result is actually (lock+unlock)/2.  This comes from I've used
this framework for measuring queues that allow bulking of
elements, and I wanted to measure the cost per element.

Example output on a CPU E5-2630:

time_bench: Type:lock_unlock Per elem: 19 cycles(tsc) 8.689 ns (step:0)
 - (measurement period time:1.737825818 sec time_interval:1737825818)
 - (invoke count:200000000 tsc_interval:3996996753)

time_bench: Type:local_bh Per elem: 8 cycles(tsc) 3.870 ns (step:0)
 - (measurement period time:0.774018176 sec time_interval:774018176)
 - (invoke count:200000000 tsc_interval:1780240549)

time_bench: Type:local_irq Per elem: 3 cycles(tsc) 1.452 ns (step:0)
 - (measurement period time:0.290556556 sec time_interval:290556556)
 - (invoke count:200000000 tsc_interval:668268412)

time_bench: Type:local_irq_save Per elem: 17 cycles(tsc) 7.805 ns (step:0)
 - (measurement period time:1.561088120 sec time_interval:1561088120)
 - (invoke count:200000000 tsc_interval:3590500626)

time_bench: Type:preempt Per elem: 5 cycles(tsc) 2.364 ns (step:0)
 - (measurement period time:0.472965394 sec time_interval:472965394)
 - (invoke count:200000000 tsc_interval:1087819451)

time_bench: Type:call_func Per elem: 5 cycles(tsc) 2.178 ns (step:0)
 - (measurement period time:0.217866832 sec time_interval:217866832)
 - (invoke count:100000000 tsc_interval:501093036)

time_bench: Type:call_func_ptr Per elem: 5 cycles(tsc) 2.530 ns (step:0)
 - (measurement period time:0.253031536 sec time_interval:253031536)
 - (invoke count:100000000 tsc_interval:581971841)

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>