lkml.org 
[lkml]   [2016]   [Sep]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 net-next 2/6] bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type
On Wed, Aug 31, 2016 at 02:50:39PM -0700, Alexei Starovoitov wrote:
> +static u32 pe_prog_convert_ctx_access(enum bpf_access_type type, int dst_reg,
> + int src_reg, int ctx_off,
> + struct bpf_insn *insn_buf,
> + struct bpf_prog *prog)
> +{
> + struct bpf_insn *insn = insn_buf;
> +
> + BUILD_BUG_ON(FIELD_SIZEOF(struct perf_sample_data, period) != sizeof(u64));
> + switch (ctx_off) {
> + case offsetof(struct bpf_perf_event_data, sample_period):
> + *insn++ = BPF_LDX_MEM(bytes_to_bpf_size(FIELD_SIZEOF(struct bpf_perf_event_data_kern, data)),
> + dst_reg, src_reg,
> + offsetof(struct bpf_perf_event_data_kern, data));
> + *insn++ = BPF_LDX_MEM(BPF_DW, dst_reg, dst_reg,
> + offsetof(struct perf_sample_data, period));
> + break;

OK, so that deals with us moving the period field in the structure, and
break compile if we'd change its size or remove it outright (highly
unlikely). In that latter case we can change this code to simply return
a (u64)0 and things would continue to 'work'.

Did I understand that correctly?

\
 
 \ /
  Last update: 2016-09-17 09:58    [W:0.095 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site