lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 30 Aug 2021 17:41:46 +0000
From:   Song Liu <songliubraving@...com>
To:     Peter Zijlstra <peterz@...radead.org>
CC:     "open list:BPF (Safe dynamic programs and tools)" 
        <bpf@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>,
        "acme@...nel.org" <acme@...nel.org>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "kjain@...ux.ibm.com" <kjain@...ux.ibm.com>,
        Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH v2 bpf-next 1/3] perf: enable branch record for software
 events



> On Aug 30, 2021, at 3:22 AM, Peter Zijlstra <peterz@...radead.org> wrote:
> 
> On Thu, Aug 26, 2021 at 03:13:04PM -0700, Song Liu wrote:
>> +int dummy_perf_snapshot_branch_stack(struct perf_branch_snapshot *br_snapshot);
>> +
>> +DECLARE_STATIC_CALL(perf_snapshot_branch_stack, dummy_perf_snapshot_branch_stack);
>> +
>> #endif /* _LINUX_PERF_EVENT_H */
>> diff --git a/kernel/events/core.c b/kernel/events/core.c
>> index 011cc5069b7ba..c53fe90e630ac 100644
>> --- a/kernel/events/core.c
>> +++ b/kernel/events/core.c
>> @@ -13437,3 +13437,6 @@ struct cgroup_subsys perf_event_cgrp_subsys = {
>> 	.threaded	= true,
>> };
>> #endif /* CONFIG_CGROUP_PERF */
>> +
>> +DEFINE_STATIC_CALL_NULL(perf_snapshot_branch_stack,
>> +			dummy_perf_snapshot_branch_stack);
> 
> This isn't right...
> 
> The whole dummy_perf_snapshot_branch_stack() thing is a declaration only
> and used as a typedef. Also, DEFINE_STATIC_CALL_NULL() and
> static_call_cond() rely on a void return value, which it doesn't have.
> 
> Did you want:
> 
>  DECLARE_STATIC_CALL(perf_snapshot_branch_stack, void (*)(struct perf_branch_snapshot *));
> 
>  DEFINE_STATIC_CALL_NULL(perf_snapshot_branch_stack, void (*)(struct perf_branch_snapshot *));
> 
>  static_call_cond(perf_snapshot_branch_stack)(...);
> 
> *OR*, do you actually need that return value, in which case you're
> probably looking for:
> 
>  DECLARE_STATIC_CALL(perf_snapshot_branch_stack, int (*)(struct perf_branch_snapshot *));
> 
>  DEFINE_STATIC_CALL_RET0(perf_snapshot_branch_stack, int (*)(struct perf_branch_snapshot *));
> 
>  ret = static_call(perf_snapshot_branch_stack)(...);
> 
> ?

Hmmm... something doesn't work here. I have:

/* include/linux/perf_event.h */
DECLARE_STATIC_CALL(perf_snapshot_branch_stack,
                   int (*)(struct perf_branch_snapshot *));


/* kernel/events/core.c */
DEFINE_STATIC_CALL_RET0(perf_snapshot_branch_stack,
                       int (*)(struct perf_branch_snapshot *));

/* kernel/bpf/trampoline.c */
       if (prog->call_get_branch)
               static_call(perf_snapshot_branch_stack)(
                       this_cpu_ptr(&bpf_perf_branch_snapshot));

/* arch/x86/events/intel/core.c */
       if (x86_pmu.disable_all == intel_pmu_disable_all)
               static_call_update(perf_snapshot_branch_stack,
                                  intel_pmu_snapshot_branch_stack);

And the compiler keeps complain with:

arch/x86/events/intel/core.c: In function ‘intel_pmu_init’:
./include/linux/static_call.h:121:41: error: initialization of ‘int (**)(struct perf_branch_snapshot *)’ from incompatible pointer type ‘int (*)(struct perf_branch_snapshot *)’ [-Werror=incompatible-pointer-type ]
  typeof(&STATIC_CALL_TRAMP(name)) __F = (func);   \
                                         ^
arch/x86/events/intel/core.c:6305:4: note: in expansion of macro ‘static_call_update’
    static_call_update(perf_snapshot_branch_stack,
    ^~~~~~~~~~~~~~~~~~


Something like 

typedef int (perf_snapshot_branch_stack_t)(struct perf_branch_snapshot *);
DECLARE_STATIC_CALL(perf_snapshot_branch_stack, perf_snapshot_branch_stack_t);

seems to work fine. 

Thanks,
Song

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ