Skip to content

ioctl: allow common operations without allocations #3726

Open
@lmb

Description

@lmb

Describe the feature you'd like supported

Operations like looking up a map value via EBPF_OPERATION_MAP_FIND_ELEMENT are currently forced to allocate a buffer because of the way that the request structure is defined:

typedef struct _ebpf_operation_map_find_element_request
{
struct _ebpf_operation_header header;
ebpf_handle_t handle;
bool find_and_delete;
uint8_t key[1];
} ebpf_operation_map_find_element_request_t;

The key is appended to the request buffer. This means that the caller has to allocate memory and perform copying. This is especially bad for batch operations where the amount if memory to be allocated and copied is larger:

typedef struct _ebpf_operation_map_update_element_batch_request
{
struct _ebpf_operation_header header;
ebpf_handle_t handle;
ebpf_map_option_t option;
// Count of elements is derived from the length of the request.
// Data is a concatenation of key+value.
uint8_t data[1];
} ebpf_operation_map_update_element_batch_request_t;

It would be nice if common performance critical map operations could be implemented without allocations.

Proposed solution

This could be achieved by making map keys and values pointers, like it is done for struct bpf_prog_info:

uintptr_t map_ids; ///< Pointer to caller-allocated array to fill map IDs into.

Additional context

No response

Metadata

Metadata

Assignees

Labels

P2optimizationAffects perf but not correctness or applicabilitytriagedDiscussed in a triage meeting

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions