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 188ECA0543; Tue, 24 May 2022 20:46:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE54B42670; Tue, 24 May 2022 20:46:33 +0200 (CEST) Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by mails.dpdk.org (Postfix) with ESMTP id D74784067C for ; Tue, 24 May 2022 20:46:30 +0200 (CEST) Received: by mail-pf1-f171.google.com with SMTP id h13so10920757pfq.5 for ; Tue, 24 May 2022 11:46:30 -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=WD7loauh6hXadZX3GnW47Wj+swJ9PflKf7RRAOfD9nI=; b=Ms45c9BfyS31slhxl4eWLH9en3N+lI3nmD03AtnRVsxKB8Yif+pudDshOIyahS7tD+ UuLWix0+1K6/ugHi4tJCKD0KE12UkXlZgHLBTCctNox2yn1/kDdWwufUdpJIr/Scak7V 1kL58r4yZOXE4BDGCbBJMGxnQfbAfl/1BXNeCblubC8KQJwLlCyY0Y6501DUX5P2UetH a4d79lRZalbkN5yWwxjanZrv1q1wPgkiCpNumpPYQ4vaEQY0qlG8TKspmPqi2zHQ3A1t IjnR61UtLHndgmVN2s7tRwfPutbp6Me7mvRulFtG9FtRNX8O3ZZ3AHS5INGYThLrdeMZ vo4w== 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=WD7loauh6hXadZX3GnW47Wj+swJ9PflKf7RRAOfD9nI=; b=vvD0P5lQ5wCd+KfRncpQ5LPGVNjwmYRWkjHyUgpCgQRCuW5TrekKiIqchCI46zOBId 40uOwm1lYPV6+B96X0kyb2X1BNkDgexjf1p218rSYlW+pPb+4f9Odn9KwU4Y5jD+dFdh SbcvW8WApzB675BONah9V5j14C03RFGvm+wmr4GvH8d4enpLcrebwl8QgdmmAl6fKKq3 9iti/HFZx6Of4zlq/69H7sU24Kg6n5qko7+zC/BxgGZ0U2r9GEcRVFp4PI2aGZhmsYPO sR4abl6TCWi8svZsBBOMV19QXLbSl8y9IAdh3fKVJI7LxK1y0+9p/p38wnBxkid09vtA yopQ== X-Gm-Message-State: AOAM532B+EYqSxAaZC7vQlZ5V8m+K9iIB+s+KHmZI3r/NfVp3wKT9SUs GIspeNA6Gq9PbaCYHAgZpJNe3TE5rWsxbw== X-Google-Smtp-Source: ABdhPJyggk4YCqar8EMj1UHOoQK/NJ6T0NcF9+fRsBra0pRLCyk3a0zFey2jbazI9hY5a6zJXMQTUA== X-Received: by 2002:a63:2406:0:b0:3f6:2513:5c63 with SMTP id k6-20020a632406000000b003f625135c63mr25111774pgk.550.1653417989802; Tue, 24 May 2022 11:46:29 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id c21-20020a17090ab29500b001cd4989ff42sm63443pjr.9.2022.05.24.11.46.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 11:46:29 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , wojciechx.liguzinski@intel.com, Cristian Dumitrescu , Jasvinder Singh Subject: [RFT 2/2] rte_pie: fix incorrect floating point math Date: Tue, 24 May 2022 11:46:22 -0700 Message-Id: <20220524184623.480646-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220524184623.480646-1-stephen@networkplumber.org> References: <20220524184623.480646-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 multiply to compute the probability. 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..82e6a05645a6 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() < (uint64_t)RTE_RAND_MAX * pie->drop_prob) { pie->accu_prob = 0; return 1; } -- 2.35.1