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 75FE243BCF; Fri, 1 Mar 2024 18:59:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 53E3E433E8; Fri, 1 Mar 2024 18:58:59 +0100 (CET) Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by mails.dpdk.org (Postfix) with ESMTP id 2E65E4335E for ; Fri, 1 Mar 2024 18:58:56 +0100 (CET) Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6e53f3f1f82so1687456b3a.2 for ; Fri, 01 Mar 2024 09:58:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1709315935; x=1709920735; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2d7NCd2qXWnxq7Co6oImJ9oP+LBIrVz9yIEOvUJkAlA=; b=Y1hStP0OCIdqqwGyP6tuFY5q3Xc4j7j0gCcLaL0z2p+i9Ac4iqtyMRdca2iirP18Xl JiJl49jsU1lc/mOpN/UOW1oakkr++ul9Gt5r9RLWupax2xmx5Z02v71oOR0NDBuZwfTQ P8Fd1jzx6g5juCisLDwIgd+JtCwpju1CyrxwbSzMsky/9DXI3g+aHC+5TANzVyRhKcDU v7ovAPF0JY/bVGiUCANHRY2iA3fyBY+VnOT24i57iK7oVzRsA220ZIWHVZag7VNRKohM /GV21o0Iug5/cVE6/q9/OvoqYoc4A8qSsKVBQpwLsEOe1RiLkH93ztnUr4SNNBOPdxNJ 0AEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709315935; x=1709920735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2d7NCd2qXWnxq7Co6oImJ9oP+LBIrVz9yIEOvUJkAlA=; b=EHDHRAirERjZReV5XLxa0Wa3+iS99s7urrZ9hEmYSkwvOlpMy9wW1Pl1QxFJAgFJI3 A2zbHZzsJHY7QH09C87wh41u123nods/uoxczm0lukSk/y4+8Eg9HzzRAVA+zFVvyI0K sbxRRodBMxQRxLSEY5o4j1RZriSHqLo6CyPoQFQK/6YuvNwNxN4ejedyuuWxTlSw0JLO Yv7KqLe9QRoisNlnJApUa2BOzxfIO7LQTOnf1+59J+zZ+o8AW2B3NSAf8BsCJHq2+JnO b42ZpcT/r7AAfXxSy0hSPDtMKhZywX8/BEWY0d8TlBD/Xe6eY3FcO1kXbxbER7/Tn/NQ betQ== X-Gm-Message-State: AOJu0YwSAoMR7uasLGXk/9mq7+91yjoYDqOBkkI3/JCsOkSNn9R1LgLY ixBenvDNjXLI7yHcROHd33voKNh5UGnt7kthNAFZq5FMj/KhkkVeCdTLxdQsx7KFJbYAFDrsF8N BD/qDrg== X-Google-Smtp-Source: AGHT+IFFoEnWCYSxuQWEpMIiW28Dle+9Q4kXG2Meg5LvHM9EOgDBR7XBjsdUarDE8a44H0N/u5fyPg== X-Received: by 2002:a05:6a00:4fc4:b0:6e5:7ac8:c27e with SMTP id le4-20020a056a004fc400b006e57ac8c27emr2425827pfb.22.1709315935288; Fri, 01 Mar 2024 09:58:55 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id bw7-20020a056a02048700b005e438ea2a5asm2938828pgb.53.2024.03.01.09.58.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 09:58:55 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH 3/6] examples/l2fwd-keepalive: use rte_drand_max Date: Fri, 1 Mar 2024 09:57:08 -0800 Message-ID: <20240301175842.159967-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240301175842.159967-1-stephen@networkplumber.org> References: <20240301175842.159967-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 There is a better way than using rand() to compute a random interval. Signed-off-by: Stephen Hemminger --- examples/l2fwd-keepalive/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c index 7e0f99a361bc..c077e7f3d4f0 100644 --- a/examples/l2fwd-keepalive/main.c +++ b/examples/l2fwd-keepalive/main.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -220,7 +221,7 @@ l2fwd_main_loop(void) } uint64_t tsc_initial = rte_rdtsc(); - uint64_t tsc_lifetime = (rand()&0x07) * rte_get_tsc_hz(); + uint64_t tsc_lifetime = rte_rand_max(8 * rte_get_tsc_hz()); while (!terminate_signal_received) { /* Keepalive heartbeat. 8< */ -- 2.43.0