Skip to content

Commit

Permalink
bpf: store per-CPU drop counts in the 'cpuinfo' map
Browse files Browse the repository at this point in the history
Drop counters for principal and aggregation buffers are tracked per-CPU
and thus need to be stored per-CPU.  The 'cpuinfo' map is a convenient
place to put those so add them in after the actual cpuinfo data for a
given CPU.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
  • Loading branch information
kvanhees committed May 24, 2023
1 parent 394de56 commit 0b9276c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
20 changes: 10 additions & 10 deletions libdtrace/dt_bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,22 +604,22 @@ gmap_create_buffers(dtrace_hdl_t *dtp)
static int
gmap_create_cpuinfo(dtrace_hdl_t *dtp)
{
int i, fd, rc;
uint32_t key = 0;
dtrace_conf_t *conf = &dtp->dt_conf;
size_t ncpus = conf->max_cpuid + 1;
cpuinfo_t *data;
cpuinfo_t *ci;

data = dt_zalloc(dtp, ncpus * sizeof(cpuinfo_t));
int i, fd, rc;
uint32_t key = 0;
dtrace_conf_t *conf = &dtp->dt_conf;
size_t ncpus = conf->max_cpuid + 1;
dt_bpf_cpuinfo_t *data;
cpuinfo_t *ci;

data = dt_zalloc(dtp, ncpus * sizeof(dt_bpf_cpuinfo_t));
if (data == NULL)
return dt_set_errno(dtp, EDT_NOMEM);

for (i = 0, ci = &conf->cpus[0]; i < ncpus; i++, ci++)
memcpy(&data[ci->cpu_id], ci, sizeof(cpuinfo_t));
memcpy(&data[ci->cpu_id].ci, ci, sizeof(cpuinfo_t));

fd = create_gmap(dtp, "cpuinfo", BPF_MAP_TYPE_PERCPU_ARRAY,
sizeof(uint32_t), sizeof(cpuinfo_t), 1);
sizeof(uint32_t), sizeof(dt_bpf_cpuinfo_t), 1);
if (fd == -1)
return -1;

Expand Down
10 changes: 9 additions & 1 deletion libdtrace/dt_bpf_maps.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand All @@ -13,6 +13,7 @@ extern "C" {
#endif

#include <stddef.h>
#include <dtrace/conf.h>

typedef struct dt_bpf_probe dt_bpf_probe_t;
struct dt_bpf_probe {
Expand All @@ -29,6 +30,13 @@ struct dt_bpf_specs {
* drain this buffer */
};

typedef struct dt_bpf_cpuinfo dt_bpf_cpuinfo_t;
struct dt_bpf_cpuinfo {
cpuinfo_t ci;
uint64_t buf_drops;
uint64_t agg_drops;
};

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 0b9276c

Please sign in to comment.