From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by mail.toke.dk (Postfix) with ESMTPS id B42719CD489 for ; Fri, 9 Dec 2022 01:32:33 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=FhApbE6r Received: by mail-ed1-x529.google.com with SMTP id v8so1127004edi.3 for ; Thu, 08 Dec 2022 16:32:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=IGZfLZ2nTw4+7WcF8MKsXwmI8yeURQq4sWvGDzZribo=; b=FhApbE6r3Q6+yY/M5ycQQHdtNFhn4uC9nBMrvGgusyIl99IUUU384ubR+g70IF6Kmd gGbDM5+RlUBgzaAIKHd9pAuZqMUKMAUKXIZ8GhAL2qyT93nJKBiHVBPcEXmhlCvvZHXW qMLcWY9CSY29xuLz5GhO2I6ajrReDHBM/G0mahgBWNbv2vXDKWMAabsno1wK0MkfSQ5m a6Ilvl2jPRa157rFgdFHByqXQXU7dk4rlwepv9UpJiylc52rlCicAfgjHinQDsKxT+6y suJ7hb9nIxVX2LM5JfFwbO6Pu+M/Rve9yC9A+byRZBWOBgBP+cKxE/5/AsHOhDViVPY1 QjQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IGZfLZ2nTw4+7WcF8MKsXwmI8yeURQq4sWvGDzZribo=; b=RTYgObflfn7mo4+9ELIR7kXQYJBOErXZaGQYnyuHUvVzw62lbFfxDA1ih6Ax94Zv/D KM6ZT2KHfD19GPZtgRYqH7YpCOwRwkqhZGj9t81z+RgWJTnlXWz5r1dMry/k4epIhTCf 4rcnu11aANPdOXdth7SZSCeMfwSdOtdaKbNzeQAF54u+Mt3ipEJzeZRc0WWsdFxkiwwt PRrS1jUjTdmhDZr6XaHDx02WQdQC0P/aKYz31/lS4GdxvMrmkffmk9fRl+if4UZvi6jJ 1za+6ZzuZcE0eXPaKJeTRyfOkemWuvPYhqnkzZT0x/0UXgh76AlCg4kJtyg7HCko9Jbr dHLA== X-Gm-Message-State: ANoB5pn5UUeXXxmmx3cWX4AmkoJn9TKZ93fU97vVDSFGnaGvaiHI99bg V3r/wqtLEXVP0m8zszm9r2B6CREc/n7HMj++qrA= X-Google-Smtp-Source: AA0mqf5by7IbjW7virQjidaMt05Q6Ne4TP/ba+OJZAVV/QLqqsQKex6uhRFQIJ2xWilbknC6yDBOGtZ0w4kBqmKOt/Y= X-Received: by 2002:a05:6402:142:b0:461:7fe6:9ea7 with SMTP id s2-20020a056402014200b004617fe69ea7mr4544644edu.94.1670545952547; Thu, 08 Dec 2022 16:32:32 -0800 (PST) MIME-Version: 1.0 References: <20221206024554.3826186-1-sdf@google.com> <20221206024554.3826186-12-sdf@google.com> <875yellcx6.fsf@toke.dk> <87359pl9zy.fsf@toke.dk> <87tu25ju77.fsf@toke.dk> In-Reply-To: <87tu25ju77.fsf@toke.dk> From: Alexei Starovoitov Date: Thu, 8 Dec 2022 16:32:21 -0800 Message-ID: To: =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: L7TIONOV3BCNFRXQQNB7GQDK33NINHOM X-Message-ID-Hash: L7TIONOV3BCNFRXQQNB7GQDK33NINHOM X-MailFrom: alexei.starovoitov@gmail.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: Stanislav Fomichev , bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Hao Luo , Jiri Olsa , Saeed Mahameed , David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, Network Development X-Mailman-Version: 3.3.7 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf-next v3 11/12] mlx5: Support RX XDP metadata List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, Dec 8, 2022 at 4:29 PM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > > Alexei Starovoitov writes: > > > On Thu, Dec 8, 2022 at 4:02 PM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > >> > >> Stanislav Fomichev writes: > >> > >> > On Thu, Dec 8, 2022 at 2:59 PM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > >> >> > >> >> Stanislav Fomichev writes: > >> >> > >> >> > From: Toke H=C3=B8iland-J=C3=B8rgensen > >> >> > > >> >> > Support RX hash and timestamp metadata kfuncs. We need to pass in= the cqe > >> >> > pointer to the mlx5e_skb_from* functions so it can be retrieved f= rom the > >> >> > XDP ctx to do this. > >> >> > >> >> So I finally managed to get enough ducks in row to actually benchma= rk > >> >> this. With the caveat that I suddenly can't get the timestamp suppo= rt to > >> >> work (it was working in an earlier version, but now > >> >> timestamp_supported() just returns false). I'm not sure if this is = an > >> >> issue with the enablement patch, or if I just haven't gotten the > >> >> hardware configured properly. I'll investigate some more, but figur= ed > >> >> I'd post these results now: > >> >> > >> >> Baseline XDP_DROP: 25,678,262 pps / 38.94 ns/pkt > >> >> XDP_DROP + read metadata: 23,924,109 pps / 41.80 ns/pkt > >> >> Overhead: 1,754,153 pps / 2.86 ns/pkt > >> >> > >> >> As per the above, this is with calling three kfuncs/pkt > >> >> (metadata_supported(), rx_hash_supported() and rx_hash()). So that'= s > >> >> ~0.95 ns per function call, which is a bit less, but not far off fr= om > >> >> the ~1.2 ns that I'm used to. The tests where I accidentally called= the > >> >> default kfuncs cut off ~1.3 ns for one less kfunc call, so it's > >> >> definitely in that ballpark. > >> >> > >> >> I'm not doing anything with the data, just reading it into an on-st= ack > >> >> buffer, so this is the smallest possible delta from just getting th= e > >> >> data out of the driver. I did confirm that the call instructions ar= e > >> >> still in the BPF program bytecode when it's dumped back out from th= e > >> >> kernel. > >> >> > >> >> -Toke > >> >> > >> > > >> > Oh, that's great, thanks for running the numbers! Will definitely > >> > reference them in v4! > >> > Presumably, we should be able to at least unroll most of the > >> > _supported callbacks if we want, they should be relatively easy; but > >> > the numbers look fine as is? > >> > >> Well, this is for one (and a half) piece of metadata. If we extrapolat= e > >> it adds up quickly. Say we add csum and vlan tags, say, and maybe > >> another callback to get the type of hash (l3/l4). Those would probably > >> be relevant for most packets in a fairly common setup. Extrapolating > >> from the ~1 ns/call figure, that's 8 ns/pkt, which is 20% of the > >> baseline of 39 ns. > >> > >> So in that sense I still think unrolling makes sense. At least for the > >> _supported() calls, as eating a whole function call just for that is > >> probably a bit much (which I think was also Jakub's point in a sibling > >> thread somewhere). > > > > imo the overhead is tiny enough that we can wait until > > generic 'kfunc inlining' infra is ready. > > > > We're planning to dual-compile some_kernel_file.c > > into native arch and into bpf arch. > > Then the verifier will automatically inline bpf asm > > of corresponding kfunc. > > Is that "planning" or "actively working on"? Just trying to get a sense > of the time frames here, as this sounds neat, but also something that > could potentially require quite a bit of fiddling with the build system > to get to work? :) "planning", but regardless how long it takes I'd rather not add any more tech debt in the form of manual bpf asm generation. We have too much of it already: gen_lookup, convert_ctx_access, etc.