Hi Daniel, On Tue, Jan 17, 2023 at 2:22 PM Daniel Müller <deso@xxxxxxxxxx> wrote: > > I apologize for the response. Somehow Andrii's reply and the entire thread was > lost on me. Anyway, glad it's working for you. > Andrii helped me get it work. TYPE_MATCHES is a solution to my problem. Now I have a better understanding on how bpf_core_type_matches works. For the record, the following works on my old kernel and new kernels: struct rw_semaphore___old { struct task_struct *owner; }; struct rw_semaphore___new { atomic_long_t owner; }; u64 owner; if (bpf_core_type_matches(struct rw_semaphore___old)) { /* owner is task_struct pointer */ struct rw_semaphore___old *old = (struct rw_semaphore___old *)sem; owner = (u64)sem->owner; } else if (bpf_core_type_matches(struct rw_semaphore___new)) { /* owner field is atomic_long_t */ struct rw_semaphore___new *new = (struct rw_semaphore___new *)sem; owner = (u64)new->owner.counter; } Thanks for your response! Hao