Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selftests/bpf: fix a clang compilation error for send_signal.c #2694

Closed
wants to merge 2 commits into from

Conversation

kernel-patches-bot
Copy link

Pull request for series with
subject: selftests/bpf: fix a clang compilation error for send_signal.c
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=622430

@kernel-patches-bot
Copy link
Author

Master branch: 357b3cc
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=622430
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 357b3cc
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=622440
version: 2

@kernel-patches-bot
Copy link
Author

Master branch: a77c2cf
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=622440
version: 2

@kernel-patches-bot
Copy link
Author

Master branch: 6789ab9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=622440
version: 2

@kernel-patches-bot
Copy link
Author

Master branch: c09df4b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=622440
version: 2

Building selftests/bpf with latest clang compiler (clang15 built
from source), I hit the following compilation error:
  /.../prog_tests/send_signal.c:43:16: error: variable 'j' set but not used [-Werror,-Wunused-but-set-variable]
                  volatile int j = 0;
                               ^
  1 error generated.
The problem also exists with clang13 and clang14. clang12 is okay.

In send_signal.c, we have the following code
  volatile int j = 0;
  ...
  for (int i = 0; i < 100000000 && !sigusr1_received; i++)
    j /= i + 1;
to burn cpu cycles so bpf_send_signal() helper can be tested
in nmi mode.

Slightly changing 'j /= i + 1' to 'j /= i + j + 1' or 'j++' can
fix the problem. Further investigation indicated this should be
a clang bug ([1]). The upstream fix will be proposed later. But it is
a good idea to workaround the issue to unblock people who build
kernel/selftests with clang.

 [1] https://discourse.llvm.org/t/strange-clang-unused-but-set-variable-error-with-volatile-variables/60841

Signed-off-by: Yonghong Song <yhs@fb.com>
@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=622440 irrelevant now. Closing PR.

@kernel-patches-bot kernel-patches-bot deleted the series/622430=>bpf-next branch March 11, 2022 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants