Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1137736lqp; Fri, 22 Mar 2024 06:45:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUNm28kzOGF5zcYnS/wXVv/+HW1nbyqJUWYZkvF7XRCtBBn66zldkNHCeKjZ0IrKgcFvk6L6SplI7kEizvLNIUusr6wHsbMJRkF3790eQ== X-Google-Smtp-Source: AGHT+IF5lOBpIz7hykpLQokaTYf+g3K7qE6g49PZffWFdlr4pf0IU4uQO05COQrqNhjrvO2cFcIZ X-Received: by 2002:a50:baaf:0:b0:567:f475:6c6b with SMTP id x44-20020a50baaf000000b00567f4756c6bmr1922570ede.8.1711115155537; Fri, 22 Mar 2024 06:45:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711115155; cv=pass; d=google.com; s=arc-20160816; b=f+P7YnHE1shngaXgFcYMtntlc02Qsgspg1iea41lhffSUtD3+W19t7R8AsjSGXyHgS qI8FzvWCEUik5OLRIMKkhSyMD0CU5H/Q85KVcRARWppu9yR3r3mbha2z3eefLe+7iHfU IGJFfVAHNcqRP8hkIMztjb3RD50I9gYyhvC+3xTafN+vj6oGB53SEnY7jrNNTC1qGCkz XIjtd6dxFxVHvlCzXLItCVtioT9hI3VWWTVWkgsNPKmNKkCbqGQKvEdH6zpIX9EGm5sU RNwiRKbnLGiwczIoSrh+9/5c8LZKVBu/YOTnS3avm9tvrC8C522vzbyc/L59XAXXlYQ0 Bezw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=Y4Wtkfs6BPfblQoCnXQVgHKXsh4zcNEQpSQfGx0qDPE=; fh=45qV2u+pqfRBejYlmQUEV9oWggVmQ0DO9tfqhoY/6bU=; b=cPQZ9/uLUVOVxhAwboR9KybhBLZDCdTKAO6zGmAwj5m4D3Oc01Bd0sB1SsK7MDkhvq DMLkPXHk0f53ztvjVi7cnnANfO694nRg5KazHYXR3w5dIqgtsOLBFR683OzMnptdqhQY 2DT5jDt3UDQumYGuqIbV8sZARhAhmRsWyStMsbdi9aZ+oR7suHfuPaCOGBfZMZux9iUX fWu0XvslYEwkiuVW1IkwJPI/0SGLqHS4Af0H/5XTJmwtyhhtZXhzC0DTUFvo/X7tyRCr xdqJW3VQ0PHYTqcAV4pP4V2X8s5UABpojHWH9fA8CYgsBYDFrHJM2FGY0K5sS8sdp3m1 tgaw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ePXycGfH; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-111555-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111555-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a19-20020a05640233d300b00568a69c0720si928455edc.126.2024.03.22.06.45.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 06:45:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111555-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ePXycGfH; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-111555-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111555-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9A5FD1F2607E for ; Fri, 22 Mar 2024 13:44:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 250A85FEEA; Fri, 22 Mar 2024 13:37:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ePXycGfH" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8FFE45BFF; Fri, 22 Mar 2024 13:37:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711114629; cv=none; b=a8EzuOVOIjWovfc3YPmMQ19sr7kI1+ntFhtgYpwyyG7mLTKwyTIEKnp3rvRS4rYpzFkx0DfSk/Y+k8ONKugwnm/msRE6Zjs0/pUEefiwbhFhFLERTH5DNDgIqkDWjXAZEVIzO+rOkg32OyF7VeLi/cdJi63EnAEgnXBojAir4mM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711114629; c=relaxed/simple; bh=zWiE+XEo6fLJK8Uz6M2Us9666B3kXGXD4OrLzuZTikk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bLYFZAh/Rtw3Mu02YdzQFlR7AY9tfg+gwK7BbIb1dcg6RuxcLa6026Cd0Ns80QTr5nkjx1YtiZlJewOR5nG7I4bbnc7l4KjENqfYwnFsSPvsjkIDtddPajQl4MsbPpOykQ0JQLpkyph8Bv1EcITiazJEv8YjJIDF2p5TbQgqy2U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ePXycGfH; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1de0f92e649so14143125ad.0; Fri, 22 Mar 2024 06:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711114627; x=1711719427; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=Y4Wtkfs6BPfblQoCnXQVgHKXsh4zcNEQpSQfGx0qDPE=; b=ePXycGfH40j9C0mOKgsmgaMrgOKYMNvN4K6ZY1ZehoQZLyPKGSEUprPPUgy0CJkokr TgQW2xr3wTZQ/IC0LGSgfRsyMedy8Tn488imWQAiLplrMn918vcYLTBcz0vpYUhMIZAH e7foDqGIEhSOIzi7vFf+oFHhLOKBD1DTa7sZkVW3dyg5pkJLToe0gJ8a2+QaPWKWkxue ZchpRIEa9jTtK/cTmN2mkACCt/WaVdDdHg20beI0axknmlg+9dWB0qvKcm6EsK3mL4j1 EuHt0ibrgAcXF6hj35sMUNtRsDmmrZAq6FyyFsREf123wUTgJLgq3RQrXA4rA8yPoSqb Wchw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711114627; x=1711719427; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Y4Wtkfs6BPfblQoCnXQVgHKXsh4zcNEQpSQfGx0qDPE=; b=JUYnsamS6QnQEAypCKAKpKBPh5EXuK5P/DLyx0wdZbs+gdyMK29S0lDKo0cKPEQ3le 643v6FaK5LuWdkQwcZR/wy0Z9hXlJFDGpU3XZHq6BPS6E+d5e3SXXleVbAvN3/hvTfQ4 ERp9BlY4Ks2IRdz5id1hZwixQxBcextt9l6l3bcAtVhsm3wNat9En7lBaXyMD3LDf/wx qkuyq6K+AVR3fkDrHOzrohS4wsD/wohikTIaG5jzCEg9zhqrYlAHrQdBYS8jTbUHk9vR t0AkRx11cd/8LnO13f827gjADIPzQDakIYPrZfnZbkMtFQCmKUkDIUXutiOQp/Sg3IP0 RkBQ== X-Forwarded-Encrypted: i=1; AJvYcCW6s0f6w91TZcd9IONn4IQp/QaNoCMX/MhY+9vZJxnhNmxc2HpYwFh+e7IDn+EUcYk2eSeiXol6U3VVbrcsejet2RIl0U7z5dIXCz+x/c/c7+dMExVkyAza9tlUgPDn9Xe7 X-Gm-Message-State: AOJu0YycRyLSKruzMC6jqDY8Wovv8+n2Iv3dmqMcbJUtLVmhHJz8MRXc trG80fkojDhV9XC0w5qFbQ+ebRS/dNkRxe6AT7Dp+jKVC7nmDQpq X-Received: by 2002:a17:902:c406:b0:1e0:b0d:5b7d with SMTP id k6-20020a170902c40600b001e00b0d5b7dmr3130944plk.36.1711114626249; Fri, 22 Mar 2024 06:37:06 -0700 (PDT) Received: from [192.168.0.106] ([117.147.31.37]) by smtp.gmail.com with ESMTPSA id h17-20020a170902f55100b001dc3c4e7a12sm1903304plf.14.2024.03.22.06.37.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Mar 2024 06:37:05 -0700 (PDT) Message-ID: Date: Fri, 22 Mar 2024 21:36:58 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] libbpf: add specific btf name info when do core To: Andrii Nakryiko Cc: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , bpf@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240321170444.388225-1-chen.dylane@gmail.com> From: Tao Chen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Nakryiko, thank you for your reply. I try to familiarize with core in libbpf, the debug info is really helpful for me. But i use the old kernel btf, so origion debuginfo like: struct task_struct___x: found target candidate [130] struct task_struct in [vmlinux] I think it may be more clear, if we print btf name when we use old kernel btf like: struct task_struct___x: found target candidate [130] struct task_struct in [/boot/***.btf] The patch just solve debug info show for newbies above. 在 2024/3/22 上午2:52, Andrii Nakryiko 写道: > On Thu, Mar 21, 2024 at 10:04 AM Tao Chen wrote: >> >> No logic changed, just add specific btf name when core info >> print, maybe it seems more understandable. >> >> Signed-off-by: Tao Chen >> --- >> tools/lib/bpf/libbpf.c | 14 +++++++++----- >> 1 file changed, 9 insertions(+), 5 deletions(-) >> > > Can you elaborate on what problem you are trying to solve? > Conceptually libbpf does look for types in vmlinux (meaning main > kernel BTF), even if user overrides BTF location (presumably because > of old kernel). So even when we emit "vmlinux" in logs, it seems > correct. > > pw-bot: cr > > >> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c >> index afd09571c482..b32154288b4a 100644 >> --- a/tools/lib/bpf/libbpf.c >> +++ b/tools/lib/bpf/libbpf.c >> @@ -5653,7 +5653,8 @@ static int load_module_btfs(struct bpf_object *obj) >> } >> >> static struct bpf_core_cand_list * >> -bpf_core_find_cands(struct bpf_object *obj, const struct btf *local_btf, __u32 local_type_id) >> +bpf_core_find_cands(struct bpf_object *obj, const struct btf *local_btf, __u32 local_type_id, >> + const char *targ_btf_path) >> { >> struct bpf_core_cand local_cand = {}; >> struct bpf_core_cand_list *cands; >> @@ -5680,7 +5681,8 @@ bpf_core_find_cands(struct bpf_object *obj, const struct btf *local_btf, __u32 l >> >> /* Attempt to find target candidates in vmlinux BTF first */ >> main_btf = obj->btf_vmlinux_override ?: obj->btf_vmlinux; >> - err = bpf_core_add_cands(&local_cand, local_essent_len, main_btf, "vmlinux", 1, cands); >> + err = bpf_core_add_cands(&local_cand, local_essent_len, main_btf, >> + targ_btf_path ?: "vmlinux", 1, cands); >> if (err) >> goto err_out; >> >> @@ -5793,7 +5795,8 @@ static int bpf_core_resolve_relo(struct bpf_program *prog, >> int relo_idx, >> const struct btf *local_btf, >> struct hashmap *cand_cache, >> - struct bpf_core_relo_res *targ_res) >> + struct bpf_core_relo_res *targ_res, >> + const char *targ_btf_path) >> { >> struct bpf_core_spec specs_scratch[3] = {}; >> struct bpf_core_cand_list *cands = NULL; >> @@ -5813,7 +5816,7 @@ static int bpf_core_resolve_relo(struct bpf_program *prog, >> >> if (relo->kind != BPF_CORE_TYPE_ID_LOCAL && >> !hashmap__find(cand_cache, local_id, &cands)) { >> - cands = bpf_core_find_cands(prog->obj, local_btf, local_id); >> + cands = bpf_core_find_cands(prog->obj, local_btf, local_id, targ_btf_path); >> if (IS_ERR(cands)) { >> pr_warn("prog '%s': relo #%d: target candidate search failed for [%d] %s %s: %ld\n", >> prog_name, relo_idx, local_id, btf_kind_str(local_type), >> @@ -5920,7 +5923,8 @@ bpf_object__relocate_core(struct bpf_object *obj, const char *targ_btf_path) >> if (prog->obj->gen_loader) >> continue; >> >> - err = bpf_core_resolve_relo(prog, rec, i, obj->btf, cand_cache, &targ_res); >> + err = bpf_core_resolve_relo(prog, rec, i, obj->btf, cand_cache, &targ_res, >> + targ_btf_path); >> if (err) { >> pr_warn("prog '%s': relo #%d: failed to relocate: %d\n", >> prog->name, i, err); >> -- >> 2.34.1 >>