Remove unused map-of-maps functions
PATCH 1/1 Remove unused map-of-maps functions
From: Eugene Loh <[email protected]>
--- libdtrace/dt_bpf.c | 57 ---------------------------------------------- libdtrace/dt_bpf.h | 5 ---- 2 files changed, 62 deletions(-)
libdtrace/dt_bpf.c +0 -57
@@ -341,63 +341,6 @@ dt_bpf_map_update(int fd, const void *key, const void *val)return dt_bpf (BPF_MAP_UPDATE_ELEM , &attr); } -/* -* Retrieve the fd for a map-in-map, i.e. map[okey] which is the fd of a map. -* -* Note: the caller is responsible for closing the fd. -*/ -int -dt_bpf_map_lookup_fd (int fd,const void *okey) -{ -uint32_t id; - -if (dt_bpf_map_lookup (fd, okey, &id) <0 ) -return -1 ; - -return dt_bpf_map_get_fd_by_id (id); -} - -/* -* Retrieve the value in a map-of-maps, i.e. map[okey][ikey]. -*/ -int -dt_bpf_map_lookup_inner (int fd,const void *okey,const void *ikey,void *val) -{ -int rc; - - fd =dt_bpf_map_lookup_fd (fd, okey); -if (fd <0 ) -return -1 ; - - rc =dt_bpf_map_lookup (fd, ikey, val); -close (fd); - -return rc; -} - -/* -* Store the value in a map-of-maps, i.e. map[okey][ikey] = value. -*/ -int -dt_bpf_map_update_inner (int fd,const void *okey,const void *ikey, -const void *val) -{ -uint32_t id; -int rc; - -if (dt_bpf_map_lookup (fd, okey, &id) <0 ) -return -1 ; - - fd =dt_bpf_map_get_fd_by_id (id); -if (fd <0 ) -return -1 ; - - rc =dt_bpf_map_update (fd, ikey, val); -close (fd); - -return rc; -} -/* * Associate a BPF program (by fd) with a raw tracepoint. */
libdtrace/dt_bpf.h +0 -5
@@ -80,11 +80,6 @@ extern int dt_bpf_map_next_key(int fd, const void *key, void *nxt);extern int dt_bpf_map_update (int fd,const void *key,const void *val);extern int dt_bpf_map_delete (int fd,const void *key);extern int dt_bpf_map_get_fd_by_id (uint32_t id); -extern int dt_bpf_map_lookup_fd (int fd,const void *okey); -extern int dt_bpf_map_lookup_inner (int fd,const void *okey,const void *ikey, -void *val); -extern int dt_bpf_map_update_inner (int fd,const void *okey,const void *ikey, -const void *val); extern int dt_bpf_prog_attach(enum bpf_prog_type ptype, enum bpf_attach_type atype, int btf_fd, uint32_t btf_id, const dtrace_difo_t *dp,
Signature · 1 line
2.43.5
On 1 May 2025, eugene loh outgrape:
Quoted 3 lines
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>
Signature · 1 line
NULL && (void)
Quoted 7 lines · Nick Alcock
On 1 May 2025, eugene loh outgrape:
Quoted 3 lines
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>Reviewed-by Nick Alcock <[email protected]>
While in general I am all for removing unused function, I would actually prefer to keep these because they are part of our BPF library and likely to be of use in the future. Yes, we could always revert this, but it is probably more likely that we would end up re-implementing them because we forgot they ever existed. Since we implement our own library to interact with the BPF subsystem, having some extra functions around for now for functionality that isn't immediately trivial to implement when you deal with inner maps for the first time, can be useful.