Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp21924lqd; Tue, 23 Apr 2024 13:12:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVxfh51YFqYShALlYNnrfYuWWdJiMG/3xvsdWGH17Rw+hFHfxfyjmEuotCVw4b3NhWPm8sZ3XeDFHe+6vT+4I/u2HVYf7Hae3een4+tOg== X-Google-Smtp-Source: AGHT+IHbEPuFRUgpMyRhNjJ5evgQXSMGcp2+pZUPs9QGHbQGmoqoy+xl54SCZHEpxzrfhst2Ubny X-Received: by 2002:a17:906:b14a:b0:a51:e05f:2455 with SMTP id bt10-20020a170906b14a00b00a51e05f2455mr238590ejb.48.1713903147791; Tue, 23 Apr 2024 13:12:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713903147; cv=pass; d=google.com; s=arc-20160816; b=r1gfluMIEB55vAozQveKvu2AMXu+mhO1Rg/EK8PHFdLVzxZsqr3X23Urm0LO1hIs7c UjECkpzv9x/PPRMFqwPJ4A4pZ5wc8nCa2hxR5koCLbhW4XuL6nQrtmHWZxvD8aB5sOio MFm6qNfG+upekSOr8VrvoKoyA2WojELAVXEaSq0rJnMGhCeTW/zo+DrwYPWLNnwb7LEH SnXbhsmXR8SL+h2b69y5Rt3nOqSY+XonhlXIK9oN4d0MhqFNg1ZsfRe8AV0Dw9en6MZK xcmYzKBi7VR4YO9KW6VjfYp39MikNon3IZEz/G9PRBkd5LKF68khDEGLXOxyTR6kaB70 C0Dg== 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:content-language :references:cc:to:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=qUPDcD2j01kH/HC1OD+xdp9q7Dd/W+nSaYPSQta4QUk=; fh=TW2PMSO9SG57vpnSdf5nMsSExn5+/dJqSgTUauK5ZyQ=; b=1ExAiqJw5lPXDByj1zPpCRwaPStWAp2ov24IKOgpiUubEnsuqejsegk7m/oA8noBRW oYEFb4Dutea64SIbqI0pROCfjGpWmdwSADs8a9B8KEJLcDTN84lABvnExG8OKk6gs4XK heM1NW059sMSJnT+UKo99gGvi0SPys9fX7CvM7IjyyZtiIwSZV+nm3+4z21SrOJ5QSpi XYjr5gjXBe9pcnNi4/sF2q9cCha1bpBfpnYgvd3AkP2dbLrrdb2+UwkVEriYCbOIXjAo eVTCXndzLJyVBLQpZmUV0faH9ZSydNI7Uo3Jipxef4uC+FMiC4lz+L64Zp/W95GKpHqK B8DQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fAXPnEr3; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-155838-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155838-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id go20-20020a1709070d9400b00a55bbe115b6si3076823ejc.686.2024.04.23.13.12.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 13:12:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155838-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=@linux.dev header.s=key1 header.b=fAXPnEr3; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-155838-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155838-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 1C5821F242FA for ; Tue, 23 Apr 2024 20:12:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E4881428EC; Tue, 23 Apr 2024 20:12:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="fAXPnEr3" Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (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 CA835142624 for ; Tue, 23 Apr 2024 20:12:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713903136; cv=none; b=Dh9ANwfyqNdBsqsw9hdjxdLMzLtBbd9rHoMUTiU7nNjsVvz1BJHfX1TLhnN+3oXi0l6s1KmV5Q9epgVgTeuDa8Snz8FnP3IJNacBqJsD5xIt9A5YS6lLj4sdL4TigTOfFQfDWQi1zQUXlBfiPrDpHNQ1Pb3WFvy2atevQpYfktQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713903136; c=relaxed/simple; bh=vw7hzJgvPpkYky/XabtFFGyyOvxANqOJd/58chF3D7g=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=SXI8Ne65adFrcsM9B3J/1N21YwbqmunTRXKXkBTNNTGYTJcn2xZpLZabIItHTRxF2pOQBKL6XZKSHjmRm8i7fnp9LUP81W03ek2Z97WNoLZJyzffNZ4GpahYvgYpaM+Cwx/5zKMlQoHJB/GZjz4nq90xT+mK/C+/O7bTtcdihN8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=fAXPnEr3; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713903132; h=from:from: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=qUPDcD2j01kH/HC1OD+xdp9q7Dd/W+nSaYPSQta4QUk=; b=fAXPnEr30y66eQOtsGiQqRTf1qzjScqw2MhQNL9zqFxtj8Xa6M1GL1pBg70R19V/vhJzry hoHUxRN+vlW2mkWZ34bfEQaZOYAag5oCQJyRiBHo84xq7oXDj89Yz43ftp23gGipaKd9b1 WdjK0FN4NkeNHwW/7w0DV/AXVj/Z3fM= Date: Tue, 23 Apr 2024 13:12:04 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] libbpf: extending BTF_KIND_INIT to accommodate some unusual types To: Xin Liu , ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, yanan@huawei.com, wuchangye@huawei.com, xiesongyang@huawei.com, kongweibin2@huawei.com, zhangmingyi5@huawei.com, liwei883@huawei.com References: <20240423131503.361149-1-liuxin350@huawei.com> Content-Language: en-GB X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: <20240423131503.361149-1-liuxin350@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 4/23/24 6:15 AM, Xin Liu wrote: > On Mon, 22 Apr 2024 10:43:38 -0700 Andrii Nakryiko wrote: > >> On Mon, Apr 22, 2024 at 7:46 AM Xin Liu wrote: >>> In btf__add_int, the size of the new btf_kind_int type is limited. >>> When the size is greater than 16, btf__add_int fails to be added >>> and -EINVAL is returned. This is usually effective. >>> >>> However, when the built-in type __builtin_aarch64_simd_xi in the >>> NEON instruction is used in the code in the arm64 system, the value >>> of DW_AT_byte_size is 64. This causes btf__add_int to fail to >>> properly add btf information to it. >>> >>> like this: >>> ... >>> <1>: Abbrev Number: 2 (DW_TAG_base_type) >>> DW_AT_byte_size : 64 // over max size 16 >>> DW_AT_encoding : 5 (signed) >>> DW_AT_name : (indirect string, offset: 0x53): __builtin_aarch64_simd_xi >>> <1>: Abbrev Number: 0 >>> ... >>> >>> An easier way to solve this problem is to treat it as a base type >>> and set byte_size to 64. This patch is modified along these lines. >>> >>> Fixes: 4a3b33f8579a ("libbpf: Add BTF writing APIs") >>> Signed-off-by: Xin Liu >>> --- >>> tools/lib/bpf/btf.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c >>> index 2d0840ef599a..0af121293b65 100644 >>> --- a/tools/lib/bpf/btf.c >>> +++ b/tools/lib/bpf/btf.c >>> @@ -1934,7 +1934,7 @@ int btf__add_int(struct btf *btf, const char *name, size_t byte_sz, int encoding >>> if (!name || !name[0]) >>> return libbpf_err(-EINVAL); >>> /* byte_sz must be power of 2 */ >>> - if (!byte_sz || (byte_sz & (byte_sz - 1)) || byte_sz > 16) >>> + if (!byte_sz || (byte_sz & (byte_sz - 1)) || byte_sz > 64) >> >> maybe we should just remove byte_sz upper limit? We can probably >> imagine 256-byte integers at some point, so why bother artificially >> restricting it? >> >> pw-bot: cr > In the current definition of btf_kind_int, bits has only 8 bits, followed > by 8 bits of unused interval. When we expand, we should only use 16 bits > at most, so the maximum value should be 8192(1 << 16 / 8), directly removing > the limit of byte_sz. It may not fit the current design. For INT type btfs > greater than 255, how to dump is still a challenge. Looking at this patch. Now I remember that I have an old pahole patch to address similar issues https://lore.kernel.org/bpf/20230426055030.3743074-1-yhs@fb.com/ which is not merged and I forgot that. In that particular case, the int size is 1024 bytes. Currently the int type more than 16 bytes cannot be dumped in libbpf. Do you have a particular use case to use your__builtin_aarch64_simd_xi() type in bpf program? I guess probably not as BPF does not support builtin function your__builtin_aarch64_simd_xi(). > > Does the current version support a maximum of 8192 bytes? > >>> return libbpf_err(-EINVAL); >>> if (encoding & ~(BTF_INT_SIGNED | BTF_INT_CHAR | BTF_INT_BOOL)) >>> return libbpf_err(-EINVAL); >>> -- >>> 2.33.0 >>>