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 49226A0545; Wed, 25 May 2022 00:18:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C2E4427F9; Wed, 25 May 2022 00:18:34 +0200 (CEST) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mails.dpdk.org (Postfix) with ESMTP id 5B8BA40E2D for ; Wed, 25 May 2022 00:18:31 +0200 (CEST) Received: by mail-pj1-f54.google.com with SMTP id fw21-20020a17090b129500b001df9f62edd6so2832806pjb.0 for ; Tue, 24 May 2022 15:18:31 -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=K1gatM5F9Uu69n0XVDFQSNbf7MVSyExw7ku4hOjpi4k=; b=J5XAtf5SqxJdPoUaNLvQNy4QJtCULioAZqH1uJ2Z5ZiA1dpGSyYsFsOIBjfSTpU9mh sdYGc1SwtnTaZd8axhYXD6NjzdBgmotJGeozAmjrIfXdPdpZ0DlgtQ95EiitmfWi1nS5 QrsB3Cdl3ME7U7sbFLzuNp9OD8yXFv3ZB4bzhfC4H156nhnlZ4QOAzlTYIbglmml5aki +P+YaGCnz3nM97ZG84h/s4snNxDkhG1cACBhp441i9p3yAlcAkjJ+0NA26WFEmv2dvYl pWAR2v8kxJZg1hRzSkQx7ZAXLaSqZquCJu/d22jq0O6TQNM9Ped6AYMeUFVeSogtZAEn CnQQ== 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=K1gatM5F9Uu69n0XVDFQSNbf7MVSyExw7ku4hOjpi4k=; b=Yd6YRrOyDanxPlrIHfMdTaD0MHoX8AAv3m5Be4foYVnRYfHv7T55GUHDI1GUWnsoik cNMPg3cZCyZgF1ozokIBTYUt/K9Fe4g0pPUmBIMnGPwhyDMSPj0uUxDlhTjazpNVGui6 6HpKhmE0Bht1a8+osRQbzI01kS0QV82zOIhbx3VOFQKPAJ3m1PfyzFMYLVaLFvL6aZKQ BaU2gFi97s4kA+w9FjV8gobv0b1mL0lGv2g9qlG2hkVaaPN5hV4H8yynNtSylEnX4Rxy rOJCVVZBY82gDZ6r7pQgZs4tvXcMezfEiaNFoh0YB1mHopboHiYbIalDMGpcZrlf14oa VhQA== X-Gm-Message-State: AOAM531PI4PYLLmmoY4FtoHasa0oHF6+ahyNvJMe8HyrmxTfGa6nJCBh GezvRItqAVMDfndbSfDokrM7y/Vke6YTWw== X-Google-Smtp-Source: ABdhPJx4f1gX/4afNWx6PErijbKuQR6Y5EF9ecjppGxTHXd5xu9MdPMHpqDCynlCkpqS8ee7sGy8uA== X-Received: by 2002:a17:90b:3a85:b0:1e0:548:2bf7 with SMTP id om5-20020a17090b3a8500b001e005482bf7mr6787341pjb.55.1653430710223; Tue, 24 May 2022 15:18:30 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id j64-20020a62c543000000b0050dc7628158sm10007121pfg.50.2022.05.24.15.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 15:18:29 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , wojciechx.liguzinski@intel.com, Cristian Dumitrescu , Jasvinder Singh Subject: [RFT v2 3/3] rte_pie: fix incorrect floating point math Date: Tue, 24 May 2022 15:18:24 -0700 Message-Id: <20220524221824.1037693-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220524221824.1037693-1-stephen@networkplumber.org> References: <20220524184623.480646-1-stephen@networkplumber.org> <20220524221824.1037693-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_rand_float() 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..ed433300c2cf 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_rand_float() < pie->drop_prob) { pie->accu_prob = 0; return 1; } -- 2.35.1