kmod/core: protect kpatch_[un]register with mutex

Use a mutex in the register/unregister functions to protect changes to
kpatch_num_registered, kpatch_func_hash and calls to the ftrace
functions by other register/unregister invocations.
kmod/core: improve performance for cumulative patching

When multiple patch modules patch the same function, there's no need to
patch all the intermediate functions.  Just hook them all into the
original function and use the ftrace handler to find the newest one.

Also use a mutex in the register/unregister functions to protect changes
to kpatch_num_registered, kpatch_func_hash and calls to the ftrace
functions by other register/unregister invocations.
readme: small clarification about contributing
Merge pull request #70 from jpoimboe/readme-contributions

readme: small clarification about contributing
Merge pull request #69 from jpoimboe/core-cumulative-performance

kmod/core: improve performance for cumulative patching
error on symbol ambiguity in link-vmlinux-syms

Like in add-patches-section, we should continue to
search the vmlinux symbol table to see if there
is a duplicate global symbol.  This normally would
not be possible, however, because create-diff-object
modifies unchanged local functions to be global
as a hack so they can be linked, there is a chance
that these symbols could collide with an existing
global symbol.  We should detect this case and error
out.

Hopefully we can figure out a way to avoid this
situation altogether.  But for now, this is a
protection against improper linking.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
Merge pull request #71 from spartacus06/fixes

error on symbol ambiguity in link-vmlinux-syms
add-patches-section: detect no patched functions
kmod/core: add "notrace" to ftrace handler

The ftrace handler needs the notrace annotation so that ftrace won't
trace it and get into a recursive loop.
Merge pull request #72 from jpoimboe/no-patched-functions

add-patches-section: detect no patched functions
Merge pull request #73 from jpoimboe/core-notrace

kmod/core: add "notrace" to ftrace handler
add uninstall target

Make it easy to clean up an install

Signed-off-by: Seth Jennings <sjenning@redhat.com>
Merge pull request #74 from spartacus06/uninstall

add uninstall target
order local FUNC syms before SECTION syms

ld drops FUNC syms that appear after the last SECTION
sym in the symbol table.

Make sure we order the FUNC syms before the SECTION syms.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
refactor copying symbols to output

Create a new function kpatch_copy_symbols() that copies symbols from
one kelf to another if the "select" function to return true for the
symbol.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
Merge pull request #75 from spartacus06/symorder

order local FUNC syms before SECTION syms
Add -c|--config option to kpatch-build

In some circumstances, the kernel is built outside from the source tree,
thus we should specify the .config file of build path.

This patch changes the basic option parsing by using getopt, and add more
information in usage().

Signed-off-by: Jincheng Miao <jincheng.miao@gmail.com>
Merge pull request #77 from ryanmiao/master

Add -c|--config option to kpatch-build
readme: add more detail to limitations section
Merge pull request #78 from jpoimboe/readme-limitations

readme: add more detail to limitations section