From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mail.toke.dk (Postfix) with ESMTPS id 7E5AD8B8CAE for ; Fri, 10 Sep 2021 13:16:54 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=jHx6gPD6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631272612; 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=KhW6lv8OKl3JGjPb0UK3/lNvMXBnjiEjWe2PmfSiYnI=; b=jHx6gPD6Q3kiAmff0k39TUVkg7rP7GwLgmqjAfLK5UqNf+qpIS9jlBhTzUUnmNTV9ax8Nq uBSVt5b6UM6ZKHoQV0+6gHZVhN3YiU+O60vFDtBXYu8F2+B1uFTO/W2ov8dzbBduk6a3zm 2cyY2gySGNV5mhXRJBolOEprRx7RZR4= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-168-NpKosJ5NMuOH09YMgZMa0Q-1; Fri, 10 Sep 2021 07:16:50 -0400 X-MC-Unique: NpKosJ5NMuOH09YMgZMa0Q-1 Received: by mail-lf1-f70.google.com with SMTP id n5-20020a19ef05000000b003e224cd5844so637541lfh.12 for ; Fri, 10 Sep 2021 04:16:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:cc:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=KhW6lv8OKl3JGjPb0UK3/lNvMXBnjiEjWe2PmfSiYnI=; b=8F6SeOP8warj2IzGD0TlvNkxqUm5Nkr4/uWm3o5JVIBqYg69S9Y5QT/DU81gKZlfjh t7ogW1cO9noxtsBLq1SVg9Mu8z8G4i5SzjPqm4Ovxp6Ty6L0vF6kGopNDWsnzPo6wVl0 DLFjGYOvtgy6f73NRoQ6UuVcQ6+1pfhU0u8XOD4W6Z8plHdumZ8AngF3d4/KK6zHKpRO tBpJUyt0Yvjz6AeQZh3g72gv1sr054GXa9Ba2+0zY6rfqc72wrmfIVgiVQK7pQWHaLP+ HK41sAHW4wqU0IMsk7JM/ZYoO6rAbqNyaoKOb4IeXRt3v4UDYnbb8iPWuPRBFAdhs7BF gY4Q== X-Gm-Message-State: AOAM533Qhw0Em99MpPozDm+uewruvuN/4pxaexwNwL5mhEvt4Dbv3+LQ rr2nrMRSibwvsv0uQHWG5Pr0e+cMqn3ac9qPI2iT9kkrDVXhdvHFMZ1RgSbTYxizmn5jWknPWq3 kB7jTQ+9ZruGeT523X0yQ X-Received: by 2002:a05:6512:2249:: with SMTP id i9mr3432156lfu.219.1631272609368; Fri, 10 Sep 2021 04:16:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzH59BTrtM3dOTuC2ud0FCBAi8NLgaYur2PMsOqbkfm5Sp/MKqxhOdAgBgLurc1d1SzcgHpYQ== X-Received: by 2002:a05:6512:2249:: with SMTP id i9mr3432122lfu.219.1631272608969; Fri, 10 Sep 2021 04:16:48 -0700 (PDT) Received: from [192.168.42.238] (87-59-106-155-cable.dk.customer.tdc.net. [87.59.106.155]) by smtp.gmail.com with ESMTPSA id m28sm534168ljc.46.2021.09.10.04.16.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Sep 2021 04:16:48 -0700 (PDT) From: Jesper Dangaard Brouer X-Google-Original-From: Jesper Dangaard Brouer Subject: Re: XDP-hints: Howto support multiple BTF types per packet basis? To: Andrii Nakryiko References: <60b6cf5b6505e_38d6d208d8@john-XPS-13-9370.notmuch> <20210602091837.65ec197a@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net> <874kdqqfnm.fsf@toke.dk> <87mtrfmoyh.fsf@toke.dk> <8735snvjp7.fsf@toke.dk> <190d8d21-f11d-bb83-58aa-08e86e0006d9@redhat.com> <936bfbdf-e194-b676-d28a-acf526120155@redhat.com> Message-ID: <2ed2a06c-6796-229d-05d4-9a6464330e9e@redhat.com> Date: Fri, 10 Sep 2021 13:16:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jbrouer@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Message-ID-Hash: THJUSBWN464A7CQWXBW72O4XLIKCWW2G X-Message-ID-Hash: THJUSBWN464A7CQWXBW72O4XLIKCWW2G X-MailFrom: jbrouer@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: brouer@redhat.com, Michal Swiatkowski , =?UTF-8?Q?Toke_H=c3=b8iland-J=c3=b8rgensen?= , Jakub Kicinski , John Fastabend , BPF-dev-list , Magnus Karlsson , William Tu , xdp-hints@xdp-project.net, Zaremba Larysa , Jiri Olsa X-Mailman-Version: 3.3.4 Precedence: list List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 09/09/2021 20.19, Andrii Nakryiko wrote: > Depending on what IDs we are talking about (sorry, I don't follow this > thread very closely, so if you are curious about some aspects of BTF > or libbpf APIs, it would be good to have a specific questions with > some context). BTF as kernel object has it's own ID allocated through > idr, so yes, they are unique. so vmlinux BTF object will have it's own > ID, while each module's BTF will have it's own. > > But if we are talking about BTF type IDs, that's entirely different > thing. BTF type IDs start from 1 (0 is reserved for special 'VOID' > type) all the way to number of types in vmlinux BTF. Then each module > extends vmlinx BTF starting at N + 1 and going to N + M, where N is > number of BTF types in vmlinux BTF and M is number of added types in > module BTF. > > So in that regard each module has BTF type IDs that are overlapping > with other modules, which is why for unique fetching of BTF types from > modules you also need BTF object FD or ID of a module BTF, and then > BTF type ID within that module. But as I said, I didn't follow along > closely, so not sure if I'm answering the right question, sorry. Thanks for answering. This N vmlinux IDs + M module IDs was important to know, thanks for correcting my understanding on this, as this does affect our ideas for using BTF for XDP-hints. This "just" means that the BTF ID will be per driver. I think we can still make this work, as the AF_XDP userspace program will already need to bind to a device. Thus, we can still send a simple btf_id in metadata, and AF_XDP prog will just have device-map with expected btf_id's from this device (to validate if it knows howto decode contents). It is slightly more annoying for my xdp_frame + cpumap use-case, as it can get XDP_REDIRECT'ed frames from many net_devices, but we do have xdp_frame->dev_rx (net_device) avail, so I can resolve this. --Jesper Finding some random BTF ID in two module and notice they point to different types. # bpftool btf dump file /sys/kernel/btf/ixgbe | grep 95905 [95905] FUNC 'ixgbe_set_rx_mode' type_id=95829 linkage=static # bpftool btf dump file /sys/kernel/btf/igc | grep 95905 [95905] FUNC 'igc_ethtool_get_link_ksettings' type_id=95904 linkage=static