in profiler/stack_printer.cpp [47:85]
static bool read_batch_counts_map(int fd, struct key_ext_t *items, __u32 *count)
{
void *in = NULL, *out;
__u32 i, n, n_read = 0;
int err = 0;
__u32 vals[*count];
struct stack_key keys[*count];
while (n_read < *count && !err)
{
n = *count - n_read;
err = bpf_map_lookup_batch(fd, &in, &out, keys + n_read,
vals + n_read, &n, NULL);
if (err && errno != ENOENT)
{
/* we want to propagate EINVAL upper, so that
* the batch_map_ops flag is set to false */
if (errno != EINVAL)
warn("bpf_map_lookup_batch: %s\n",
strerror(-err));
return false;
}
n_read += n;
in = out;
}
for (i = 0; i < n_read; i++)
{
items[i].k.pid = keys[i].pid;
items[i].k.kernel_ip = keys[i].kernel_ip;
items[i].k.user_stack_id = keys[i].user_stack_id;
items[i].k.kern_stack_id = keys[i].kern_stack_id;
strncpy(items[i].k.name, keys[i].name, TASK_COMM_LEN);
items[i].v = vals[i];
}
*count = n_read;
return true;
}