linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] samples/bpf: Fix broken samples.
@ 2019-10-02 17:46 KP Singh
  2019-10-02 18:45 ` Alexei Starovoitov
  0 siblings, 1 reply; 3+ messages in thread
From: KP Singh @ 2019-10-02 17:46 UTC (permalink / raw)
  To: linux-kernel, bpf
  Cc: Florent Revest, Alexei Starovoitov, Daniel Borkmann,
	Martin KaFai Lau, Song Liu, Yonghong Song, Florent Revest,
	Rasmus Villemoes, Arnaldo Carvalho de Melo

From: KP Singh <kpsingh@google.com>

Rename asm_goto_workaround.h to asm_workaround.h and add a
workaround for the newly added "asm_inline" in:

  commit eb111869301e ("compiler-types.h: add asm_inline definition")

Add missing include for <linux/perf_event.h> which was removed from
perf-sys.h in:

  commit 91854f9a077e ("perf tools: Move everything related to
	               sys_perf_event_open() to perf-sys.h")

Co-developed-by: Florent Revest <revest@google.com>
Signed-off-by: Florent Revest <revest@google.com>
Signed-off-by: KP Singh <kpsingh@google.com>
---
 samples/bpf/Makefile                            |  2 +-
 .../{asm_goto_workaround.h => asm_workaround.h} | 17 ++++++++++++++---
 samples/bpf/task_fd_query_user.c                |  1 +
 3 files changed, 16 insertions(+), 4 deletions(-)
 rename samples/bpf/{asm_goto_workaround.h => asm_workaround.h} (46%)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 42b571cde177..ab2b4d7ecb4b 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -289,7 +289,7 @@ $(obj)/%.o: $(src)/%.c
 		-Wno-gnu-variable-sized-type-not-at-end \
 		-Wno-address-of-packed-member -Wno-tautological-compare \
 		-Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
-		-I$(srctree)/samples/bpf/ -include asm_goto_workaround.h \
+		-I$(srctree)/samples/bpf/ -include asm_workaround.h \
 		-O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf $(LLC_FLAGS) -filetype=obj -o $@
 ifeq ($(DWARF2BTF),y)
 	$(BTF_PAHOLE) -J $@
diff --git a/samples/bpf/asm_goto_workaround.h b/samples/bpf/asm_workaround.h
similarity index 46%
rename from samples/bpf/asm_goto_workaround.h
rename to samples/bpf/asm_workaround.h
index 7409722727ca..7c99ea6ae98c 100644
--- a/samples/bpf/asm_goto_workaround.h
+++ b/samples/bpf/asm_workaround.h
@@ -1,9 +1,10 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Copyright (c) 2019 Facebook */
-#ifndef __ASM_GOTO_WORKAROUND_H
-#define __ASM_GOTO_WORKAROUND_H
+#ifndef __ASM_WORKAROUND_H
+#define __ASM_WORKAROUND_H
 
-/* this will bring in asm_volatile_goto macro definition
+/*
+ * This will bring in asm_volatile_goto and asm_inline macro definitions
  * if enabled by compiler and config options.
  */
 #include <linux/types.h>
@@ -13,5 +14,15 @@
 #define asm_volatile_goto(x...) asm volatile("invalid use of asm_volatile_goto")
 #endif
 
+/*
+ * asm_inline is defined as asm __inline in "include/linux/compiler_types.h"
+ * if supported by the kernel's CC (i.e CONFIG_CC_HAS_ASM_INLINE) which is not
+ * supported by CLANG.
+ */
+#ifdef asm_inline
+#undef asm_inline
+#define asm_inline asm
+#endif
+
 #define volatile(x...) volatile("")
 #endif
diff --git a/samples/bpf/task_fd_query_user.c b/samples/bpf/task_fd_query_user.c
index e39938058223..4c31b305e6ef 100644
--- a/samples/bpf/task_fd_query_user.c
+++ b/samples/bpf/task_fd_query_user.c
@@ -13,6 +13,7 @@
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <linux/perf_event.h>
 
 #include "libbpf.h"
 #include "bpf_load.h"
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-02 18:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02 17:46 [PATCH] samples/bpf: Fix broken samples KP Singh
2019-10-02 18:45 ` Alexei Starovoitov
2019-10-02 18:52   ` KP Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).