Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7126508ybl; Wed, 15 Jan 2020 16:10:20 -0800 (PST) X-Google-Smtp-Source: APXvYqzP/uTUY1X7kxZ3lZtyq1dLffaq9AsP69Z1VkVhXYpy85ONWlJHkBBpwn91cDzlwGUVEZpP X-Received: by 2002:a05:6830:4a4:: with SMTP id l4mr4708578otd.91.1579133420546; Wed, 15 Jan 2020 16:10:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579133420; cv=none; d=google.com; s=arc-20160816; b=Pb5Z4axIWn0m/y898Sq9M4p2P1k3jtRKjCVmtbb/QCT+dfbwGws9I9APyvLn9GfniW 7pBEBZyTMNvvVKQyDFRqu1LvqHX4romZWDUNYGB1laiuLHlwE/vfe+Pfz3jDxrUZrD3j HWajrs26SEWsjGGzQQBu7TAz8Z3xKu+CwjKbB9AKcTPHY4ID/iovzRFxmlImxvmSzYY/ FVUIFE6vKfppRVWIjsVwhuHhwe9HDPGaESHaQN3eTyrqjPgF8+TNRjF3FETy3ePfEanY 1oCuhidZzVyzDse6I/8jDRMtd02ZKAxp9BLRbM9CwCfkFnubqgZSiV18IEyjhYvCY+jX rD1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=m3ykeEiv2DWhC3YDv/3M+ztOkLKwpMGFjEqD6cnUt4s=; b=uYGR1DVAyGqR3LHUgUcJzXWLBuVEM/HJgHt82rEsDDSyUVB8bwIllfp4fUWu/E3IA7 jEduP8YXqveuzXhriQ1rzEeLIJ9VcjQNmziHqFlJmZDvEbFgeDyWXJllF1iWp+dNO5ui veVKqFWD+HVsn7kqlQL8giuFCbKAsLDRR0i9R3Ng4dj4ZE95S0lHxuoyxoBCYoTP/foN jgikzes+QMB0ro7eu09WdzMzoEWper3GuXTjOa6bx5JTkASLnNdftKrr0z0Ds7YCQ8L9 EVsi2J+yVGc2OtChqApjS7yc4y7qFBaOdJDplqWZawp+yGLah/AISiwnhVwCjgtXO8AF QMwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cNt51iDc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q6si13905674otg.248.2020.01.15.16.09.55; Wed, 15 Jan 2020 16:10:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cNt51iDc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730242AbgAOWbu (ORCPT + 99 others); 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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 >