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 76CAEA04FF; Tue, 24 May 2022 00:49:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5C6574067B; Tue, 24 May 2022 00:49:51 +0200 (CEST) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by mails.dpdk.org (Postfix) with ESMTP id 660044003C for ; Tue, 24 May 2022 00:49:50 +0200 (CEST) Received: by mail-pg1-f173.google.com with SMTP id j21so14651049pga.13 for ; Mon, 23 May 2022 15:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version :content-transfer-encoding; bh=Spmtq16/H6sIUE826JrdQFhlBlBPHSKKZnT93ieRQMw=; b=valzf4z/4MH+PdLMiADPyYKEoSFSkp9YHWwCmnVVP11Kc3Wq9vlt1byCwpVJX7+SYn HBr9+s930L/F2L8xMwVNncAD7oyRBFkrDLfS911LpIdOiXr701cEv7CHXulkOYrFMzbj SoWoHwxybqT2YyEry/OiQiPTFlI7AJziziWG4SGtKWqRD4g39KGTRutzVM6zI+ypRI7I WSzsN+av6XtHIYP7sQKoiYH738hfZ4xsB4kRkrEOnGQDnhpTDG9EHzS/qCXf1LFh5aGD f88akl3z6FioyDHRXF42RFiwFSkiZITcfls/3xg+JP8TxWdLfI9vZPINZCO/xOUXbzFV jucA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-transfer-encoding; bh=Spmtq16/H6sIUE826JrdQFhlBlBPHSKKZnT93ieRQMw=; b=cMiJHoCRAKDg25XllgXxtr+xCBZzzcCsrdi7oG03Vw37QY9Wg4hH6iMiAkAnxE7lIt 2neZRoRnt8RJI4q0i2Pc49b91Kd5E2uI2zwxy9Mxd6o/6KhAUEfSoeuOoJwWIRERnIiI Q9+Uos7NYCWQ5o13yvt7qQWa4E6FSkOGAwt6ozQkdFyIvW1aj8dpB4aSdxtzQ9HCw14V +UBKu4SNEpdJF7d4xSBLqib7NQkV78TzUuNLl+bKoAzxwyFRJgSZhcjv+/p4a00Iyafd +q7+e2maUGq+o5zbYHyHGTyBZ94Ia4xj2IF5AbEySS2g1Lrrixvvm/jjie5bsUO392ht tgJA== X-Gm-Message-State: AOAM531aaEiWV1xxWM9lPRvpX5J54pQDCxNuiNw+1/5tCvFpEqo1HU9+ YiLU0+MnPiTYXZFC7+I6bOnhCsQB3c9CDA== X-Google-Smtp-Source: ABdhPJxf72dFGWj5bVHUibAa0n1drurBI/Tqj5Mf3dEJOUA06nVW4qvN5JYfp0tZWtmuy9uYQZFP2A== X-Received: by 2002:aa7:88d2:0:b0:50a:cf7d:6ff1 with SMTP id k18-20020aa788d2000000b0050acf7d6ff1mr26121545pff.67.1653346189550; Mon, 23 May 2022 15:49:49 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id jh21-20020a170903329500b0015e8d4eb24dsm5647042plb.151.2022.05.23.15.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 15:49:49 -0700 (PDT) Date: Mon, 23 May 2022 15:49:46 -0700 From: Stephen Hemminger To: Cristian Dumitrescu , Jasvinder Singh Cc: dev@dpdk.org Subject: DPDK PIE computation is broken Message-ID: <20220523154946.5a4bcb33@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Was looking at where rte_rand() is currently used in DPDK. Found that rte_pie uses it (that is expected. But it also using it wrong on a couple of levels. First. Look at: #define RTE_RAND_MAX ~0LLU /**< Max value of the random number */ _rte_pie_drop(const struct rte_pie_config *pie_cfg, struct rte_pie *pie) { uint64_t rand_value; ... rand_value = rte_rand()/RTE_RAND_MAX; if ((double)rand_value < pie->drop_prob) { pie->accu_prob = 0; return 1; } /* No drop */ return 0; Since rand_value is 64 bit unsigned value the division happens as unsigned Therefore for all values of rte_rand(). rand_value is going to be 0 Converting it to double just makes it zero in another form. How was PIE tested? Why was this not seen. Second, the obvious fix would be to make rand_value a double. But doing floating point divide in the packet path would be a major performance loss. Saw this earlier with the packet_sched code.