All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hao Luo <haoluo@google.com>
To: "Daniel Müller" <deso@posteo.net>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@google.com>, Jiri Olsa <jolsa@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	kernel-team@meta.com
Subject: Re: CORE feature request: support checking field type directly
Date: Tue, 17 Jan 2023 16:55:44 -0800	[thread overview]
Message-ID: <CA+khW7gFq3VKEvF7hZXQsLJagz=HMZ4kJwh=QdmFG1pFbq1xRw@mail.gmail.com> (raw)
In-Reply-To: <20230117222158.uyezr5ab72ck5fhv@muellerd-fedora-PC2BDTX9>

Hi Daniel,

On Tue, Jan 17, 2023 at 2:22 PM Daniel Müller <deso@posteo.net> 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

  reply	other threads:[~2023-01-18  1:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12 22:18 CORE feature request: support checking field type directly Hao Luo
2023-01-13 23:41 ` Andrii Nakryiko
2023-01-14  1:06   ` Hao Luo
2023-01-14  1:14     ` Andrii Nakryiko
2023-01-14  2:19       ` Hao Luo
2023-01-14  2:44         ` Andrii Nakryiko
2023-01-17 18:45           ` Hao Luo
2023-01-17 21:56 ` Daniel Müller
2023-01-17 22:21   ` Daniel Müller
2023-01-18  0:55     ` Hao Luo [this message]
2023-01-31  6:06       ` Namhyung Kim
2023-01-31 16:46         ` Daniel Müller
2023-01-31 19:58           ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+khW7gFq3VKEvF7hZXQsLJagz=HMZ4kJwh=QdmFG1pFbq1xRw@mail.gmail.com' \
    --to=haoluo@google.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=deso@posteo.net \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kpsingh@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.