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 D3703A0547; Thu, 26 May 2022 22:27:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 35CD24281B; Thu, 26 May 2022 22:27:04 +0200 (CEST) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by mails.dpdk.org (Postfix) with ESMTP id E843A427EA for ; Thu, 26 May 2022 22:27:00 +0200 (CEST) Received: by mail-pf1-f176.google.com with SMTP id b135so2577972pfb.12 for ; Thu, 26 May 2022 13:27:00 -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=26mDrDq8AwlTp+mPD8+6Kysic6mo72Linr72U5N0ysfxU9Wy063dz+Lr/DHeu3ivlZ ehiyA6vlZPPQujelOYJi2Gw7mNXMPdyRelviy/LVyZiPH8NVYMXdbTdiZ393s4jnkBNF 2GNNS/xeleuiOJlxLO4GBL53DKkq9XCpv4N5xQEMA6qtAkDQpdyoD7msFi69Il8EFydo 9xKz6cat0n68fVdjirC7Kq6UAAYYbZr8VW/rIM7T1WkmlEqX7gm5R+vAFfopGXNjqykE tn+6GOen5NZONxwJ5prFtgvnlNKYHCZwAdU10YVDKG/V4N39j8ZvTmce/nzV4+6Myf/E /WCw== 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=l6uqkNUXawvZh2KrGKkxlj81s2Q3QZhs6NxP32CK4KlmF21u21rz3hCWdksjOe3wr6 DPF19m4qhxWHzFL3tXYZkvOAWAKNEn2LKZ99bzGmvSiE+10AlY0PO81/f6lfCIvvDz8+ tbelcMEmOEiBwC/vufMQ6N1f1aB2QVY6B5MJG4s9HaLpBGwjzCRmkbUMsHL2Sw+Nqltq BCXhng4Il6hT8Sb7kJ2R1oWBzLiGOLU018S554efF2f3u34B9s+E0b2Rh1lhVPUcoEh0 wJPpVMmVLZZQmMQMarDKWr62qf7U+cV15NrYLgaHNDX0X49d2LI6jBVeSrqo/OL/mzep YBtQ== X-Gm-Message-State: AOAM531QAZcdHKaLYtw/ixXZhBhBMTV8bmdw35DZWIft8IPkEhtRkLnh ejKoh1atelZeU1ZoI42QYQqJYqqEESCzaw== X-Google-Smtp-Source: ABdhPJz1Nv7wPjay2Y92K6Kw+fnPZpviMOGbgGKFvaL2KyiI0xWlyfw6/CvfXqcR6DuUFZZBnyXSqQ== X-Received: by 2002:a62:8604:0:b0:519:363d:8eb3 with SMTP id x4-20020a628604000000b00519363d8eb3mr68692pfd.83.1653596819792; Thu, 26 May 2022 13:26:59 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id c20-20020a170902b69400b0015e8d4eb1e5sm2025316pls.47.2022.05.26.13.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 13:26:59 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu , Jasvinder Singh , Wojciech Liguzinski Subject: [PATCH v5 3/3] rte_pie: fix incorrect floating point math Date: Thu, 26 May 2022 13:26:53 -0700 Message-Id: <20220526202653.99796-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220526202653.99796-1-stephen@networkplumber.org> References: <20220524184623.480646-1-stephen@networkplumber.org> <20220526202653.99796-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") 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