perf mem: Rework command option handling
Split the common option and ones for record or report. Otherwise -U in
the record option cannot be used because it clashes with in the common
(or report) option. Also rename report_events() to __cmd_report() to
follow the convention and to be sync with the record part.
Also set the flag PARSE_OPT_STOP_AT_NON_OPTION for the common option so
that it can show the help message in the subcommand like below:
$ perf mem record -h
Usage: perf mem record [<options>] [<command>]
or: perf mem record [<options>] -- <command> [<options>]
-C, --cpu <cpu> list of cpus to profile
-e, --event <event> event selector. use 'perf mem record -e list' to list available events
-f, --force don't complain, do it
-K, --all-kernel collect only kernel level data
-p, --phys-data Record/Report sample physical addresses
-t, --type <type> memory operations(load,store) Default load,store
-U, --all-user collect only user level data
-v, --verbose be more verbose (show counter open errors, etc)
--data-page-size Record/Report sample data address page size
--ldlat <n> mem-loads latency
Cc: Aditya Gupta <adityag@linux.ibm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20240731235505.710436-4-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>