From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 05C27A0555; Wed, 25 May 2022 19:12:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D827E427F9; Wed, 25 May 2022 19:12:41 +0200 (CEST) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTP id F18DF427F9 for ; Wed, 25 May 2022 19:12:40 +0200 (CEST) Received: by mail-pj1-f46.google.com with SMTP id x2-20020a17090a1f8200b001e07a64c461so2196174pja.4 for ; Wed, 25 May 2022 10:12:40 -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=6EbH89RIQ9T1r4Bv5a9z0U19T6cYdGe3OiQ5CK+/Phs=; b=RCr+gEb0vfpV5pjkDg5f9YBK0axPKMsiDyrxPbqPZzZc/3E6w5rTusI3yO0pK+j+Y5 q+qiZLMBgyF4Nx/zTqRAZiHopkB+khOwXx1NfMi+SD2ny/YlPvj8sTxKaTQdaHZA9exe Z3LOcUgsO/4Nuj/CXw6TNYxpNSzOGjxeHavwHF3rPDojhZ0MRI5SGx6/kTsDfLoaDHUG IDf5DRunlLzLXZYWkcvTEjB+lJSjUwiWB/qBn3F+1+QOeYBZfFryIu5WiGdD39ZXA/Pl wFtApy14eHwuhkatAjF5nkiT/YU4Ub6PUuYcnPZrlhsIvohHtllSrgC8W7Q+/JeieMq1 37YA== 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=6EbH89RIQ9T1r4Bv5a9z0U19T6cYdGe3OiQ5CK+/Phs=; b=ZdPMGG1LHPA2l983gLkTYliCWmPCfGVZEVgrDmWPgPTbM+sD6jM7v/P8pdOpi3c2G1 7tfMZlvAxgPRbfekuR27MXW0dcG8Ge6Ae55tiNKtXKwJ+m1UZYGe6QRRbIZKcO0cdP21 bstOZrtPyjToPhy2cikH0g4V1YDpScYPOgYipHdT+rB4Mk8h2/+bRwzpK9kIcmaMHjOz xJCB/KPV3HngxDQlXXcudyyy+IOSDFzqjGQkblFfIN9AW7+zX+fFS0ojW06XVEVzF9Us P3sJm3SJ7UjTyQ6V9HHq0ARszZFsimZRJ2YO/6U3l4BjHEECaVNn7mDBIgI8gw05nXQk 7ZBA== X-Gm-Message-State: AOAM532uqGMqUcQecJRKxicEtjK+xC2+5MW8W3dZZ/N2XNcBUVK0+Aem lPZJz5AM5+ffX72UgujM1UTTfV33L3W9cg== X-Google-Smtp-Source: ABdhPJzZzoJ+E7NkkZeeViJJ2+SMaYAtgtOgWLdWF7CMxZCUvINbrhIxAMpsXEnTRPz8qHg+omJfuQ== X-Received: by 2002:a17:90a:a096:b0:1df:58d7:5b20 with SMTP id r22-20020a17090aa09600b001df58d75b20mr11462435pjp.212.1653498758772; Wed, 25 May 2022 10:12:38 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id s23-20020a170902b19700b001622c377c3esm6139599plr.117.2022.05.25.10.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 10:12:38 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , wojciechx.liguzinski@intel.com, Cristian Dumitrescu , Jasvinder Singh Subject: [PATCH v3 3/3] rte_pie: fix incorrect floating point math Date: Wed, 25 May 2022 10:12:30 -0700 Message-Id: <20220525171231.200035-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220525171231.200035-1-stephen@networkplumber.org> References: <20220524184623.480646-1-stephen@networkplumber.org> <20220525171231.200035-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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") Cc: wojciechx.liguzinski@intel.com 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; } -- 2.35.1