Re: [net-next V8 PATCH 1/5] bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUMAP

Yann Ylavic
2017-10-18T07:46:01Z

On Mon, Oct 16, 2017 at 12:19 PM, Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
> +
> + /* Notice returns -EPERM on if map size is larger than memlock limit */
> + ret = bpf_map_precharge_memlock(cmap->map.pages);
> + if (ret) {
> + err = ret;
> + goto free_cmap;
> + }
> +
> + /* A per cpu bitfield with a bit per possible CPU in map */
> + cmap->flush_needed = __alloc_percpu(cpu_map_bitmap_size(attr),
> + __alignof__(unsigned long));
> + if (!cmap->flush_needed)
> + goto free_cmap;
> +
> + /* Alloc array for possible remote "destination" CPUs */
> + cmap->cpu_map = bpf_map_area_alloc(cmap->map.max_entries *
> + sizeof(struct bpf_cpu_map_entry *),
> + cmap->map.numa_node);
> + if (!cmap->cpu_map)

ret = -ENOMEM; ?

> + goto free_percpu;
> +
> + return &cmap->map;
> +free_percpu:
> + free_percpu(cmap->flush_needed);
> +free_cmap:
> + kfree(cmap);
> + return ERR_PTR(err);
> +}

Regards,
Yann.