perf stat: Enable counters when collecting process-wide or system-wide data
perf stat: Enable counters when collecting process-wide or system-wide data

Command 'perf stat' doesn't enable counters when collecting an
existing (by -p) process or system-wide statistics. Fix the
issue.

Change the condition of fork/exec subcommand. If there is a
subcommand parameter, perf always forks/execs it. The usage
example is:

 # perf stat -a sleep 10

So this command could collect statistics for 10 seconds
precisely. User still could stop it by CTRL+C. Without the new
capability, user could only use CTRL+C to stop it without
precise time clock.

Another issue is 'perf stat -a' consumes 100% time of a full
single logical cpu. It has a bad impact on running workload.

Fix it by adding a sleep(1) in the while(!done) loop in function
run_perf_stat.

Signed-off-by: Zhang Yanmin <232a135a0093779c691103f08ca7218045d46eb9@linux.intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <293abb6b76d7791c0732cc517d38c4b5c734b87f@redhat.com>
Cc: Avi Kivity <8f920f22884d6fea9df883843c4a8095a2e5ac6f@redhat.com>
Cc: Peter Zijlstra <645ca7d3a8d3d4f60557176cd361ea8351edc32b@chello.nl>
Cc: Sheng Yang <72968c211adb68bbedf8fc6c85be24c9cd49b112@linux.intel.com>
Cc: Marcelo Tosatti <958bcd1f4a7a8c36dca09fe3fa9cb5f1483adf51@redhat.com>
Cc: Joerg Roedel <4688a6871ff025801033b3c4b039d55a29f8f937@8bytes.org>
Cc: Jes Sorensen <0e1e349bdba396f044a06b01fef702e072aa66d3@redhat.com>
Cc: Gleb Natapov <03189597947f75187c4136ade35aec34feed9dc1@redhat.com>
Cc: Zachary Amsden <42ecf5e41ede111a9c9d6c29e7b00a556e2f1d34@redhat.com>
Cc: <9dcafbcbfce2797bd03f6187e98acab45e4475fa@intel.com>
LKML-Reference: <472a97d120768e1af452b9bfcdb890fbfd78b4d3@infradead.org>
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>

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