From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C77DEE49A5 for ; Mon, 21 Aug 2023 04:34:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233009AbjHUEey (ORCPT ); Mon, 21 Aug 2023 00:34:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232996AbjHUEet (ORCPT ); Mon, 21 Aug 2023 00:34:49 -0400 Received: from out-43.mta0.migadu.com (out-43.mta0.migadu.com [91.218.175.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C62099 for ; Sun, 20 Aug 2023 21:34:47 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692592485; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GQ3+8fFgZPBnKHzt/pbHvIk2a6srPidqNvlwyrLGsa0=; b=iYEcXNNTWGHp/TS4M1UGtGRa/KMZvi79XLGBInTQ4C3EeglmOSzWImmpy43QjX1FhrdulZ IgBCYoOml7Sy7F179Y463RKOj0f2e9TBd9f2eXJ52nN85AstH/wwhf+0flSBd0radljLWr xb5PZWfrV/GhR1k5hlfsZKGqPboGUVw= Date: Sun, 20 Aug 2023 21:34:37 -0700 MIME-Version: 1.0 Reply-To: yonghong.song@linux.dev Subject: Re: [PATCH bpf-next v5] selftests/bpf: trace_helpers.c: optimize kallsyms cache Content-Language: en-US To: Rong Tao Cc: andrii@kernel.org, ast@kernel.org, bpf@vger.kernel.org, daniel@iogearbox.net, haoluo@google.com, john.fastabend@gmail.com, kpsingh@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, martin.lau@linux.dev, mykolal@fb.com, olsajiri@gmail.com, rongtao@cestc.cn, sdf@google.com, shuah@kernel.org, song@kernel.org References: <817af9ec-0ba3-fab0-6d8a-4529ede337b5@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/20/23 7:03 PM, Rong Tao wrote: > Sorry Song, I did not state clear. > > libbpf_ensure_mem() is declared in libbpf_internal.h, we want to use > libbpf_ensure_mem() in trace_helpers.c, Unforturnately, we could only include > the headers 'install_headers:' defined in tools/lib/bpf/Makefile, the > 'install_headers:' target does not include libbpf_internal.h, like: > > tools/testing/selftests/bpf/trace_helpers.c:17:10: > fatal error: libbpf_internal.h: No such file or directory > 17 | #include "libbpf_internal.h" > | ^~~~~~~~~~~~~~~~~~~ > > tools/testing/selftests/bpf/trace_helpers.c:17:10: > fatal error: bpf/libbpf_internal.h: No such file or directory > 17 | #include "bpf/libbpf_internal.h" > | ^~~~~~~~~~~~~~~~~~~~~~~ It works fine for me. On top of your patch, the following works fine: diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/selftests/bpf/trace_helpers.c index 0053ba22f0cb..087383c5dc3a 100644 --- a/tools/testing/selftests/bpf/trace_helpers.c +++ b/tools/testing/selftests/bpf/trace_helpers.c @@ -14,6 +14,7 @@ #include #include #include +#include "bpf/libbpf_internal.h" #define TRACEFS_PIPE "/sys/kernel/tracing/trace_pipe" #define DEBUGFS_PIPE "/sys/kernel/debug/tracing/trace_pipe" With V=1 when building selftests, the following is the compilation command line: clang --target=x86_64-linux-gnu -fintegrated-as -g -O0 -rdynamic -Wall -Werror -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/include -I/home/yhs/work/bpf-next/include/generated -I/home/yhs/work/bpf-next/tools/lib -I/home/yhs/work/bpf-next/tools/include -I/home/yhs/work/bpf-next/tools/include/uapi -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf -Wno-unused-command-line-argument -c trace_helpers.c -lelf -lz -lrt -lpthread -o /home/yhs/work/bpf-next/tools/testing/selftests/bpf/trace_helpers.o This include path /home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/include will make including 'bpf/libbpf_internal.h' work. > > How about > > 1. dup-declare libbpf_ensure_mem() in trace_helpers.c > 2. move libbpf_ensure_mem() declare into libbpf_common.h > > Which one do you like best. > > Best wishes, > Rong Tao > >