From patchwork Mon Sep 9 04:54:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1982308 X-Patchwork-Delegate: echaudro@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PcCoZuHz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X2Dzh0ty4z1y1l for ; Mon, 9 Sep 2024 14:55:27 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 079EF404E5; Mon, 9 Sep 2024 04:55:22 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id DOgeyKOabFbB; Mon, 9 Sep 2024 04:55:20 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org C30FC40558 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PcCoZuHz Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id C30FC40558; Mon, 9 Sep 2024 04:55:20 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7C75FC0014; Mon, 9 Sep 2024 04:55:20 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6BB75C0017 for ; Mon, 9 Sep 2024 04:55:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3FA5640500 for ; Mon, 9 Sep 2024 04:55:19 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id IpdT_7-ZsTay for ; Mon, 9 Sep 2024 04:55:18 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=mkp@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 4E58B4028E Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4E58B4028E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 4E58B4028E for ; Mon, 9 Sep 2024 04:55:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725857716; 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=Y6yTZ2YIG0ibVZkSqiJOyjLYXZQk4gLN6V9YcvoIyFE=; b=PcCoZuHzAudUu00zUOGGaMiWaxY93H/ZebaiSl4/Ac+FIrihsYryQEjRXCK4+vr2Py9asl zyaoMYDV/Zs+ctFnCp415qe+bolNECY5RSqJqd7pXc8qaIgZCvQbTOcu3duBfg1G7qU4mk VtEufPg/JoDhuRb+bFT3td5S1ndPJq8= Received: from mx-prod-mc-04.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-216-yjVNjQmlObyJQIPBokc_oA-1; Mon, 09 Sep 2024 00:55:14 -0400 X-MC-Unique: yjVNjQmlObyJQIPBokc_oA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 61DB419560B4 for ; Mon, 9 Sep 2024 04:55:13 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.9.170]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 867C31956048; Mon, 9 Sep 2024 04:55:12 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Mon, 9 Sep 2024 00:54:59 -0400 Message-ID: <20240909045505.236657-3-mkp@redhat.com> In-Reply-To: <20240909045505.236657-1-mkp@redhat.com> References: <20240909045505.236657-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v3 2/8] dpif-netdev: Remove undefined integer division. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Clang analyzer will complain about floating point operations conducted with integer types as rounding is undefined. In pmd_info_show_rxq() a percentage was calculated inside uint64 integers instead of a floating pointer variable for a user visible message. This issue can be resolved simply by casting to double while dividing. Signed-off-by: Mike Pattrick Acked-by: Eelco Chaudron Acked-by: Simon Horman --- lib/dpif-netdev.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index f0594e5f5..d12e716b6 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -942,9 +942,9 @@ pmd_info_show_rxq(struct ds *reply, struct dp_netdev_pmd_thread *pmd, ? "(enabled) " : "(disabled)"); ds_put_format(reply, " pmd usage: "); if (total_pmd_cycles) { - ds_put_format(reply, "%2"PRIu64"", - rxq_proc_cycles * 100 / total_pmd_cycles); - ds_put_cstr(reply, " %"); + ds_put_format(reply, "%2.0f %%", + (double) (rxq_proc_cycles * 100) / + total_pmd_cycles); } else { ds_put_format(reply, "%s", "NOT AVAIL"); } @@ -959,8 +959,10 @@ pmd_info_show_rxq(struct ds *reply, struct dp_netdev_pmd_thread *pmd, if (total_rxq_proc_cycles < busy_pmd_cycles) { overhead_cycles = busy_pmd_cycles - total_rxq_proc_cycles; } - ds_put_format(reply, "%2"PRIu64" %%", - overhead_cycles * 100 / total_pmd_cycles); + + ds_put_format(reply, "%2.0f %%", + (double) (overhead_cycles * 100) / + total_pmd_cycles); } else { ds_put_cstr(reply, "NOT AVAIL"); }