From nobody Sun Nov 24 05:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725560121; cv=none; d=zohomail.com; s=zohoarc; b=CKMi2G4uHcMFrSmQAv5bnKwa1oFRXm8Mhu5lxATibar3UbNeF45AvXyAkmW5J2ksNNpG2PZ7d0pucaRbUD18hUGvBQuEM89bUDjgH65Aj6PQr0OhMMCWw/1uoLU0jnz0LxgeIy8b36O9YSvI3KbjDNceNnkJdWGUEgVUmk1Pk8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725560121; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CNUUuqSRzYX0POnmd5u0Eimd9GLrqiy5Ip/mekTfUeI=; b=VaORtJrlWhiQ0g2y1lpwvv//Kcm7r+p/jJRt/K9PaRGreq57gHjSiso/32iJb1PyxAKXB9bm8rMO4jKHLKNsmLUTKjFwUZbogsUVAr3vQ3wlYwmAl79M/jF3sGbGGYBTep39oIhkVEJ6OcleAqxGwt2wDaDzQTd8/iMpfVXD0gc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725560121132441.7192971898145; Thu, 5 Sep 2024 11:15:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smGzd-0006dH-A0; Thu, 05 Sep 2024 14:14:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzL-0005p2-1E for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:13:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzJ-0001HH-Ko for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:13:46 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-H5WyZE7tPdu0Kba45UoRBg-1; Thu, 05 Sep 2024 14:13:39 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CEAE51955D4B; Thu, 5 Sep 2024 18:13:37 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.53]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7C64D19560AA; Thu, 5 Sep 2024 18:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725560022; 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=CNUUuqSRzYX0POnmd5u0Eimd9GLrqiy5Ip/mekTfUeI=; b=iR565ud8L3fGBWRrJd20zxDkieSEaZS+syN4RYBpGVqPR0b+z3mzk/1JG0GvIVRPK7/JTC udGTCLhE3GXRD9kOy++ZaHsIew3PKjIWaSsFEhTkD9b9vpkrZc8pCx6s0VUrODWT56FMg5 q6VrNseJ+soVmDTKo0VWvF2/RWKaqio= X-MC-Unique: H5WyZE7tPdu0Kba45UoRBg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Yuri Benditovich , "Michael S. Tsirkin" , Andrew Melnychenko , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 1/7] hw/net: fix typo s/epbf/ebpf/ in virtio-net Date: Thu, 5 Sep 2024 19:13:24 +0100 Message-ID: <20240905181330.3657590-2-berrange@redhat.com> In-Reply-To: <20240905181330.3657590-1-berrange@redhat.com> References: <20240905181330.3657590-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725560121783116600 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index ed33a32877..055fce1d78 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1254,7 +1254,7 @@ static void rss_data_to_rss_config(struct VirtioNetRs= sData *data, config->default_queue =3D data->default_queue; } =20 -static bool virtio_net_attach_epbf_rss(VirtIONet *n) +static bool virtio_net_attach_ebpf_rss(VirtIONet *n) { struct EBPFRSSConfig config =3D {}; =20 @@ -1276,7 +1276,7 @@ static bool virtio_net_attach_epbf_rss(VirtIONet *n) return true; } =20 -static void virtio_net_detach_epbf_rss(VirtIONet *n) +static void virtio_net_detach_ebpf_rss(VirtIONet *n) { virtio_net_attach_ebpf_to_backend(n->nic, -1); } @@ -1286,8 +1286,8 @@ static void virtio_net_commit_rss_config(VirtIONet *n) if (n->rss_data.enabled) { n->rss_data.enabled_software_rss =3D n->rss_data.populate_hash; if (n->rss_data.populate_hash) { - virtio_net_detach_epbf_rss(n); - } else if (!virtio_net_attach_epbf_rss(n)) { + virtio_net_detach_ebpf_rss(n); + } else if (!virtio_net_attach_ebpf_rss(n)) { if (get_vhost_net(qemu_get_queue(n->nic)->peer)) { warn_report("Can't load eBPF RSS for vhost"); } else { @@ -1300,7 +1300,7 @@ static void virtio_net_commit_rss_config(VirtIONet *n) n->rss_data.indirections_len, sizeof(n->rss_data.key)); } else { - virtio_net_detach_epbf_rss(n); + virtio_net_detach_ebpf_rss(n); trace_virtio_net_rss_disable(); } } --=20 2.45.2 From nobody Sun Nov 24 05:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725560098; cv=none; d=zohomail.com; s=zohoarc; b=KUqti+J6xgzC5NZuPdDKDGg3aMFvrpNEPVvr0z0AdMElV2F6PoASzJCwkEVOvsoin/VRn0J2z8C9w5+3VHYP6CGpXTOLrmFESDfwr2KrEVW4BNhpMT7aJaa7Qp+h7FULZJcr4uV0LlcjSpTB6JxxYMramgbXwChoiodnNmukqQA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725560098; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IwjHADrvISKOyWtGPf2TkVdMM+O/TEDCNULvna+zMpE=; b=SiDihVDtNXyboBsCwP2+RXOpslTw84i9xH3OTtaaQNBMPquAYsXPbdbIHAWeLUQ7YhVplmBSzy+TRDcwoR71PZLHarWs77fYIPkmWK+eUi0wCStMefNpqAGaCq/XPRXcOxkfdML8YK5E6NKm7d6bQMP9NbjYF8VEc9bXbbK4qYk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725560097994556.5103221372774; Thu, 5 Sep 2024 11:14:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smGzR-0005vU-3t; Thu, 05 Sep 2024 14:13:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzM-0005pM-56 for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:13:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzK-0001HN-2I for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:13:47 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-195-bSFmzxb2OyC4QIC6WHG6yw-1; Thu, 05 Sep 2024 14:13:42 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7DB9D1955D44; Thu, 5 Sep 2024 18:13:40 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.53]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7011E19560AF; Thu, 5 Sep 2024 18:13:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725560025; 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=IwjHADrvISKOyWtGPf2TkVdMM+O/TEDCNULvna+zMpE=; b=i/RA6Wr6w4CKP700qpcd26Go7l99KV8cJSEHpWYX2rveJCvGEoPg25ktDyYPljsFoaTLF/ XjeuIXGpfJWX71WDHRx4eLkwvoGpAJkOb6eunlhm7OWQ2+zZNtWYIjwwEsOgpi+nzoiGOB QLPY8brQwLLS+82UIqihMp+YG4Lj5Qo= X-MC-Unique: bSFmzxb2OyC4QIC6WHG6yw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Yuri Benditovich , "Michael S. Tsirkin" , Andrew Melnychenko , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 2/7] ebpf: drop redundant parameter checks in static methods Date: Thu, 5 Sep 2024 19:13:25 +0100 Message-ID: <20240905181330.3657590-3-berrange@redhat.com> In-Reply-To: <20240905181330.3657590-1-berrange@redhat.com> References: <20240905181330.3657590-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725560099832116600 Various static methods have checks on their parameters which were already checked immediately before the method was invoked. Drop these redundat checks to simplify the following commit which adds formal error reporting. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michael S. Tsirkin --- ebpf/ebpf_rss.c | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c index 87f0714910..aa7170d997 100644 --- a/ebpf/ebpf_rss.c +++ b/ebpf/ebpf_rss.c @@ -49,10 +49,6 @@ bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx) =20 static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx) { - if (!ebpf_rss_is_loaded(ctx)) { - return false; - } - ctx->mmap_configuration =3D mmap(NULL, qemu_real_host_page_size(), PROT_READ | PROT_WRITE, MAP_SHARED, ctx->map_configuration, 0); @@ -90,10 +86,6 @@ toeplitz_fail: =20 static void ebpf_rss_munmap(struct EBPFRSSContext *ctx) { - if (!ebpf_rss_is_loaded(ctx)) { - return; - } - munmap(ctx->mmap_indirections_table, qemu_real_host_page_size()); munmap(ctx->mmap_toeplitz_key, qemu_real_host_page_size()); munmap(ctx->mmap_configuration, qemu_real_host_page_size()); @@ -177,15 +169,10 @@ bool ebpf_rss_load_fds(struct EBPFRSSContext *ctx, in= t program_fd, return true; } =20 -static bool ebpf_rss_set_config(struct EBPFRSSContext *ctx, +static void ebpf_rss_set_config(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *config) { - if (!ebpf_rss_is_loaded(ctx)) { - return false; - } - memcpy(ctx->mmap_configuration, config, sizeof(*config)); - return true; } =20 static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx, @@ -194,8 +181,7 @@ static bool ebpf_rss_set_indirections_table(struct EBPF= RSSContext *ctx, { char *cursor =3D ctx->mmap_indirections_table; =20 - if (!ebpf_rss_is_loaded(ctx) || indirections_table =3D=3D NULL || - len > VIRTIO_NET_RSS_MAX_TABLE_LEN) { + if (len > VIRTIO_NET_RSS_MAX_TABLE_LEN) { return false; } =20 @@ -207,20 +193,16 @@ static bool ebpf_rss_set_indirections_table(struct EB= PFRSSContext *ctx, return true; } =20 -static bool ebpf_rss_set_toepliz_key(struct EBPFRSSContext *ctx, +static void ebpf_rss_set_toepliz_key(struct EBPFRSSContext *ctx, uint8_t *toeplitz_key) { /* prepare toeplitz key */ uint8_t toe[VIRTIO_NET_RSS_MAX_KEY_SIZE] =3D {}; =20 - if (!ebpf_rss_is_loaded(ctx) || toeplitz_key =3D=3D NULL) { - return false; - } memcpy(toe, toeplitz_key, VIRTIO_NET_RSS_MAX_KEY_SIZE); *(uint32_t *)toe =3D ntohl(*(uint32_t *)toe); =20 memcpy(ctx->mmap_toeplitz_key, toe, VIRTIO_NET_RSS_MAX_KEY_SIZE); - return true; } =20 bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *co= nfig, @@ -231,18 +213,14 @@ bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, str= uct EBPFRSSConfig *config, return false; } =20 - if (!ebpf_rss_set_config(ctx, config)) { - return false; - } + ebpf_rss_set_config(ctx, config); =20 if (!ebpf_rss_set_indirections_table(ctx, indirections_table, config->indirections_len)) { return false; } =20 - if (!ebpf_rss_set_toepliz_key(ctx, toeplitz_key)) { - return false; - } + ebpf_rss_set_toepliz_key(ctx, toeplitz_key); =20 return true; } --=20 2.45.2 From nobody Sun Nov 24 05:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725560077; cv=none; d=zohomail.com; s=zohoarc; b=iSOqbkzBKshnAgWxwVoDqz1B+HtYnRsDjzmScP2HrYd3UqVAT6pwHEPZJlySZxzQGtaxDar81Dr9N9p8pqrPyAcAa8y8eXcrKZeOzeDZV0NZ7OizIJ2auNlpvc/O4ddUUm3+u2WD8tSW5h6qwGe4vkSpVTA91c/5iDKDJYFkrRA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725560077; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3gKQxkSU8pAyHZ+WgFRtKo1vyQQVE3H2sHGvZSNk/Hw=; b=Vc/8Ao7ir0qetuob9+eYf09Dmjw5x3uh6FdHwtnFR+sPcoR5ONasaCmyz3UyL4KKPxm5QyFs7hbRVxDzrc0argDpXReNe56QcBOUU7BYfvbxMsbcX6DI7Tl2IElFvFydNdplOW9QDhefDh5Ybdn7UnK/da1UL4v8a7J2M8h/Gk8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725560077139907.4585323503142; Thu, 5 Sep 2024 11:14:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smGzW-0006Ba-A2; Thu, 05 Sep 2024 14:13:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzO-0005rg-Lc for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:13:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzN-0001II-2T for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:13:50 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-696-1noywOAHNGyordMMp29NmA-1; Thu, 05 Sep 2024 14:13:44 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 98B891955F45; Thu, 5 Sep 2024 18:13:42 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.53]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A51B319560AA; Thu, 5 Sep 2024 18:13:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725560027; 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=3gKQxkSU8pAyHZ+WgFRtKo1vyQQVE3H2sHGvZSNk/Hw=; b=LHGtOb8mCDZVJs+REb4ZREYHcoHon2xhAjGmmYOCnLxlqcCbt+Vy7LhQIwHu6pyKezjJKM TaYk4oPGM32gef4ooOsAx1eHQlwRu/QEf19dblZrM+UBjN28vBhhXIPqH73bMgYv4YROf5 xJryBBzj1BoNBsizbKrlZQ97aGExVxQ= X-MC-Unique: 1noywOAHNGyordMMp29NmA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Yuri Benditovich , "Michael S. Tsirkin" , Andrew Melnychenko , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 3/7] ebpf: improve error trace events Date: Thu, 5 Sep 2024 19:13:26 +0100 Message-ID: <20240905181330.3657590-4-berrange@redhat.com> In-Reply-To: <20240905181330.3657590-1-berrange@redhat.com> References: <20240905181330.3657590-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725560077631116600 A design pattern of trace_foo_error("descriptive string") is undesirable because it does not allow for filtering trace events based on the error scenario. Split eBPF error trace event into three separate events to address this filtering need. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michael S. Tsirkin --- ebpf/ebpf_rss.c | 10 +++++----- ebpf/trace-events | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c index aa7170d997..47186807ad 100644 --- a/ebpf/ebpf_rss.c +++ b/ebpf/ebpf_rss.c @@ -53,21 +53,21 @@ static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx) PROT_READ | PROT_WRITE, MAP_SHARED, ctx->map_configuration, 0); if (ctx->mmap_configuration =3D=3D MAP_FAILED) { - trace_ebpf_error("eBPF RSS", "can not mmap eBPF configuration arra= y"); + trace_ebpf_rss_mmap_error(ctx, "configuration"); return false; } ctx->mmap_toeplitz_key =3D mmap(NULL, qemu_real_host_page_size(), PROT_READ | PROT_WRITE, MAP_SHARED, ctx->map_toeplitz_key, 0); if (ctx->mmap_toeplitz_key =3D=3D MAP_FAILED) { - trace_ebpf_error("eBPF RSS", "can not mmap eBPF toeplitz key"); + trace_ebpf_rss_mmap_error(ctx, "toeplitz key"); goto toeplitz_fail; } ctx->mmap_indirections_table =3D mmap(NULL, qemu_real_host_page_size(), PROT_READ | PROT_WRITE, MAP_SHARED, ctx->map_indirections_table, 0); if (ctx->mmap_indirections_table =3D=3D MAP_FAILED) { - trace_ebpf_error("eBPF RSS", "can not mmap eBPF indirection table"= ); + trace_ebpf_rss_mmap_error(ctx, "indirections table"); goto indirection_fail; } =20 @@ -105,14 +105,14 @@ bool ebpf_rss_load(struct EBPFRSSContext *ctx) =20 rss_bpf_ctx =3D rss_bpf__open(); if (rss_bpf_ctx =3D=3D NULL) { - trace_ebpf_error("eBPF RSS", "can not open eBPF RSS object"); + trace_ebpf_rss_open_error(ctx); goto error; } =20 bpf_program__set_type(rss_bpf_ctx->progs.tun_rss_steering_prog, BPF_PR= OG_TYPE_SOCKET_FILTER); =20 if (rss_bpf__load(rss_bpf_ctx)) { - trace_ebpf_error("eBPF RSS", "can not load RSS program"); + trace_ebpf_rss_load_error(ctx); goto error; } =20 diff --git a/ebpf/trace-events b/ebpf/trace-events index b3ad1a35f2..a0f157be37 100644 --- a/ebpf/trace-events +++ b/ebpf/trace-events @@ -1,4 +1,6 @@ # See docs/devel/tracing.rst for syntax documentation. =20 # ebpf-rss.c -ebpf_error(const char *s1, const char *s2) "error in %s: %s" +ebpf_rss_load_error(void *ctx) "ctx=3D%p" +ebpf_rss_mmap_error(void *ctx, const char *object) "ctx=3D%p object=3D%s" +ebpf_rss_open_error(void *ctx) "ctx=3D%p" --=20 2.45.2 From nobody Sun Nov 24 05:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725560068; cv=none; d=zohomail.com; s=zohoarc; b=DLuaa6Vn6w3Xc7z0vHb5gRWYkKDNMwdqPDHaXlqnU7xULajglRl4inI5t+PfFcS2+kOIKxJ1JsG1YoX/0tkh1kIEemIHCE7i8ngTa47ontUk/+/Lx/HEGzmm13bl6sdRGzDypJpes14NcNOiaVGfUPWn3XVsQ3DxTDB8+D3Bs1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725560068; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YDxC23U3Cz/j/UkCFMi8cT4ZDFIROKWuRfpP5kfBUTA=; b=WnrVcNBIqN3ResqGvpiVl1ty1Q10eek4phi9Y6lZ4ClWz3rXjUo1f38/PtqCdC8BKobYZFxLuJ1EIqo92xvpItIrlcYe2LSyvoYWpyREFzLL+G/WE6ptEm/BEFOlrDkL+6X24sr35EEhWw6eMzEdt5KRe3bE1CqvIacRrgn0+Gc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725560068788489.75436104557036; Thu, 5 Sep 2024 11:14:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smGzW-0006Co-9H; Thu, 05 Sep 2024 14:13:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzS-0005zR-2d for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:13:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzQ-0001Iy-Bs for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:13:53 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-t83X9BbDNPWgdjeywHG8sw-1; Thu, 05 Sep 2024 14:13:45 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BBB5F195604F; Thu, 5 Sep 2024 18:13:44 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.53]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E2A1519560AA; Thu, 5 Sep 2024 18:13:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725560031; 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=YDxC23U3Cz/j/UkCFMi8cT4ZDFIROKWuRfpP5kfBUTA=; b=NMxGZMKj7MQVBhpbd5hcgVbi6+KyjOOnMx4HLongll/DNLQjp0xjKliyyHqBy5O8p2wRV0 AeLAHarHiTpIosjpoxu4ZnXZ4ySiiOp+np5ZrN1Ymhcg7HyaBIyqfYv4UGfdgM8wojq+ta nUzCEsYqjkjwO1rH9VbNWw7z7WlG27w= X-MC-Unique: t83X9BbDNPWgdjeywHG8sw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Yuri Benditovich , "Michael S. Tsirkin" , Andrew Melnychenko , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 4/7] ebpf: add formal error reporting to all APIs Date: Thu, 5 Sep 2024 19:13:27 +0100 Message-ID: <20240905181330.3657590-5-berrange@redhat.com> In-Reply-To: <20240905181330.3657590-1-berrange@redhat.com> References: <20240905181330.3657590-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725560069749116600 The eBPF code is currently reporting error messages through trace events. Trace events are fine for debugging, but they are not to be considered the primary error reporting mechanism, as their output is inaccessible to callers. This adds an "Error **errp" parameter to all methods which have important error scenarios to report to the caller. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- ebpf/ebpf_rss.c | 59 ++++++++++++++++++++++++++++++++++++--------- ebpf/ebpf_rss.h | 10 +++++--- hw/net/virtio-net.c | 7 +++--- 3 files changed, 59 insertions(+), 17 deletions(-) diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c index 47186807ad..f65a58b0b6 100644 --- a/ebpf/ebpf_rss.c +++ b/ebpf/ebpf_rss.c @@ -47,13 +47,14 @@ bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx) return ctx !=3D NULL && (ctx->obj !=3D NULL || ctx->program_fd !=3D -1= ); } =20 -static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx) +static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx, Error **errp) { ctx->mmap_configuration =3D mmap(NULL, qemu_real_host_page_size(), PROT_READ | PROT_WRITE, MAP_SHARED, ctx->map_configuration, 0); if (ctx->mmap_configuration =3D=3D MAP_FAILED) { trace_ebpf_rss_mmap_error(ctx, "configuration"); + error_setg(errp, "Unable to map eBPF configuration array"); return false; } ctx->mmap_toeplitz_key =3D mmap(NULL, qemu_real_host_page_size(), @@ -61,6 +62,7 @@ static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx) ctx->map_toeplitz_key, 0); if (ctx->mmap_toeplitz_key =3D=3D MAP_FAILED) { trace_ebpf_rss_mmap_error(ctx, "toeplitz key"); + error_setg(errp, "Unable to map eBPF toeplitz array"); goto toeplitz_fail; } ctx->mmap_indirections_table =3D mmap(NULL, qemu_real_host_page_size(), @@ -68,6 +70,7 @@ static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx) ctx->map_indirections_table, 0); if (ctx->mmap_indirections_table =3D=3D MAP_FAILED) { trace_ebpf_rss_mmap_error(ctx, "indirections table"); + error_setg(errp, "Unable to map eBPF indirection array"); goto indirection_fail; } =20 @@ -95,7 +98,7 @@ static void ebpf_rss_munmap(struct EBPFRSSContext *ctx) ctx->mmap_indirections_table =3D NULL; } =20 -bool ebpf_rss_load(struct EBPFRSSContext *ctx) +bool ebpf_rss_load(struct EBPFRSSContext *ctx, Error **errp) { struct rss_bpf *rss_bpf_ctx; =20 @@ -106,6 +109,7 @@ bool ebpf_rss_load(struct EBPFRSSContext *ctx) rss_bpf_ctx =3D rss_bpf__open(); if (rss_bpf_ctx =3D=3D NULL) { trace_ebpf_rss_open_error(ctx); + error_setg(errp, "Unable to open eBPF RSS object"); goto error; } =20 @@ -113,6 +117,7 @@ bool ebpf_rss_load(struct EBPFRSSContext *ctx) =20 if (rss_bpf__load(rss_bpf_ctx)) { trace_ebpf_rss_load_error(ctx); + error_setg(errp, "Unable to load eBPF program"); goto error; } =20 @@ -126,7 +131,7 @@ bool ebpf_rss_load(struct EBPFRSSContext *ctx) ctx->map_toeplitz_key =3D bpf_map__fd( rss_bpf_ctx->maps.tap_rss_map_toeplitz_key); =20 - if (!ebpf_rss_mmap(ctx)) { + if (!ebpf_rss_mmap(ctx, errp)) { goto error; } =20 @@ -143,13 +148,28 @@ error: } =20 bool ebpf_rss_load_fds(struct EBPFRSSContext *ctx, int program_fd, - int config_fd, int toeplitz_fd, int table_fd) + int config_fd, int toeplitz_fd, int table_fd, + Error **errp) { if (ebpf_rss_is_loaded(ctx)) { + error_setg(errp, "eBPF program is already loaded"); return false; } =20 - if (program_fd < 0 || config_fd < 0 || toeplitz_fd < 0 || table_fd < 0= ) { + if (program_fd < 0) { + error_setg(errp, "eBPF program FD is not open"); + return false; + } + if (config_fd < 0) { + error_setg(errp, "eBPF config FD is not open"); + return false; + } + if (toeplitz_fd < 0) { + error_setg(errp, "eBPF toeplitz FD is not open"); + return false; + } + if (table_fd < 0) { + error_setg(errp, "eBPF indirection FD is not open"); return false; } =20 @@ -158,7 +178,7 @@ bool ebpf_rss_load_fds(struct EBPFRSSContext *ctx, int = program_fd, ctx->map_toeplitz_key =3D toeplitz_fd; ctx->map_indirections_table =3D table_fd; =20 - if (!ebpf_rss_mmap(ctx)) { + if (!ebpf_rss_mmap(ctx, errp)) { ctx->program_fd =3D -1; ctx->map_configuration =3D -1; ctx->map_toeplitz_key =3D -1; @@ -177,11 +197,14 @@ static void ebpf_rss_set_config(struct EBPFRSSContext= *ctx, =20 static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx, uint16_t *indirections_table, - size_t len) + size_t len, + Error **errp) { char *cursor =3D ctx->mmap_indirections_table; =20 if (len > VIRTIO_NET_RSS_MAX_TABLE_LEN) { + error_setg(errp, "Indirections table length %zu exceeds limit %d", + len, VIRTIO_NET_RSS_MAX_TABLE_LEN); return false; } =20 @@ -206,17 +229,31 @@ static void ebpf_rss_set_toepliz_key(struct EBPFRSSCo= ntext *ctx, } =20 bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *co= nfig, - uint16_t *indirections_table, uint8_t *toeplitz_key) + uint16_t *indirections_table, uint8_t *toeplitz_key, + Error **errp) { - if (!ebpf_rss_is_loaded(ctx) || config =3D=3D NULL || - indirections_table =3D=3D NULL || toeplitz_key =3D=3D NULL) { + if (!ebpf_rss_is_loaded(ctx)) { + error_setg(errp, "eBPF program is not loaded"); + return false; + } + if (config =3D=3D NULL) { + error_setg(errp, "eBPF config table is NULL"); + return false; + } + if (indirections_table =3D=3D NULL) { + error_setg(errp, "eBPF indirections table is NULL"); + return false; + } + if (toeplitz_key =3D=3D NULL) { + error_setg(errp, "eBPF toeplitz key is NULL"); return false; } =20 ebpf_rss_set_config(ctx, config); =20 if (!ebpf_rss_set_indirections_table(ctx, indirections_table, - config->indirections_len)) { + config->indirections_len, + errp)) { return false; } =20 diff --git a/ebpf/ebpf_rss.h b/ebpf/ebpf_rss.h index 239242b0d2..86a5787789 100644 --- a/ebpf/ebpf_rss.h +++ b/ebpf/ebpf_rss.h @@ -14,6 +14,8 @@ #ifndef QEMU_EBPF_RSS_H #define QEMU_EBPF_RSS_H =20 +#include "qapi/error.h" + #define EBPF_RSS_MAX_FDS 4 =20 struct EBPFRSSContext { @@ -41,13 +43,15 @@ void ebpf_rss_init(struct EBPFRSSContext *ctx); =20 bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx); =20 -bool ebpf_rss_load(struct EBPFRSSContext *ctx); +bool ebpf_rss_load(struct EBPFRSSContext *ctx, Error **errp); =20 bool ebpf_rss_load_fds(struct EBPFRSSContext *ctx, int program_fd, - int config_fd, int toeplitz_fd, int table_fd); + int config_fd, int toeplitz_fd, int table_fd, + Error **errp); =20 bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *co= nfig, - uint16_t *indirections_table, uint8_t *toeplitz_key); + uint16_t *indirections_table, uint8_t *toeplitz_key, + Error **errp); =20 void ebpf_rss_unload(struct EBPFRSSContext *ctx); =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 055fce1d78..558fc62844 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1265,7 +1265,8 @@ static bool virtio_net_attach_ebpf_rss(VirtIONet *n) rss_data_to_rss_config(&n->rss_data, &config); =20 if (!ebpf_rss_set_all(&n->ebpf_rss, &config, - n->rss_data.indirections_table, n->rss_data.key)= ) { + n->rss_data.indirections_table, n->rss_data.key, + NULL)) { return false; } =20 @@ -1336,7 +1337,7 @@ static bool virtio_net_load_ebpf_fds(VirtIONet *n) } } =20 - ret =3D ebpf_rss_load_fds(&n->ebpf_rss, fds[0], fds[1], fds[2], fds[3]= ); + ret =3D ebpf_rss_load_fds(&n->ebpf_rss, fds[0], fds[1], fds[2], fds[3]= , NULL); =20 exit: if (!ret) { @@ -1354,7 +1355,7 @@ static bool virtio_net_load_ebpf(VirtIONet *n) =20 if (virtio_net_attach_ebpf_to_backend(n->nic, -1)) { if (!(n->ebpf_rss_fds && virtio_net_load_ebpf_fds(n))) { - ret =3D ebpf_rss_load(&n->ebpf_rss); + ret =3D ebpf_rss_load(&n->ebpf_rss, NULL); } } =20 --=20 2.45.2 From nobody Sun Nov 24 05:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725560114; cv=none; d=zohomail.com; s=zohoarc; b=LJV32Etd5WcRjTEkTzfB3twdSubMOSTJQha7d1Yor/pKAaiFkLXVBnCT0Po2Fl4MOVrFGGw3OGN58cQN+UwVWnJntnVIQyRy2ychHpbEcNLI4R5pa8tO1KEKAqAYw2GzbAI3ZpfeywuScbRRCoJSJE1N1m3pURK3/va+vKC+1fM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725560114; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GntZYB7SZ1FkxJjrkqDUyeQadmd2xxjQACdxKqQxrKs=; b=Kc+7HYnXd4+ShC7sPmBAjRNSGpmYQXZD79jA6awUzSJQORpMheakx7Jsu/fJGvbgLZamNDc7Aal/EdJVoMNssQ/0dVb2q1WN8cJgZ3f0pECKrR4Du3r7T6pfoPrLywy1MF0EeuSc04LgjBvScZHUdegTwtEguaAKRqp/WD7jxCo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725560114081168.36577161998082; Thu, 5 Sep 2024 11:15:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smGzY-0006Jx-AN; Thu, 05 Sep 2024 14:14:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzR-0005wp-Ed for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:13:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzP-0001Ik-S5 for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:13:53 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-Ouxfj5a5MHGhaucGe28kWQ-1; Thu, 05 Sep 2024 14:13:49 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2CF68195604F; Thu, 5 Sep 2024 18:13:48 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.53]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1C6C819560AF; Thu, 5 Sep 2024 18:13:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725560031; 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=GntZYB7SZ1FkxJjrkqDUyeQadmd2xxjQACdxKqQxrKs=; b=bOtpPKvbp9r/YoNT556WbH6lA2JOYrvKXwDoWpSzjQGYz8W6kjSnMUJojdQ6PNWcv+aYQH mro5CkW86JE8T84Z3IL4qgsk0jOuRA1ZItqGcqIj1h74YnTBvz9M6AaJQkjnPhgEQEf2bH 2ixmTW6x6TlDpYYwme6Z/XPyX/79rD4= X-MC-Unique: Ouxfj5a5MHGhaucGe28kWQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Yuri Benditovich , "Michael S. Tsirkin" , Andrew Melnychenko , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 5/7] hw/net: report errors from failing to use eBPF RSS FDs Date: Thu, 5 Sep 2024 19:13:28 +0100 Message-ID: <20240905181330.3657590-6-berrange@redhat.com> In-Reply-To: <20240905181330.3657590-1-berrange@redhat.com> References: <20240905181330.3657590-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725560115874116600 If the user/mgmt app passed in a set of pre-opened FDs for eBPF RSS, then it is expecting QEMU to use them. Any failure to do so must be considered a fatal error and propagated back up the stack, otherwise deployment mistakes will not be detectable in a prompt manner. When not using pre-opened FDs, then eBPF RSS is tried on a "best effort" basis only and thus fallback to software RSS is valid. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/virtio-net.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 558fc62844..f2690390c1 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1316,28 +1316,27 @@ static void virtio_net_disable_rss(VirtIONet *n) virtio_net_commit_rss_config(n); } =20 -static bool virtio_net_load_ebpf_fds(VirtIONet *n) +static bool virtio_net_load_ebpf_fds(VirtIONet *n, Error **errp) { int fds[EBPF_RSS_MAX_FDS] =3D { [0 ... EBPF_RSS_MAX_FDS - 1] =3D -1}; int ret =3D true; int i =3D 0; =20 if (n->nr_ebpf_rss_fds !=3D EBPF_RSS_MAX_FDS) { - warn_report("Expected %d file descriptors but got %d", - EBPF_RSS_MAX_FDS, n->nr_ebpf_rss_fds); - return false; - } + error_setg(errp, "Expected %d file descriptors but got %d", + EBPF_RSS_MAX_FDS, n->nr_ebpf_rss_fds); + return false; + } =20 for (i =3D 0; i < n->nr_ebpf_rss_fds; i++) { - fds[i] =3D monitor_fd_param(monitor_cur(), n->ebpf_rss_fds[i], - &error_warn); + fds[i] =3D monitor_fd_param(monitor_cur(), n->ebpf_rss_fds[i], err= p); if (fds[i] < 0) { ret =3D false; goto exit; } } =20 - ret =3D ebpf_rss_load_fds(&n->ebpf_rss, fds[0], fds[1], fds[2], fds[3]= , NULL); + ret =3D ebpf_rss_load_fds(&n->ebpf_rss, fds[0], fds[1], fds[2], fds[3]= , errp); =20 exit: if (!ret) { @@ -1349,13 +1348,15 @@ exit: return ret; } =20 -static bool virtio_net_load_ebpf(VirtIONet *n) +static bool virtio_net_load_ebpf(VirtIONet *n, Error **errp) { bool ret =3D false; =20 if (virtio_net_attach_ebpf_to_backend(n->nic, -1)) { - if (!(n->ebpf_rss_fds && virtio_net_load_ebpf_fds(n))) { - ret =3D ebpf_rss_load(&n->ebpf_rss, NULL); + if (n->ebpf_rss_fds) { + ret =3D virtio_net_load_ebpf_fds(n, errp); + } else { + ret =3D ebpf_rss_load(&n->ebpf_rss, errp); } } =20 @@ -3761,7 +3762,23 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) net_rx_pkt_init(&n->rx_pkt); =20 if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) { - virtio_net_load_ebpf(n); + Error *err =3D NULL; + if (!virtio_net_load_ebpf(n, &err)) { + /* + * If user explicitly gave QEMU RSS FDs to use, then + * failing to use them must be considered a fatal + * error. If no RSS FDs were provided, QEMU is trying + * eBPF on a "best effort" basis only, so report a + * warning and allow fallback to software RSS. + */ + if (n->ebpf_rss_fds) { + error_propagate(errp, err); + } else { + warn_report("unable to load eBPF RSS: %s", + error_get_pretty(err)); + error_free(err); + } + } } } =20 --=20 2.45.2 From nobody Sun Nov 24 05:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725560117; cv=none; d=zohomail.com; s=zohoarc; b=jKscULHI57g0BjxkXULGRQAheTBxucqxCPkui3KUiuPNZi1cCKWOwkQcMO/KSCsBZxw7pN90BxuSd4QZNxsis9VJ264kBjRX1Gj7j+OQJ5UGQNJDR/dpHPybVfOpM6KkjaUokdsVdojOiATIcDtncenMUCdFg5XMEFHeiV6Bf94= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725560117; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Jb3323FTeFVOq4Fo+9Ph+TDdlMgb3Q0Vo35BrafQYJ4=; b=QInMTVH+555IPyEuo77qHepifFboWuGCsIDslZTXO+GM7JTgerI8JlOyZ2eNLT+KI12uwv1dlCBUQVVRguSHul/KaHadlqwmsHE5HZsa7lXXGPWWVlsHgDzQ7qEhJxDnbBgTstj3SBaVFzMZ3MC22BFzUOViKOk1u7YkJX45aI0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725560117313690.6350303059165; Thu, 5 Sep 2024 11:15:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smGzb-0006XN-Ps; Thu, 05 Sep 2024 14:14:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzV-0006BE-3j for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:13:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzT-0001JL-At for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:13:56 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-584-_xUU55JGPuKjhv_LnKc7HA-1; Thu, 05 Sep 2024 14:13:51 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2EE2919560A3; Thu, 5 Sep 2024 18:13:50 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.53]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 564B419560AF; Thu, 5 Sep 2024 18:13:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725560034; 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=Jb3323FTeFVOq4Fo+9Ph+TDdlMgb3Q0Vo35BrafQYJ4=; b=Lodd8dtLmv311EqxynVvs82dcCFsnaClCtRQeFqsHlHPRNqaTyd70Hb4cl1PlczAKIScqJ xbmK5Qt6OhEdxLjnKqnw2RM+Ghhnq+Uww5Q+WkldBtMQOt7YM5ZlIU/9tTcG6R+SVdMhGp AvWYyvmycRup4jLIIFDTUB5oskbd+iE= X-MC-Unique: _xUU55JGPuKjhv_LnKc7HA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Yuri Benditovich , "Michael S. Tsirkin" , Andrew Melnychenko , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 6/7] ebpf: improve trace event coverage to all key operations Date: Thu, 5 Sep 2024 19:13:29 +0100 Message-ID: <20240905181330.3657590-7-berrange@redhat.com> In-Reply-To: <20240905181330.3657590-1-berrange@redhat.com> References: <20240905181330.3657590-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725560117818116600 The existing error trace event is renamed to have a name prefix matching its source file & to remove the redundant first arg that adds no useful information. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- ebpf/ebpf_rss.c | 19 +++++++++++++++++++ ebpf/trace-events | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c index f65a58b0b6..2afff27e78 100644 --- a/ebpf/ebpf_rss.c +++ b/ebpf/ebpf_rss.c @@ -74,6 +74,10 @@ static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx, Er= ror **errp) goto indirection_fail; } =20 + trace_ebpf_rss_mmap(ctx, + ctx->mmap_configuration, + ctx->mmap_toeplitz_key, + ctx->mmap_indirections_table); return true; =20 indirection_fail: @@ -131,6 +135,11 @@ bool ebpf_rss_load(struct EBPFRSSContext *ctx, Error *= *errp) ctx->map_toeplitz_key =3D bpf_map__fd( rss_bpf_ctx->maps.tap_rss_map_toeplitz_key); =20 + trace_ebpf_rss_load(ctx, + ctx->program_fd, + ctx->map_configuration, + ctx->map_indirections_table, + ctx->map_toeplitz_key); if (!ebpf_rss_mmap(ctx, errp)) { goto error; } @@ -178,6 +187,12 @@ bool ebpf_rss_load_fds(struct EBPFRSSContext *ctx, int= program_fd, ctx->map_toeplitz_key =3D toeplitz_fd; ctx->map_indirections_table =3D table_fd; =20 + trace_ebpf_rss_load(ctx, + ctx->program_fd, + ctx->map_configuration, + ctx->map_indirections_table, + ctx->map_toeplitz_key); + if (!ebpf_rss_mmap(ctx, errp)) { ctx->program_fd =3D -1; ctx->map_configuration =3D -1; @@ -259,6 +274,8 @@ bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struc= t EBPFRSSConfig *config, =20 ebpf_rss_set_toepliz_key(ctx, toeplitz_key); =20 + trace_ebpf_rss_set_data(ctx, config, indirections_table, toeplitz_key); + return true; } =20 @@ -268,6 +285,8 @@ void ebpf_rss_unload(struct EBPFRSSContext *ctx) return; } =20 + trace_ebpf_rss_unload(ctx); + ebpf_rss_munmap(ctx); =20 if (ctx->obj) { diff --git a/ebpf/trace-events b/ebpf/trace-events index a0f157be37..bf3d9b6451 100644 --- a/ebpf/trace-events +++ b/ebpf/trace-events @@ -1,6 +1,10 @@ # See docs/devel/tracing.rst for syntax documentation. =20 # ebpf-rss.c +ebpf_rss_load(void *ctx, int progfd, int cfgfd, int toepfd, int indirfd) "= ctx=3D%p program-fd=3D%d config-fd=3D%d toeplitz-fd=3D%d indirection-fd=3D%= d" ebpf_rss_load_error(void *ctx) "ctx=3D%p" +ebpf_rss_mmap(void *ctx, void *cfgptr, void *toepptr, void *indirptr) "ctx= =3D%p config-ptr=3D%p toeplitz-ptr=3D%p indirection-ptr=3D%p" ebpf_rss_mmap_error(void *ctx, const char *object) "ctx=3D%p object=3D%s" ebpf_rss_open_error(void *ctx) "ctx=3D%p" +ebpf_rss_set_data(void *ctx, void *cfgptr, void *toepptr, void *indirptr) = "ctx=3D%p config-ptr=3D%p toeplitz-ptr=3D%p indirection-ptr=3D%p" +ebpf_rss_unload(void *ctx) "rss unload ctx=3D%p" --=20 2.45.2 From nobody Sun Nov 24 05:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725560062; cv=none; d=zohomail.com; s=zohoarc; b=Pft0rB4LMd7WMZMzUpmiYBayMVd2v9Pb3Rf8z5Q+8POVTPLa73JYexPHmmb0WuqhK2HdaVdPUDI5s2IggJcoqKeM4OubTaZfyPp/gGdip8izJG++KFlQWBjzgAZ2Cqsdgqobqn+c6VmMs+al+K98DeWgoKegT+GFIRvXQ4wzrk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725560062; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bQkHr1QmRO1W82B1NnepTGechn1FxN3QSf+Q6T9d9U0=; b=PpwUdQzga0fgBPZVLaw/+ZnrMGcAP4894h3yA8C/2ajfETmXiH+t4V7aVkIAZV505TVKkowpQxycsYSX5k9ge49/mOG55VZ1OOPyCN/DBxoAIPx0hFVROJuhzZL1Hie5Bm5z61hu5rZTQwYejzdH5WEv55OxrJKCpWCQyUgj3VY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725560062077217.8984682403584; Thu, 5 Sep 2024 11:14:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smGzb-0006TO-4l; Thu, 05 Sep 2024 14:14:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzX-0006IL-Tp for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:14:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smGzW-0001K5-Dv for qemu-devel@nongnu.org; Thu, 05 Sep 2024 14:13:59 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-G0t5cjKOOxauFe4nxqtJTA-1; Thu, 05 Sep 2024 14:13:53 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6DF5E19560A3; Thu, 5 Sep 2024 18:13:52 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.53]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 75A8319560B3; Thu, 5 Sep 2024 18:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725560037; 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=bQkHr1QmRO1W82B1NnepTGechn1FxN3QSf+Q6T9d9U0=; b=VkZKee8N+/A6MjMYm2FcCzoyoU5XeeTtNzcJNZznt0DgRklJIZSwzmnulxNJB/PFPRfCRy uhBl1ti2u7rgihiL0ArrJKs1w/iZueUGVSVmJvV/ix729wt4pq7X5HOkIw0mCsA0ap35e1 qdgQ2Oaz18JjjxVdwyeJifygX2q5LTw= X-MC-Unique: G0t5cjKOOxauFe4nxqtJTA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Yuri Benditovich , "Michael S. Tsirkin" , Andrew Melnychenko , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 7/7] hw/net: improve tracing of eBPF RSS setup Date: Thu, 5 Sep 2024 19:13:30 +0100 Message-ID: <20240905181330.3657590-8-berrange@redhat.com> In-Reply-To: <20240905181330.3657590-1-berrange@redhat.com> References: <20240905181330.3657590-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725560063584116600 This adds more trace events to key eBPF RSS setup operations, and also distinguishes events from multiple NIC instances. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/trace-events | 8 +++++--- hw/net/virtio-net.c | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/net/trace-events b/hw/net/trace-events index 78efa2ec2c..6cad34aba2 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -399,9 +399,11 @@ virtio_net_announce_notify(void) "" virtio_net_announce_timer(int round) "%d" virtio_net_handle_announce(int round) "%d" virtio_net_post_load_device(void) -virtio_net_rss_disable(void) -virtio_net_rss_error(const char *msg, uint32_t value) "%s, value 0x%08x" -virtio_net_rss_enable(uint32_t p1, uint16_t p2, uint8_t p3) "hashes 0x%x, = table of %d, key of %d" +virtio_net_rss_load(void *nic, size_t nfds, void *fds) "nic=3D%p nfds=3D%z= u fds=3D%p" +virtio_net_rss_attach_ebpf(void *nic, int prog_fd) "nic=3D%p prog-fd=3D%d" +virtio_net_rss_disable(void *nic) "nic=3D%p" +virtio_net_rss_error(void *nic, const char *msg, uint32_t value) "nic=3D%p= msg=3D%s, value 0x%08x" +virtio_net_rss_enable(void *nic, uint32_t p1, uint16_t p2, uint8_t p3) "ni= c=3D%p hashes 0x%x, table of %d, key of %d" =20 # tulip.c tulip_reg_write(uint64_t addr, const char *name, int size, uint64_t val) "= addr 0x%02"PRIx64" (%s) size %d value 0x%08"PRIx64 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f2690390c1..5d26a8e260 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1241,6 +1241,7 @@ static bool virtio_net_attach_ebpf_to_backend(NICStat= e *nic, int prog_fd) return false; } =20 + trace_virtio_net_rss_attach_ebpf(nic, prog_fd); return nc->info->set_steering_ebpf(nc, prog_fd); } =20 @@ -1297,12 +1298,13 @@ static void virtio_net_commit_rss_config(VirtIONet = *n) } } =20 - trace_virtio_net_rss_enable(n->rss_data.hash_types, + trace_virtio_net_rss_enable(n, + n->rss_data.hash_types, n->rss_data.indirections_len, sizeof(n->rss_data.key)); } else { virtio_net_detach_ebpf_rss(n); - trace_virtio_net_rss_disable(); + trace_virtio_net_rss_disable(n); } } =20 @@ -1353,6 +1355,7 @@ static bool virtio_net_load_ebpf(VirtIONet *n, Error = **errp) bool ret =3D false; =20 if (virtio_net_attach_ebpf_to_backend(n->nic, -1)) { + trace_virtio_net_rss_load(n, n->nr_ebpf_rss_fds, n->ebpf_rss_fds); if (n->ebpf_rss_fds) { ret =3D virtio_net_load_ebpf_fds(n, errp); } else { @@ -1484,7 +1487,7 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, virtio_net_commit_rss_config(n); return queue_pairs; error: - trace_virtio_net_rss_error(err_msg, err_value); + trace_virtio_net_rss_error(n, err_msg, err_value); virtio_net_disable_rss(n); return 0; } --=20 2.45.2