All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Juntong Deng <juntong.deng@outlook.com>
Cc: Jiri Olsa <olsajiri@gmail.com>,
	ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
	andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com,
	song@kernel.org, yonghong.song@linux.dev, kpsingh@kernel.org,
	sdf@fomichev.me, haoluo@google.com, memxor@gmail.com,
	snorcht@gmail.com, brauner@kernel.org, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 2/5] selftests/bpf: Add tests for open-coded style process file iterator
Date: Wed, 27 Nov 2024 12:21:51 +0100	[thread overview]
Message-ID: <Z0cAz3uOGRcl36Eu@krava> (raw)
In-Reply-To: <AM6PR03MB5080FB540DD0BBFA48C20325992F2@AM6PR03MB5080.eurprd03.prod.outlook.com>

On Tue, Nov 26, 2024 at 10:24:07PM +0000, Juntong Deng wrote:
> On 2024/11/20 11:27, Jiri Olsa wrote:
> > On Tue, Nov 19, 2024 at 05:53:59PM +0000, Juntong Deng wrote:
> > 
> > SNIP
> > 
> > > +static void subtest_task_file_iters(void)
> > > +{
> > > +	int prog_fd, child_pid, wstatus, err = 0;
> > > +	const int stack_size = 1024 * 1024;
> > > +	struct iters_task_file *skel;
> > > +	struct files_test_args args;
> > > +	struct bpf_program *prog;
> > > +	bool setup_end, test_end;
> > > +	char *stack;
> > > +
> > > +	skel = iters_task_file__open_and_load();
> > > +	if (!ASSERT_OK_PTR(skel, "open_and_load"))
> > > +		return;
> > > +
> > > +	if (!ASSERT_OK(skel->bss->err, "pre_test_err"))
> > > +		goto cleanup_skel;
> > > +
> > > +	prog = bpf_object__find_program_by_name(skel->obj, "test_bpf_iter_task_file");
> > > +	if (!ASSERT_OK_PTR(prog, "find_program_by_name"))
> > > +		goto cleanup_skel;
> > > +
> > > +	prog_fd = bpf_program__fd(prog);
> > > +	if (!ASSERT_GT(prog_fd, -1, "bpf_program__fd"))
> > > +		goto cleanup_skel;
> > 
> > I don't think you need to check on this once we did iters_task_file__open_and_load
> > 
> > > +
> > > +	stack = (char *)malloc(stack_size);
> > > +	if (!ASSERT_OK_PTR(stack, "clone_stack"))
> > > +		goto cleanup_skel;
> > > +
> > > +	setup_end = false;
> > > +	test_end = false;
> > > +
> > > +	args.setup_end = &setup_end;
> > > +	args.test_end = &test_end;
> > > +
> > > +	/* Note that there is no CLONE_FILES */
> > > +	child_pid = clone(task_file_test_process, stack + stack_size, CLONE_VM | SIGCHLD, &args);
> > > +	if (!ASSERT_GT(child_pid, -1, "child_pid"))
> > > +		goto cleanup_stack;
> > > +
> > > +	while (!setup_end)
> > > +		;
> > 
> > I thin kthe preferred way is to synchronize through pipe,
> > you can check prog_tests/uprobe_multi_test.c
> > 
> 
> Thanks for your reply.
> 
> Do we really need to use pipe? Currently this test is very simple.
> 
> In this test, all files opened by the test process will be closed first
> so that there is an empty file description table, and then open the
> test files.
> 
> This way the test process has only 3 newly opened files and the file
> descriptors are always 0, 1, 2.
> 
> Although using pipe is feasible, this test will become more complicated
> than it is now.

I see, I missed the close_range call.. anyway I'd still prefer pipe to busy waiting

perhaps you could use fentry probe triggered by the task_file_test_process
and do the fd/file iteration in there? that way there'be no need for the sync

jirka

  reply	other threads:[~2024-11-27 11:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-19 17:49 [PATCH bpf-next v4 0/5] bpf: Add open-coded style process file iterator and bpf_fget_task() kfunc Juntong Deng
2024-11-19 17:53 ` [PATCH bpf-next v4 1/5] bpf: Introduce task_file open-coded iterator kfuncs Juntong Deng
2024-11-20 10:55   ` Jiri Olsa
2024-11-20 11:04     ` Jiri Olsa
2024-11-19 17:53 ` [PATCH bpf-next v4 2/5] selftests/bpf: Add tests for open-coded style process file iterator Juntong Deng
2024-11-20 11:27   ` Jiri Olsa
2024-11-26 22:24     ` Juntong Deng
2024-11-27 11:21       ` Jiri Olsa [this message]
2024-12-10 14:17         ` Juntong Deng
2024-11-19 17:54 ` [PATCH bpf-next v4 3/5] bpf: Add bpf_fget_task() kfunc Juntong Deng
2024-11-19 17:54 ` [PATCH bpf-next v4 4/5] bpf: Make fs kfuncs available for SYSCALL and TRACING program types Juntong Deng
2024-11-19 17:54 ` [PATCH bpf-next v4 5/5] selftests/bpf: Add tests for bpf_fget_task() kfunc Juntong Deng
2024-11-19 18:40 ` [PATCH bpf-next v4 0/5] bpf: Add open-coded style process file iterator and " Juntong Deng
2024-11-20  9:12   ` Christian Brauner
2024-11-26 22:15     ` Juntong Deng

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=Z0cAz3uOGRcl36Eu@krava \
    --to=olsajiri@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brauner@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=juntong.deng@outlook.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=sdf@fomichev.me \
    --cc=snorcht@gmail.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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.