Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'fix-number-of-arguments-in-test'

Cupertino Miranda says:

====================
Fix number of arguments in test

Hi everyone,

This is a new version based on comments.

Regards,
Cupertino

Changes from v1:
- Comment with gcc-bpf replaced by bpf_gcc.
- Used pragma GCC optimize to disable GCC optimization in test.

Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Yonghong Song <yonghong.song@linux.dev>
Cc: David Faust <david.faust@oracle.com>
Cc: Jose Marchesi <jose.marchesi@oracle.com>
Cc: Elena Zannoni <elena.zannoni@oracle.com>
====================

Link: https://lore.kernel.org/r/20240507122220.207820-1-cupertino.miranda@oracle.com
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

+30 -14
+9 -8
tools/testing/selftests/bpf/Makefile
··· 81 81 # The following tests contain C code that, although technically legal, 82 82 # triggers GCC warnings that cannot be disabled: declaration of 83 83 # anonymous struct types in function parameter lists. 84 - progs/btf_dump_test_case_bitfields.c-CFLAGS := -Wno-error 85 - progs/btf_dump_test_case_namespacing.c-CFLAGS := -Wno-error 86 - progs/btf_dump_test_case_packing.c-CFLAGS := -Wno-error 87 - progs/btf_dump_test_case_padding.c-CFLAGS := -Wno-error 88 - progs/btf_dump_test_case_syntax.c-CFLAGS := -Wno-error 84 + progs/btf_dump_test_case_bitfields.c-bpf_gcc-CFLAGS := -Wno-error 85 + progs/btf_dump_test_case_namespacing.c-bpf_gcc-CFLAGS := -Wno-error 86 + progs/btf_dump_test_case_packing.c-bpf_gcc-CFLAGS := -Wno-error 87 + progs/btf_dump_test_case_padding.c-bpf_gcc-CFLAGS := -Wno-error 88 + progs/btf_dump_test_case_syntax.c-bpf_gcc-CFLAGS := -Wno-error 89 89 endif 90 90 91 91 ifneq ($(CLANG_CPUV4),) ··· 470 470 # $eval()) and pass control to DEFINE_TEST_RUNNER_RULES. 471 471 # Parameters: 472 472 # $1 - test runner base binary name (e.g., test_progs) 473 - # $2 - test runner extra "flavor" (e.g., no_alu32, cpuv4, gcc-bpf, etc) 473 + # $2 - test runner extra "flavor" (e.g., no_alu32, cpuv4, bpf_gcc, etc) 474 474 define DEFINE_TEST_RUNNER 475 475 476 476 TRUNNER_OUTPUT := $(OUTPUT)$(if $2,/)$2 ··· 498 498 # Using TRUNNER_XXX variables, provided by callers of DEFINE_TEST_RUNNER and 499 499 # set up by DEFINE_TEST_RUNNER itself, create test runner build rules with: 500 500 # $1 - test runner base binary name (e.g., test_progs) 501 - # $2 - test runner extra "flavor" (e.g., no_alu32, cpuv4, gcc-bpf, etc) 501 + # $2 - test runner extra "flavor" (e.g., no_alu32, cpuv4, bpf_gcc, etc) 502 502 define DEFINE_TEST_RUNNER_RULES 503 503 504 504 ifeq ($($(TRUNNER_OUTPUT)-dir),) ··· 521 521 | $(TRUNNER_OUTPUT) $$(BPFOBJ) 522 522 $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@, \ 523 523 $(TRUNNER_BPF_CFLAGS) \ 524 - $$($$<-CFLAGS)) 524 + $$($$<-CFLAGS) \ 525 + $$($$<-$2-CFLAGS)) 525 526 526 527 $(TRUNNER_BPF_SKELS): %.skel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT) 527 528 $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)
+21 -6
tools/testing/selftests/bpf/progs/test_xdp_noinline.c
··· 318 318 return true; 319 319 } 320 320 321 + #ifndef __clang__ 322 + #pragma GCC push_options 323 + /* GCC optimization collapses functions and increases the number of arguments 324 + * beyond the compatible amount supported by BPF. 325 + */ 326 + #pragma GCC optimize("-fno-ipa-sra") 327 + #endif 328 + 321 329 static __attribute__ ((noinline)) 322 330 bool encap_v4(struct xdp_md *xdp, struct ctl_value *cval, 323 331 struct packet_description *pckt, ··· 379 371 return false; 380 372 return true; 381 373 } 374 + 375 + #ifndef __clang__ 376 + #pragma GCC pop_options 377 + #endif 382 378 383 379 static __attribute__ ((noinline)) 384 380 int swap_mac_and_send(void *data, void *data_end) ··· 600 588 __attribute__ ((noinline)) 601 589 static int process_l3_headers_v6(struct packet_description *pckt, 602 590 __u8 *protocol, __u64 off, 603 - __u16 *pkt_bytes, void *data, 604 - void *data_end) 591 + __u16 *pkt_bytes, void *extra_args[2]) 605 592 { 606 593 struct ipv6hdr *ip6h; 607 594 __u64 iph_len; 608 595 int action; 596 + void *data = extra_args[0]; 597 + void *data_end = extra_args[1]; 609 598 610 599 ip6h = data + off; 611 600 if (ip6h + 1 > data_end) ··· 632 619 __attribute__ ((noinline)) 633 620 static int process_l3_headers_v4(struct packet_description *pckt, 634 621 __u8 *protocol, __u64 off, 635 - __u16 *pkt_bytes, void *data, 636 - void *data_end) 622 + __u16 *pkt_bytes, void *extra_args[2]) 637 623 { 638 624 struct iphdr *iph; 639 625 int action; 626 + void *data = extra_args[0]; 627 + void *data_end = extra_args[1]; 640 628 641 629 iph = data + off; 642 630 if (iph + 1 > data_end) ··· 680 666 __u8 protocol; 681 667 __u32 vip_num; 682 668 int action; 669 + void *extra_args[2] = { data, data_end }; 683 670 684 671 if (is_ipv6) 685 672 action = process_l3_headers_v6(&pckt, &protocol, off, 686 - &pkt_bytes, data, data_end); 673 + &pkt_bytes, extra_args); 687 674 else 688 675 action = process_l3_headers_v4(&pckt, &protocol, off, 689 - &pkt_bytes, data, data_end); 676 + &pkt_bytes, extra_args); 690 677 if (action >= 0) 691 678 return action; 692 679 protocol = pckt.flow.proto;