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 X-Spam-Level: X-Spam-Status: No, score=-6.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E178C32771 for ; Wed, 15 Jan 2020 22:31:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1778724671 for ; Wed, 15 Jan 2020 22:31:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cNt51iDc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729048AbgAOWbu (ORCPT ); Wed, 15 Jan 2020 17:31:50 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:36467 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728899AbgAOWbu (ORCPT ); Wed, 15 Jan 2020 17:31:50 -0500 Received: by mail-qk1-f193.google.com with SMTP id a203so17355080qkc.3; Wed, 15 Jan 2020 14:31:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=m3ykeEiv2DWhC3YDv/3M+ztOkLKwpMGFjEqD6cnUt4s=; b=cNt51iDcDZI6zelQEGvFbm8lPIlIGnZldM0f2rIq1AgcoCCdkQIbVvR19pY8xHwYlP 7R2OMxb5sfqI39LAluJjBuUlrFm8jXcFHwHzpQsVk9IHMN/xpCMK491szpikUKk8RT8X m7307OpYrbxFQJI8OakwrfTa3HGJZ4eJBfI86Xby5q50ox6WVd4PzkYEVcAciFBIwS8u f7mRKTLIgkBP65rlD0vn09o9FPFOgGm1EUGPVidZ+W/ZFmk+dDe2ZjwrZvCB++dEJ8sV SkthSvzz+nTTMBTamfNnFkYTRMY01cXfsbE7dr+lHGbkVSn+2SSSqgQh18vnIuXka7P3 jZ8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=m3ykeEiv2DWhC3YDv/3M+ztOkLKwpMGFjEqD6cnUt4s=; b=cK76LIAP5ynqr0Qta/8qtkniBiwY6z2LvYl36KzJhC160HWZAgWe7jrqSs6rdz51KO jvOYzc5iDZ5jEMidCg5GTs6O4px3Y9vBjWG95814auLdEtPiisD6EOzE4jAM7pZ/if06 Y73rLUhWf5YehK9/0knabFTx+SmCHoRVm0XkuQh9SeHo7s/9OBXRisdV1InonIhgnHvY kvxy66xTcUm0LeQKyHsjwPbDFOeJueNg0/TXS9c/A/cnPj84VMNww/UfbaRJatW8cJtH Mte43cYFkUJjnqhSIxlzcsWwulykNHHh+yVSJd6j9xHx2a9ykwKoTYMCxPM9qh21vYh7 XOIg== X-Gm-Message-State: APjAAAVLiYLb8203H9f0aSWU+jQBOW6ieGh/6E8+TWrMNMJgtQICPqfV ZOGrpVd0Z2SQwg49NYDkGtG7+lsqO9IdXO45MaU= X-Google-Smtp-Source: APXvYqzukFfHfNkIeKb+uK+DszszlveC2wPehwk6e8vAwphJhtnuhVoFPfjcvFFmRoCVVG49lShaKmldjnY1Y1hDegY= X-Received: by 2002:ae9:e809:: with SMTP id a9mr13631663qkg.92.1579127508368; Wed, 15 Jan 2020 14:31:48 -0800 (PST) MIME-Version: 1.0 References: <157909756858.1192265.6657542187065456112.stgit@toke.dk> <157909757089.1192265.9038866294345740126.stgit@toke.dk> <87v9pctlvn.fsf@toke.dk> In-Reply-To: <87v9pctlvn.fsf@toke.dk> From: Andrii Nakryiko Date: Wed, 15 Jan 2020 14:31:37 -0800 Message-ID: Subject: Re: [PATCH bpf-next v2 02/10] tools/bpf/runqslower: Fix override option for VMLINUX_BTF To: =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= Cc: Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , Doug Ledford , Jason Gunthorpe , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Shuah Khan , Networking , bpf , open list , linux-rdma@vger.kernel.org, "open list:KERNEL SELFTEST FRAMEWORK" , clang-built-linux@googlegroups.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On Wed, Jan 15, 2020 at 2:06 PM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > > Andrii Nakryiko writes: > > > On Wed, Jan 15, 2020 at 6:13 AM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > >> > >> From: Toke H=C3=B8iland-J=C3=B8rgensen > >> > >> The runqslower tool refuses to build without a file to read vmlinux BT= F > >> from. The build fails with an error message to override the location b= y > >> setting the VMLINUX_BTF variable if autodetection fails. However, the > >> Makefile doesn't actually work with that override - the error message = is > >> still emitted. > > > > Do you have example command with VMLINUX_BTF override that didn't work > > (and what error message was emitted)? > > Before this patch: > > $ cd ~/build/linux/tools/bpf/runqslower > $ make > Makefile:18: *** "Can't detect kernel BTF, use VMLINUX_BTF to specify it = explicitly". Stop. > > $ make VMLINUX_BTF=3D~/build/linux/vmlinux > Makefile:18: *** "Can't detect kernel BTF, use VMLINUX_BTF to specify it = explicitly". Stop. Ok, so this is strange. Try make clean and run with V=3D1, it might help to debug this. This could happen if ~/build/linux/vmlinux doesn't exist, but I assume you double-checked that. It works for me just fine (Makefile won't do VMLINUX_BTF :=3D assignment, if it's defined through make invocation, so your change should be a no-op in that regard): $ make clean $ make VMLINUX_BTF=3D~/linux-build/default/vmlinux V=3D1 ... .output/sbin/bpftool btf dump file ~/linux-build/default/vmlinux format c > .output/vmlinux.h ... Wonder what your output looks like? > > >> Fix this by only doing auto-detection if no override is set. And while > >> we're at it, also look for a vmlinux file in the current kernel build = dir > >> if none if found on the running kernel. > >> > >> Fixes: 9c01546d26d2 ("tools/bpf: Add runqslower tool to tools/bpf") > >> Signed-off-by: Toke H=C3=B8iland-J=C3=B8rgensen > >> --- > >> tools/bpf/runqslower/Makefile | 16 ++++++++++------ > >> 1 file changed, 10 insertions(+), 6 deletions(-) > >> > >> diff --git a/tools/bpf/runqslower/Makefile b/tools/bpf/runqslower/Make= file > >> index cff2fbcd29a8..fb93ce2bf2fe 100644 > >> --- a/tools/bpf/runqslower/Makefile > >> +++ b/tools/bpf/runqslower/Makefile > >> @@ -10,12 +10,16 @@ CFLAGS :=3D -g -Wall > >> > >> # Try to detect best kernel BTF source > >> KERNEL_REL :=3D $(shell uname -r) > >> -ifneq ("$(wildcard /sys/kernel/btf/vmlinux)","") > >> -VMLINUX_BTF :=3D /sys/kernel/btf/vmlinux > >> -else ifneq ("$(wildcard /boot/vmlinux-$(KERNEL_REL))","") > >> -VMLINUX_BTF :=3D /boot/vmlinux-$(KERNEL_REL) > >> -else > >> -$(error "Can't detect kernel BTF, use VMLINUX_BTF to specify it expli= citly") > >> +ifeq ("$(VMLINUX_BTF)","") > >> + ifneq ("$(wildcard /sys/kernel/btf/vmlinux)","") > >> + VMLINUX_BTF :=3D /sys/kernel/btf/vmlinux > >> + else ifneq ("$(wildcard /boot/vmlinux-$(KERNEL_REL))","") > >> + VMLINUX_BTF :=3D /boot/vmlinux-$(KERNEL_REL) > >> + else ifneq ("$(wildcard $(abspath ../../../vmlinux))","") > >> + VMLINUX_BTF :=3D $(abspath ../../../vmlinux) > > > > I'm planning to mirror runqslower into libbpf Github repo and this > > ../../../vmlinux piece will be completely out of place in that > > context. Also it only will help when building kernel in-tree. So I'd > > rather not add this. > > Well building the kernel in-tree is something people sometimes want to do= ;) > > Specifically, the selftests depend on this, so we should at least fix > those; but I guess it could work to just pass in VMLINUX_BTF as part of > the make -C from the selftests dir? I'll try that... Yes, it can be handled through VMLINUX_BTF override for selftests. As I said, this will be a self-contained example in libbpf's Github repo, so this "in kernel tree" assumption doesn't stand there. > > -Toke >