Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2011294rdg; Sun, 15 Oct 2023 07:17:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZ5PFRzzTET182uo9H6cIjlzZmw4cuJ6hdX5ariUlRFMb3YxHV20SOAL+yH4PIKFTKhMI5 X-Received: by 2002:a17:902:e812:b0:1b0:3ab6:5140 with SMTP id u18-20020a170902e81200b001b03ab65140mr7414801plg.4.1697379463030; Sun, 15 Oct 2023 07:17:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697379463; cv=none; d=google.com; s=arc-20160816; b=Qc67qogbdk1lAUXGD3BPscl72tW5aKWq+xN6tkmz2ENI59HBOUTUehDMOKRIADa/6L f3EFucUDaBSMpFVDu0nr0q+ytxrKgBFR0e9xLH5xzbILkBIiLUkGjbCw+JEMQ7XPklA6 Mns8ME7449CeadXEnN7VYcib8Z3ZcBcPmHX+01QgOagM4F33P8XjVf7ns66GO5qmOp+N zpTJQxp8AqEPXpQMzCLBvJJOLS9gO9bhs2+35Suk3MPEgSup3rGMyDnAB2ravPckjCPU +z5Xir1TrJZt7Fq58XtJDvVoUzyWt2hwkVJv0u75btVXiqPZ7O4Pi7mKKrTVIrcviTKH 8Yvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=Z+b0dEMOY183z9dPBZcXWdZ+T7lbIwplG3M4Qto5H1o=; fh=f+8c4CX0Hpb8J+qpFQab+8ncm37u6Ed3k6xLUQ3yhso=; b=KK0c3fJk7F45X/ZQ4A+m/4s9nfeQvguF07ravK7s48TiYMxNqjfrT1vTYpKw+6JpOt SNPXfqxkSlhMvVwFIO2JlRjkPXSpWWyJ2NrftRgX7S/QuivldkiSgFNWMDm+SG7YYtIt 43XDzxIEIVcXffdUoExaCHayzXU8/6O8+ANXcsG/1UXNN9eW/LEZoUliFbrsCCqXB9e6 pnr7APkgJ7n3FynDblaqplf66NtOAQieCd+ZPiOLxUtrnOQ9tcNmR3cVCa1q8wMQMoxA n8QD5789DFJl5EQcY9KAk61ZQoT3CJRF55wpQOJrYPNOaPeLiAwt0gBiSfsDdz6KEbpd fcOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=oOKWrKzv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id m14-20020a170902db0e00b001bc674914b0si9144889plx.472.2023.10.15.07.17.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 07:17:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=fail header.i=@daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=oOKWrKzv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0F2B48063036; Sun, 15 Oct 2023 07:17:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbjJOORP (ORCPT + 99 others); Sun, 15 Oct 2023 10:17:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjJOORO (ORCPT ); Sun, 15 Oct 2023 10:17:14 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2274DA for ; Sun, 15 Oct 2023 07:17:11 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6b44befac59so1381263b3a.0 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=TyT5uf2nSiLNosu4Vzn1ni29FTtF1mjW37Pwk0IQjJYLYveladKY3lY+G6rblKhgRd 3MBIomIeqxvIdY+O0F3FKYL7pjnGwNzoIi8ou5XKXFxi48WM4zqN3XS3Pn86FfwD8q3a fqYwQpvaS2+VlmUhl7nZHApPCoNX/hRMpyfiD4PLKzChIKI+xi/P3ipP24NNpYFLvK7q VgKxildvnJfIGv1AHherhAhbOKAazDCEDfFnclke1MkRqTTXn+pj1wwQtK7Zb8x23BJf 9Q9vvnhw1VkmGKBDXIeT6f3eo12kYqYsgInVnXiuCp0ej70qSi8IiUP6pmES96Nf1YTF MvVg== X-Gm-Message-State: AOJu0YyrQU15XdBjbHKDHoJhICxey/6xwgVzwqv9rkHKXYlHz9TyXdpC Wcz4fq6wPTbAsLCuHQf1UkbYPA== 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 15 Oct 2023 07:17:40 -0700 (PDT) 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 -- 2.42.0