[DTrace-devel] [PATCH] Implement the ppid builtin D variable
Eugene Loh
eugene.loh at oracle.com
Wed Sep 16 14:48:43 PDT 2020
The other reply slipped out before I wrote anything. Sorry. Let's try
this again...
On 09/16/2020 02:02 PM, Kris Van Hees wrote:
> On Wed, Sep 16, 2020 at 02:16:33PM -0400, eugene.loh at oracle.com wrote:
>> diff --git a/bpf/get_bvar.c b/bpf/get_bvar.c
>> @@ -46,6 +46,17 @@ noinline uint64_t dt_get_bvar(dt_mstate_t *mst, uint32_t id)
>>
>> return val & 0x00000000ffffffffUL;
>> }
>> + case DIF_VAR_PPID: {
>> + uint64_t ptr = bpf_get_current_task();
>> + int32_t val = -1;
>> +
>> + if (ptr == 0)
>> + return -1;
>> +
>> + bpf_probe_read((void *) &ptr, 8, (const void *) (ptr + mst->offparent));
>> + bpf_probe_read((void *) &val, 4, (const void *) (ptr + mst->offtgid));
> I suggested storing the offsets in the 'state' map rather than the 'mem' map.
Right, sorry. But what is the 'state' map?
$ grep create_gmap libdtrace/dt_bpf.c
create_gmap(dtrace_hdl_t *dtp, const char *name, enum bpf_map_type
type,
if (create_gmap(dtp, "buffers", BPF_MAP_TYPE_PERF_EVENT_ARRAY,
ci_mapfd = create_gmap(dtp, "cpuinfo", BPF_MAP_TYPE_PERCPU_ARRAY,
ci_memfd = create_gmap(dtp, "mem", BPF_MAP_TYPE_PERCPU_ARRAY,
if (create_gmap(dtp, "strtab", BPF_MAP_TYPE_ARRAY,
create_gmap(dtp, "gvars", BPF_MAP_TYPE_ARRAY,
create_gmap(dtp, "tvars", BPF_MAP_TYPE_ARRAY,
'mstate' was the closest I found, and it's in mem.
More information about the DTrace-devel
mailing list