From patchwork Wed Aug 28 17:46:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihor Solodrai X-Patchwork-Id: 13781635 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 973C21494AC for ; Wed, 28 Aug 2024 17:46:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724867180; cv=none; b=T4afJGxQmY73cpxN2s/S5eY87vTT3mR77ZpJJZKt3sZtWcY+fx9E59gh7Bnnfamj7xLld2vNjpGgslUU49CpRexQxyzXH3FRr2h1aHmif8asCrVlDDj1Am2AWMslL5LnVkRSbHaDoSU8AYLGe2zhJE8xFHbshcQQtN1oAZz+fGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724867180; c=relaxed/simple; bh=nkCcXQDV/mdZLX18VUtj4JuBZeCvMj1Cf+DewzIYzww=; h=Date:To:From:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=Nj3wHKIy0jT5PVA2txOYMqNilKzvbTmVNrQqf98ziizQ/YW8YIBZfdLmyzbBqAjve8u6+BKqH3xllf7AxVz87uDJB8b83b1mtHnfxqmEM1TfpjQuZ63SCtwLFQRAskKAj+HV8aVhRI4EHMo4z1JeS6eDtH5CJCExHJJotQesJV0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=bKxxT+qb; arc=none smtp.client-ip=185.70.43.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="bKxxT+qb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1724867176; x=1725126376; bh=tTEFrSeRUTfQXamaeVUCKec9AJ5LPsMxJSjJ8kzhlG8=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=bKxxT+qbyY5NLJ+6L+LfVVpHO0YtRbvtfBxsSPqDihhIltKyjvpb4zuS6MQ0Src8s a8hvziRuVQkCsTbdrpmU3rq5b5kZzqQIRItWNeZFspqLxFlfGJdQD3aFGDcF9OA9ai AFPV6BgpM5ySdrW7ekvlwIFP75Exn9FVCwAIOzOj3+pJ8AzcbD+XxQMtFN9iu1KbzK rmhUMbp4OSG06PHKygTwxlL6Aqu2xoQfa5+qn+h6Ug8IOWbNlFjjpz1IDcr0z+jvY6 w1hidMCepdqQha1faI/O4SnaIWaszl1wiNZAVcITmbMFR12rDCgRe46XGd6fiHpOEY kN1p1gFv/Miog== Date: Wed, 28 Aug 2024 17:46:14 +0000 To: bpf@vger.kernel.org, andrii@kernel.org From: Ihor Solodrai Cc: ast@kernel.org, daniel@iogearbox.net, eddyz87@gmail.com, mykolal@fb.com Subject: [PATCH bpf-next 1/2] selftests/bpf: specify libbpf headers required for %.bpf.o progs Message-ID: <20240828174608.377204-1-ihor.solodrai@pm.me> Feedback-ID: 27520582:user:proton X-Pm-Message-ID: 221ce0a4ffcdcf5c23a252a751abf3bbf020d665 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Test %.bpf.o objects actually depend only on some libbpf headers. Define a list of required headers and use it as TRUNNER_BPF_OBJS dependency. bpf_*.h list was determined by: $ grep -rh 'include --- tools/testing/selftests/bpf/Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index c120617b64ad..53cc13b92ee2 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -516,6 +516,12 @@ xdp_features.skel.h-deps := xdp_features.bpf.o LINKED_BPF_OBJS := $(foreach skel,$(LINKED_SKELS),$($(skel)-deps)) LINKED_BPF_SRCS := $(patsubst %.bpf.o,%.c,$(LINKED_BPF_OBJS)) +HEADERS_FOR_BPF_OBJS := $(wildcard $(BPFDIR)/*.bpf.h) \ + $(addprefix $(BPFDIR)/, bpf_core_read.h \ + bpf_endian.h \ + bpf_helpers.h \ + bpf_tracing.h) + # Set up extra TRUNNER_XXX "temporary" variables in the environment (relies on # $eval()) and pass control to DEFINE_TEST_RUNNER_RULES. # Parameters: @@ -566,8 +572,7 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.bpf.o: \ $(TRUNNER_BPF_PROGS_DIR)/%.c \ $(TRUNNER_BPF_PROGS_DIR)/*.h \ $$(INCLUDE_DIR)/vmlinux.h \ - $(wildcard $(BPFDIR)/bpf_*.h) \ - $(wildcard $(BPFDIR)/*.bpf.h) \ + $(HEADERS_FOR_BPF_OBJS) \ | $(TRUNNER_OUTPUT) $$(BPFOBJ) $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@, \ $(TRUNNER_BPF_CFLAGS) \ From patchwork Wed Aug 28 17:46:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihor Solodrai X-Patchwork-Id: 13781636 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 481C047F46 for ; Wed, 28 Aug 2024 17:46:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724867194; cv=none; b=iTFwd/qxvHRyRHug5D+8i7JZ3R3iOu/i1NxGkDlMAQPV5n6phnkSBzXiALpsu8S15wl2plfqRioeHRlqp88YVeMYNtHuUhJT/uXTxWhaPXko/HgbVgm4Cy1TV92mvnrRO2hXcj2kgPDC0A3yWuXVr0+tedPaMhzsd4CWRdxz1tk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724867194; c=relaxed/simple; bh=A0wnW1NSnEJhZKlZZv/p1c9qcu8JL0YptFf+ftNW1So=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pDDIf/XYcltN84X/InpuQwmV+hqwloTANOjgcoxJTCZO5esk1g5o+DhTWz4oB7oKGcbBC/JJ8B0cYCFFkLE0xM/OwXY56IfV2UeZVCsPt/gTGeuqkILBuRo25zqJErHj6v9VIAdtATfY8H+JoiyiJpbtw7I8I3OKxa49fw5/bIw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=WgzHiusl; arc=none smtp.client-ip=185.70.43.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="WgzHiusl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1724867190; x=1725126390; bh=Et19RCXm340CBimjeN2JzvnctL6rRMpzTVztmVo5lqY=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=WgzHiusl8ASkx1S3PmcenbDgJJZaN2wPykqkm4AyMRmfin01vBhjyMWNWU7wgN8P1 CCUhIUebup+CM+X1TDDMhoXb2HDt8o1IVRqI/P4kufAH4qGsYT/JGHBVxDtDS8/LY5 giOvYxtqyNqdEHlPqO1HD+m5/x519lnQeWPmM4R+q+BQAolt9IyCT60Hp8RkiGpQ+i 8ZH0Xo4qUpadch3JvbyhGWfRrRzPrHPu1wOY9rWwN6EX7xFR1ZzUAb4P84XMo2j7ac F/V1yCumSLiF+TNTKOri+nDj5bzM5ePYXaYF+qMnS/6BkBUAKl9/56ojxYzghMNkGK ILUTZWd4sLeXQ== Date: Wed, 28 Aug 2024 17:46:23 +0000 To: bpf@vger.kernel.org, andrii@kernel.org From: Ihor Solodrai Cc: ast@kernel.org, daniel@iogearbox.net, eddyz87@gmail.com, mykolal@fb.com Subject: [PATCH bpf-next 2/2] selftests/bpf: do not update vmlinux.h unnecessarily Message-ID: <20240828174608.377204-2-ihor.solodrai@pm.me> In-Reply-To: <20240828174608.377204-1-ihor.solodrai@pm.me> References: <20240828174608.377204-1-ihor.solodrai@pm.me> Feedback-ID: 27520582:user:proton X-Pm-Message-ID: 0af206ba7cb27c82b8c223fb3ebe92bba0946649 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net %.bpf.o objects depend on vmlinux.h, which makes them transitively dependent on unnecessary libbpf headers. However vmlinux.h doesn't actually change as often. When generating vmlinux.h, compare it to a previous version and update it only if there are changes. Example of build time improvement (after first clean build): $ touch ../../../lib/bpf/bpf.h $ time make -j8 Before: real 1m37.592s After: real 0m27.310s Notice that %.bpf.o gen step is skipped if vmlinux.h hasn't changed. Link: https://lore.kernel.org/bpf/CAEf4BzY1z5cC7BKye8=A8aTVxpsCzD=p1jdTfKC7i0XVuYoHUQ@mail.gmail.com Signed-off-by: Ihor Solodrai --- tools/testing/selftests/bpf/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 53cc13b92ee2..7660d19b66c2 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -399,10 +399,14 @@ $(HOST_BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ DESTDIR=$(HOST_SCRATCH_DIR)/ prefix= all install_headers endif +# vmlinux.h is first dumped to a temprorary file and then compared to +# the previous version. This helps to avoid unnecessary re-builds of +# $(TRUNNER_BPF_OBJS) $(INCLUDE_DIR)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) | $(INCLUDE_DIR) ifeq ($(VMLINUX_H),) $(call msg,GEN,,$@) - $(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $@ + $(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $(INCLUDE_DIR)/.vmlinux.h.tmp + $(Q)cmp -s $(INCLUDE_DIR)/.vmlinux.h.tmp $@ || mv $(INCLUDE_DIR)/.vmlinux.h.tmp $@ else $(call msg,CP,,$@) $(Q)cp "$(VMLINUX_H)" $@