Re: [PATCHv3 bpf 2/2] selftests/bpf: Add test for early update in prog_array_map_poke_run

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 05, 2023 at 08:00:48AM -0800, Yonghong Song wrote:

SNIP

> > > > +void test_tailcall_poke(void)
> > > > +{
> > > > +	struct tailcall_poke *call, *test;
> > > > +	int err, cnt = 10;
> > > > +	pthread_t thread;
> > > > +
> > > > +	unlink(JMP_TABLE);
> > > > +
> > > > +	call = tailcall_poke__open_and_load();
> > > > +	if (!ASSERT_OK_PTR(call, "tailcall_poke__open"))
> > > > +		return;
> > > > +
> > > > +	err = bpf_map__pin(call->maps.jmp_table, JMP_TABLE);
> > > > +	if (!ASSERT_OK(err, "bpf_map__pin"))
> > > > +		goto out;
> > > Just curious. What is the reason having bpf_map__pin() here
> > > and below? I tried and it looks like removing bpf_map__pin()
> > > and below bpf_map__set_pin_path() will make reproducing
> > > the failure hard/impossible.
> > yes, it's there to share the jmp_table map between the two
> > skeleton instances, so the update thread changes the same
> > jmp_table map that's used in the skeleton we load in the
> > while loop below
> 
> This does make sense.
> 
> > 
> > I'll add some comments to the test
> 
> Thanks for explanation. Some comments are definitely helpful!

np, also looks like I should move this to prog_tests/tailcalls.c,
will send new version with that

thanks,
jirka


> 
> > 
> > jirka
> > 
> > > > +
> > > > +	err = pthread_create(&thread, NULL, update, call);
> > > > +	if (!ASSERT_OK(err, "new toggler"))
> > > > +		goto out;
> > > > +
> > > > +	while (cnt--) {
> > > > +		test = tailcall_poke__open();
> > > > +		if (!ASSERT_OK_PTR(test, "tailcall_poke__open"))
> > > > +			break;
> > > > +
> > > > +		err = bpf_map__set_pin_path(test->maps.jmp_table, JMP_TABLE);
> > > > +		if (!ASSERT_OK(err, "bpf_map__pin")) {
> > > > +			tailcall_poke__destroy(test);
> > > > +			break;
> > > > +		}
> > > > +
> > > > +		bpf_program__set_autoload(test->progs.test, true);
> > > > +		bpf_program__set_autoload(test->progs.call1, false);
> > > > +		bpf_program__set_autoload(test->progs.call2, false);
> > > > +
> > > > +		err = tailcall_poke__load(test);
> > > > +		tailcall_poke__destroy(test);
> > > > +		if (!ASSERT_OK(err, "tailcall_poke__load"))
> > > > +			break;
> > > > +	}
> > > > +
> > > > +	thread_exit = 1;
> > > > +	ASSERT_OK(pthread_join(thread, NULL), "pthread_join");
> > > > +
> > > > +out:
> > > > +	bpf_map__unpin(call->maps.jmp_table, JMP_TABLE);
> > > > +	tailcall_poke__destroy(call);
> > > > +}
> > SNIP




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux