From patchwork Wed May 25 20:31:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 111864 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 155D5A0548; Wed, 25 May 2022 22:31:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B74A427F6; Wed, 25 May 2022 22:31:34 +0200 (CEST) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id E99B441181 for ; Wed, 25 May 2022 22:31:32 +0200 (CEST) Received: by mail-pj1-f53.google.com with SMTP id z11so10896879pjc.3 for ; Wed, 25 May 2022 13:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dn470I1AAXYIPllkE0iKbl8OtBnx1LYxnn0mwkxAqPY=; b=pt5bGAWkj0QijlG84ovOj5K0Y8srt1NVBywu1UEESoDZX/iH9ce+fUnxjIcL9Ft4yz pXzmMJ31oAgosu0ANfKZ/9DGEHY2Te65SJmxzrqHeD0NtDO2BF8ftGvK281CW5e8e9mT yviPr2P6qMDw672E9tSq28wFKhExZ+e+2dW020bnNMzaaJhA02NnV6+70KjoZzwC0FIM V7DlOTjp7RYtU2RxWKZdxIixhEX92Mogzid2xIT8bUt97Ih7EoXGGzHeWX0YqFj/yHSN leAfkMiHSUmKCqLJpS3taGVUycdetxy/zsmSwvfvVKjYuJSqBcoTKWw+mezNYeIUpf8q apfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dn470I1AAXYIPllkE0iKbl8OtBnx1LYxnn0mwkxAqPY=; b=jxvgpQoZ9LCZUH6WBcyEr5YwrgMJ8kJ0ilAQqa/oUJo3GHXpbNa+sr86OC3PmTuNP3 L8liTjrSJ/C0r/ONK/J/1ZB1N0gF2ZaUBEWfeYQKXgAi8mOg1Df7HNkwV8mO1SlrFLA1 8CdxAqwtG+8P8AJmziXyuD/gOQtPQFweJRSs1Ji8NC9jPb93y5rUhf9POAg6C3Fg03DT m55pWEJKXYFHA5cnchY1oDFfIskzX6ifdqWxXnvsVOwLwNiM5qSfReWnLTKeSO5wsBfW 7IdGgZoftVhQy8g2iw0LWZL+NrYv40VYU2lR5nLfSFlzNqRO/YM8p52I5muleOrm9q81 C/BA== X-Gm-Message-State: AOAM530erhOn0ZCevABvsn1NCSuOoiBqB+/lNy7E5JRa8kNleaxQJT53 X1uppCrR2zdUbYwhimmQzuHksPfv37310A== X-Google-Smtp-Source: ABdhPJwaAJ+E2/qXp/K/44DKRnUV9bYuqelahWL+HvKKbvowd95XMjget++idPz4dNWr4/glw+E9fA== X-Received: by 2002:a17:903:32cc:b0:161:9539:fd49 with SMTP id i12-20020a17090332cc00b001619539fd49mr35105272plr.117.1653510690811; Wed, 25 May 2022 13:31:30 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id a26-20020a62d41a000000b0050dc7628176sm11766091pfh.80.2022.05.25.13.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 13:31:30 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu , Jasvinder Singh , Wojciech Liguzinski Subject: [PATCH v4 3/3] rte_pie: fix incorrect floating point math Date: Wed, 25 May 2022 13:31:23 -0700 Message-Id: <20220525203123.277180-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220525203123.277180-1-stephen@networkplumber.org> References: <20220524184623.480646-1-stephen@networkplumber.org> <20220525203123.277180-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The function rte_pie_drop was attempting to do a random probability drop, but because of incorrect usage of fixed point divide it would always return 1. Change to use new rte_drand() instead. Fixes: 44c730b0e379 ("sched: add PIE based congestion management") Signed-off-by: Stephen Hemminger --- lib/sched/rte_pie.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/sched/rte_pie.h b/lib/sched/rte_pie.h index 3e2c1ef46721..528f2ea878e8 100644 --- a/lib/sched/rte_pie.h +++ b/lib/sched/rte_pie.h @@ -217,7 +217,6 @@ __rte_experimental _rte_pie_drop(const struct rte_pie_config *pie_cfg, struct rte_pie *pie) { - uint64_t rand_value; uint64_t qdelay = pie_cfg->qdelay_ref / 2; /* PIE is active but the queue is not congested: return 0 */ @@ -240,9 +239,7 @@ _rte_pie_drop(const struct rte_pie_config *pie_cfg, if (pie->accu_prob >= 8.5) return 1; - rand_value = rte_rand()/RTE_RAND_MAX; - - if ((double)rand_value < pie->drop_prob) { + if (rte_drand() < pie->drop_prob) { pie->accu_prob = 0; return 1; }