Re: [PATCH v6 perf,bpf 07/15] perf, bpf: save bpf_prog_info information as headers to perf.data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On Mar 7, 2019, at 6:05 AM, Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> 
> On Tue, Mar 05, 2019 at 11:13:51PM -0800, Song Liu wrote:
> 
> SNIP
> 
>> +static int process_bpf_prog_info(struct feat_fd *ff,
>> +				 void *data __maybe_unused)
>> +{
>> +	struct bpf_prog_info_linear *info_linear;
>> +	struct bpf_prog_info_node *info_node;
>> +	struct perf_env *env = &ff->ph->env;
>> +	u32 count, i;
>> +	int err = -1;
>> +
>> +	if (do_read_u32(ff, &count))
>> +		return -1;
>> +
>> +	if (ff->ph->needs_swap)
>> +		pr_warning("interpreting bpf_prog_info from systems with endianity is not yet supported\n");
> 
> 		return 0; ?
> 
> what's here to process?
> 
> jirka

Aha, I didn't notice the lseek() call in perf_file_section__process(), 
so I was thinking we need to keep proper offset. With the lseek(), 
this is not necessary. 

I will fix it in the next version. 

Thanks,
Song

>> +
>> +	down_write(&env->bpf_progs.lock);
>> +
>> +	for (i = 0; i < count; ++i) {
>> +		u32 info_len, data_len;
>> +
>> +		info_linear = NULL;
>> +		info_node = NULL;
>> +		if (do_read_u32(ff, &info_len))
>> +			goto out;
>> +		if (do_read_u32(ff, &data_len))
>> +			goto out;
>> +
>> +		if (info_len > sizeof(struct bpf_prog_info)) {
>> +			pr_warning("detected invalid bpf_prog_info\n");
>> +			goto out;
>> +		}
>> +
>> +		info_linear = malloc(sizeof(struct bpf_prog_info_linear) +
>> +				     data_len);
>> +		if (!info_linear)
>> +			goto out;
>> +		info_linear->info_len = sizeof(struct bpf_prog_info);
>> +		info_linear->data_len = data_len;
>> +		if (do_read_u64(ff, (u64 *)(&info_linear->arrays)))
>> +			goto out;
>> +		if (__do_read(ff, &info_linear->info, info_len))
>> +			goto out;
>> +		if (info_len < sizeof(struct bpf_prog_info))
>> +			memset(((void *)(&info_linear->info)) + info_len, 0,
>> +			       sizeof(struct bpf_prog_info) - info_len);
>> +
>> +		if (__do_read(ff, info_linear->data, data_len))
>> +			goto out;
>> +
>> +		/* endian mismatch, drop the info, continue */
>> +		if (ff->ph->needs_swap) {
>> +			free(info_linear);
>> +			continue;
>> +		}
>> +
>> +		info_node = malloc(sizeof(struct bpf_prog_info_node));
>> +		if (!info_node)
>> +			goto out;
>> +
>> +		/* after reading from file, translate offset to address */
>> +		bpf_program__bpil_offs_to_addr(info_linear);
>> +		info_node->info_linear = info_linear;
>> +		perf_env__insert_bpf_prog_info(env, info_node);
>> +	}
>> +
>> +	return 0;
>> +out:
>> +	free(info_linear);
>> +	free(info_node);
>> +	up_write(&env->bpf_progs.lock);
>> +	return err;
>> +}
> 
> SNIP





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux