x86, bts: fix race when bts tracer is removed
x86, bts: fix race when bts tracer is removed

When the bts tracer is removed while the traced task is running,
the write to clear the bts tracer pointer races with context switch code.

Read the tracer once during a context switch.

When a new tracer is installed, the bts tracer is set in the ds context
before the tracer is initialized in order to claim the context for that
tracer.

This may result in write accesses using an uninitialized trace configuration
when scheduling timestamps have been requested.

Store active tracing flags separately and only set active flags after
the tracing configuration has been initialized.

Reviewed-by: Oleg Nesterov <20b70f0af00562e63758b9ee42012ecc96c58590@redhat.com>
Signed-off-by: Markus Metzger <5f675b2b36595f90898e014b548ff7d9bbff2ab7@intel.com>
Cc: 0d270388f2f92757a5de0f4bd891d3b392c44c4f@redhat.com
Cc: f199ae9781930a5b94b284ca2f471140752002a7@googlemail.com
Cc: 456eeec121e9ca822312e63cde01787382ccd416@intel.com
Cc: 0474aee45985f5ae829f53849df476200e876990@linux.jf.intel.com
LKML-Reference: <4564533e800002b5c2cf4a56abf7c6c4d71df5b2@intel.com>
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas