From patchwork Sun Oct 15 14:16:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13422258 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C19ABCDB47E for ; Sun, 15 Oct 2023 14:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229978AbjJOORQ (ORCPT ); Sun, 15 Oct 2023 10:17:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbjJOORO (ORCPT ); Sun, 15 Oct 2023 10:17:14 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B19A0D6 for ; Sun, 15 Oct 2023 07:17:11 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-692d2e8c003so3531358b3a.1 for ; Sun, 15 Oct 2023 07:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1697379431; x=1697984231; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Z+b0dEMOY183z9dPBZcXWdZ+T7lbIwplG3M4Qto5H1o=; b=oOKWrKzvXwy6Iss50tPht/+1c1HJyTCKCwA46I9tiPP/IHCgdCNzKNIcGQ0J6Gv3M+ VHM2g+vzcIOHQrwnU8mEKqiJsjbflHEdg2GpV1SwawE+py0vyHW0/oFH+02d4tKUGAu1 6Q+y6T7ZRoJj+E5/pxcm7XtkwaavFP54+G5/l5ZxbmraAuPggemAJtmYWlfFyKkcNDVC XA/piv1AsZaMtRWAZuG7ytz49tnZLSw1zvZZ0OUqa8d6kBcpELJ+wpuO47U+QAGqw5+Q 53T+VH0nTLUy0nP9Ac8/nlxctORyojWWh+uL661MD3da5xDNKlPHV+z+5WZBepDGf54s 88DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697379431; x=1697984231; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Z+b0dEMOY183z9dPBZcXWdZ+T7lbIwplG3M4Qto5H1o=; b=jqzoLYc9JHfbMeH+oogevdHCCws3Q3qSNaUq4u9eYUl8oBBKePzwlmt+0VPsqbm3ra jcHwt7JK8O6ejtFtxbciR7dicVu+bS72beUMJ4d3YI8aIhsDEdo2n6QnzKr8oSguRmOy qA2A/DRskgpDNEQqMu+WlWCSq+9q8Pz1TvpzbOMDcDwQtry/+9ATh5EZrIsYN/+4Z8ct ObQOm9LzoVihHrMf+sCrEkazUt1l9jiqfS/ZM/rx5TSfkjk25q9zVnEs7U/WpOB1fHvx 7ubvV9r7vBFItd8rvXbWjjWrNI2NG9FFy0j7uluO2WoDC91rocvZn/8+USyYA1dz1Hhf O5fw== X-Gm-Message-State: AOJu0YzlXaxDlDKCvv46ynGEElG1+KEd/WqYpsmrc+EPmbzfjLTPHcSB M+nTLU2xFQ50o0X4awPEzmwjpg== X-Google-Smtp-Source: AGHT+IF8ctbxzi/yLoYKR8nfTMdLlPrANNX0a4fFaaxK61sDbvY5BiX2bAhQb9DCFQvUS99Sir6h0g== X-Received: by 2002:a05:6a21:6d92:b0:13a:dd47:c31a with SMTP id wl18-20020a056a216d9200b0013add47c31amr6752797pzb.20.1697379431188; Sun, 15 Oct 2023 07:17:11 -0700 (PDT) Received: from localhost ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with UTF8SMTPSA id x6-20020aa78f06000000b006b3dc56c944sm3993752pfr.133.2023.10.15.07.17.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 15 Oct 2023 07:17:10 -0700 (PDT) From: Akihiko Odaki Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jonathan Corbet , Willem de Bruijn , Jason Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Xuan Zhuo , Mykola Lysenko , Shuah Khan , bpf@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kselftest@vger.kernel.org, Yuri Benditovich , Andrew Melnychenko , Akihiko Odaki Subject: [RFC PATCH v2 0/7] tun: Introduce virtio-net hashing feature Date: Sun, 15 Oct 2023 23:16:28 +0900 Message-ID: <20231015141644.260646-1-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org virtio-net have two usage of hashes: one is RSS and another is hash reporting. Conventionally the hash calculation was done by the VMM. However, computing the hash after the queue was chosen defeats the purpose of RSS. Another approach is to use eBPF steering program. This approach has another downside: it cannot report the calculated hash due to the restrictive nature of eBPF. Extend the steering program feature by introducing a dedicated program type: BPF_PROG_TYPE_VNET_HASH. This program type is capable to report the hash value and the queue to use at the same time. This is a rewrite of a RFC patch series submitted by Yuri Benditovich that incorporates feedbacks for the series and V1 of this series: https://lore.kernel.org/lkml/20210112194143.1494-1-yuri.benditovich@daynix.com/ QEMU patched to use this new feature is available at: https://github.com/daynix/qemu/tree/akihikodaki/bpf The QEMU patches will soon be submitted to the upstream as RFC too. V1 -> V2: Changed to introduce a new BPF program type. Akihiko Odaki (7): bpf: Introduce BPF_PROG_TYPE_VNET_HASH bpf: Add vnet_hash members to __sk_buff skbuff: Introduce SKB_EXT_TUN_VNET_HASH virtio_net: Add virtio_net_hdr_v1_hash_from_skb() tun: Support BPF_PROG_TYPE_VNET_HASH selftests/bpf: Test BPF_PROG_TYPE_VNET_HASH vhost_net: Support VIRTIO_NET_F_HASH_REPORT Documentation/bpf/bpf_prog_run.rst | 1 + Documentation/bpf/libbpf/program_types.rst | 2 + drivers/net/tun.c | 158 +++++-- drivers/vhost/net.c | 16 +- include/linux/bpf_types.h | 2 + include/linux/filter.h | 7 + include/linux/skbuff.h | 10 + include/linux/virtio_net.h | 22 + include/uapi/linux/bpf.h | 5 + kernel/bpf/verifier.c | 6 + net/core/filter.c | 86 +++- net/core/skbuff.c | 3 + tools/include/uapi/linux/bpf.h | 5 + tools/lib/bpf/libbpf.c | 2 + tools/testing/selftests/bpf/config | 1 + tools/testing/selftests/bpf/config.aarch64 | 1 - .../selftests/bpf/prog_tests/vnet_hash.c | 385 ++++++++++++++++++ tools/testing/selftests/bpf/progs/vnet_hash.c | 16 + 18 files changed, 681 insertions(+), 47 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/vnet_hash.c create mode 100644 tools/testing/selftests/bpf/progs/vnet_hash.c