Re: [PATCH v2 1/8] perf/x86: add a function to get the lbr stack

2018-09-07 Thread Wei Wang

On 09/07/2018 11:28 AM, Andi Kleen wrote:

+int perf_get_lbr_stack(struct perf_lbr_stack *stack)
+{
+   stack->lbr_nr = x86_pmu.lbr_nr;
+   stack->lbr_tos = x86_pmu.lbr_tos;
+   stack->lbr_from = x86_pmu.lbr_from;
+   stack->lbr_to = x86_pmu.lbr_to;
+
+   if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
+   stack->lbr_info = MSR_LBR_INFO_0;
+   else
+   stack->lbr_info = 0;

Seems weird to export the enum value if the enum isn't exported.
How can it be used?



I'm not sure about the issue. The caller gets the value of 
MSR_LBR_INFO_0 (not the enum, LBR_FORMAT_INFO) only when the hardware 
supports it. If hardware doesn't support it, just sets it to 0, and 
there will be no lbr info msr to be passed through.


Best,
Wei


Re: [PATCH v2 1/8] perf/x86: add a function to get the lbr stack

2018-09-07 Thread Wei Wang

On 09/07/2018 11:28 AM, Andi Kleen wrote:

+int perf_get_lbr_stack(struct perf_lbr_stack *stack)
+{
+   stack->lbr_nr = x86_pmu.lbr_nr;
+   stack->lbr_tos = x86_pmu.lbr_tos;
+   stack->lbr_from = x86_pmu.lbr_from;
+   stack->lbr_to = x86_pmu.lbr_to;
+
+   if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
+   stack->lbr_info = MSR_LBR_INFO_0;
+   else
+   stack->lbr_info = 0;

Seems weird to export the enum value if the enum isn't exported.
How can it be used?



I'm not sure about the issue. The caller gets the value of 
MSR_LBR_INFO_0 (not the enum, LBR_FORMAT_INFO) only when the hardware 
supports it. If hardware doesn't support it, just sets it to 0, and 
there will be no lbr info msr to be passed through.


Best,
Wei


Re: [PATCH v2 1/8] perf/x86: add a function to get the lbr stack

2018-09-06 Thread Andi Kleen
> +int perf_get_lbr_stack(struct perf_lbr_stack *stack)
> +{
> + stack->lbr_nr = x86_pmu.lbr_nr;
> + stack->lbr_tos = x86_pmu.lbr_tos;
> + stack->lbr_from = x86_pmu.lbr_from;
> + stack->lbr_to = x86_pmu.lbr_to;
> +
> + if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
> + stack->lbr_info = MSR_LBR_INFO_0;
> + else
> + stack->lbr_info = 0;

Seems weird to export the enum value if the enum isn't exported.
How can it be used?

-Andi


Re: [PATCH v2 1/8] perf/x86: add a function to get the lbr stack

2018-09-06 Thread Andi Kleen
> +int perf_get_lbr_stack(struct perf_lbr_stack *stack)
> +{
> + stack->lbr_nr = x86_pmu.lbr_nr;
> + stack->lbr_tos = x86_pmu.lbr_tos;
> + stack->lbr_from = x86_pmu.lbr_from;
> + stack->lbr_to = x86_pmu.lbr_to;
> +
> + if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
> + stack->lbr_info = MSR_LBR_INFO_0;
> + else
> + stack->lbr_info = 0;

Seems weird to export the enum value if the enum isn't exported.
How can it be used?

-Andi