All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: Kees Cook <keescook@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
	Petr Mladek <pmladek@suse.com>,
	Peter Ziljstra <peterz@infradead.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Valentin Schneider <valentin.schneider@arm.com>,
	qiang.zhang@windriver.com, robdclark@chromium.org,
	Christian Brauner <christian@brauner.io>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Ingo Molnar <mingo@redhat.com>,
	juri.lelli@redhat.com,
	Vincent Guittot <vincent.guittot@linaro.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>, Martin Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	john fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	"linux-perf-use." <linux-perf-users@vger.kernel.org>,
	linux-fsdevel@vger.kernel.org,
	open list <linux-kernel@vger.kernel.org>,
	oliver.sang@intel.com, kbuild test robot <lkp@intel.com>
Subject: Re: [PATCH v5 11/15] tools/bpf/bpftool: use TASK_COMM_LEN_16 instead of hard-coded 16
Date: Thu, 21 Oct 2021 15:38:10 -0700	[thread overview]
Message-ID: <CAEf4BzbLzVEXd0FO6MRuVJA=CO7zbgSrx8c0JcuR_1K=bq1OcA@mail.gmail.com> (raw)
In-Reply-To: <20211021034603.4458-2-laoar.shao@gmail.com>

On Wed, Oct 20, 2021 at 8:46 PM Yafang Shao <laoar.shao@gmail.com> wrote:
>
> Use TASK_COMM_LEN_16 instead of hard-coded 16 to make it more grepable.
> It uses bpf_probe_read_kernel() to get task comm, which may return a
> string without nul terminator. We should use bpf_probe_read_kernel_str()
> instead.
>
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Petr Mladek <pmladek@suse.com>
> ---
>  tools/bpf/bpftool/Makefile                | 1 +
>  tools/bpf/bpftool/main.h                  | 3 ++-
>  tools/bpf/bpftool/skeleton/pid_iter.bpf.c | 4 ++--
>  tools/bpf/bpftool/skeleton/pid_iter.h     | 4 +++-
>  4 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> index d73232be1e99..33fbde84993c 100644
> --- a/tools/bpf/bpftool/Makefile
> +++ b/tools/bpf/bpftool/Makefile
> @@ -164,6 +164,7 @@ $(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF)
>         $(QUIET_CLANG)$(CLANG) \
>                 -I$(if $(OUTPUT),$(OUTPUT),.) \
>                 -I$(srctree)/tools/include/uapi/ \
> +               -I$(srctree)/tools/include/ \

bpftool shouldn't rely on internal kernel headers for compilation. If
you want to have TASK_COMM_LEN_16 constant for grep-ability, just
#define it where appropriate

>                 -I$(LIBBPF_PATH) \
>                 -I$(srctree)/tools/lib \
>                 -g -O2 -Wall -target bpf -c $< -o $@ && $(LLVM_STRIP) -g $@
> diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h
> index 90caa42aac4c..5efa27188f68 100644
> --- a/tools/bpf/bpftool/main.h
> +++ b/tools/bpf/bpftool/main.h
> @@ -12,6 +12,7 @@
>  #include <linux/compiler.h>
>  #include <linux/kernel.h>
>  #include <linux/hashtable.h>
> +#include <linux/sched/task.h>
>  #include <tools/libc_compat.h>
>

[...]

  reply	other threads:[~2021-10-21 22:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21  3:45 [PATCH v5 10/15] tools/lib/perf: use TASK_COMM_LEN_16 instead of hard-coded 16 Yafang Shao
2021-10-21  3:45 ` [PATCH v5 11/15] tools/bpf/bpftool: " Yafang Shao
2021-10-21 22:38   ` Andrii Nakryiko [this message]
2021-10-21  3:46 ` [PATCH v5 12/15] tools/perf/test: make perf test adopt to task comm size change Yafang Shao
2021-10-21  3:46 ` [PATCH v5 13/15] tools/testing/selftests/bpf: use TASK_COMM_LEN_16 instead of hard-coded 16 Yafang Shao
2021-10-21 22:44   ` Andrii Nakryiko
2021-10-22  6:36     ` Yafang Shao
2021-10-22 23:41       ` Andrii Nakryiko
2021-10-21  3:46 ` [PATCH v5 14/15] sched.h: extend task comm from 16 to 24 for CONFIG_BASE_FULL Yafang Shao
2021-10-21  3:46 ` [PATCH v5 15/15] kernel/kthread: show a warning if kthread's comm is truncated Yafang Shao

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='CAEf4BzbLzVEXd0FO6MRuVJA=CO7zbgSrx8c0JcuR_1K=bq1OcA@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andrii@kernel.org \
    --cc=arnaldo.melo@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=christian@brauner.io \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dietmar.eggemann@arm.com \
    --cc=john.fastabend@gmail.com \
    --cc=juri.lelli@redhat.com \
    --cc=kafai@fb.com \
    --cc=keescook@chromium.org \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=laoar.shao@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=oliver.sang@intel.com \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=qiang.zhang@windriver.com \
    --cc=robdclark@chromium.org \
    --cc=rostedt@goodmis.org \
    --cc=songliubraving@fb.com \
    --cc=valentin.schneider@arm.com \
    --cc=vincent.guittot@linaro.org \
    --cc=viro@zeniv.linux.org.uk \
    --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.