From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 229A7A0517; Wed, 10 Jun 2020 12:21:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4F8C52C27; Wed, 10 Jun 2020 12:21:30 +0200 (CEST) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by dpdk.org (Postfix) with ESMTP id 98CE829C6 for ; Tue, 9 Jun 2020 21:57:56 +0200 (CEST) Received: by mail-qk1-f196.google.com with SMTP id c185so22101865qke.7 for ; Tue, 09 Jun 2020 12:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:from:to:cc:subject:in-reply-to:references :mime-version:content-disposition:content-transfer-encoding; bh=eeQUw54YqVw7D5BKX1IHH6/iIKyQc7Y0cM75qxJVkJo=; b=UQg4JfEUVpIGjdDlid2SmiPP7MlA/QxTvgKdVb1QvBYZvAyM0wkThyUhZiYEG6AwGk 1N6bjVVO/F2h11aGNXgXMl7V1yxtHDR6qGtRPkKTKzvWrr+rRqLhtPpWyuhJOzlgBmFM 4E5nMxKLof15PVSOk1JQT6F1po59hTI6kVbeD5qsDdLA6e/jCh45gMRcDXvd1yH315p/ RY4At0t+Kkl51YgemHGFg/+KeryNeGGyHdSjm63ZEM9CD/TQ7Zf/z1K4mx7l7HfYzUb8 bnfRDB0i1oyzwQxP/kgrw8Zdoqz5bOuXwa3otmAeEAqDL45zHHKdOdx6qdkXc3Izq6Wh AvzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:from:to:cc:subject:in-reply-to :references:mime-version:content-disposition :content-transfer-encoding; bh=eeQUw54YqVw7D5BKX1IHH6/iIKyQc7Y0cM75qxJVkJo=; b=Qca9M1RTEyqKHx2tQNchEs541lhFQXx5RJQhbE18MB2HS80rbI6Y/6qRagKqXZPt+j q74f7KnhKq2zm/Kb7LCQ0AR/NjhEdYVvLtfMqy4S478ahe6bgM7fxLREIF7ZvguzUG22 PsgZTnrl8l88G4G8H77aN3oFl6yHgHBYkaHVPQdagJh7vDS8Mopo6WvnhpVELDBtTOFa UBEoLLFBaOOgGZ/urn5tuNoY/U77IIOMDtQMk60n1jYkchoDZOyLxA7B1elCnL1aEUQM LQuaBs2XWMXWLjgukuZPP194+lSl6TLtxYwke5F3JWkjs4NdVwKzLBwh0H4UoOAN8m8V 5oWQ== X-Gm-Message-State: AOAM532qF0EDaL83t4MCwszVMsNejrZnzTTgAfFtg3SNE3owMHMestKn LVcR709NK5l4nYbVGiHIm+s= X-Google-Smtp-Source: ABdhPJysNZIfJGVay/uf/VRS6Hwzb9iU4JlxBslNeWZM1gAvW66eHyguQgduNN+z6FU5gRULEyebxg== X-Received: by 2002:a37:aec4:: with SMTP id x187mr30893786qke.332.1591732675636; Tue, 09 Jun 2020 12:57:55 -0700 (PDT) Received: from localhost (modemcable249.105-163-184.mc.videotron.ca. [184.163.105.249]) by smtp.gmail.com with ESMTPSA id r5sm11922952qtc.40.2020.06.09.12.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 12:57:55 -0700 (PDT) Date: Tue, 9 Jun 2020 15:57:53 -0400 Message-ID: <20200609155753.GB111880@t480s.localdomain> From: Vivien Didelot To: Stephen Hemminger Cc: dev@dpdk.org, Ferruh Yigit , patrick.keroulas@radio-canada.ca, thomas@monjalon.net In-Reply-To: <20200609124357.20e7b4ea@hermes.lan> References: <20200609190719.105323-1-vivien.didelot@gmail.com> <20200609124357.20e7b4ea@hermes.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Wed, 10 Jun 2020 12:21:28 +0200 Subject: Re: [dpdk-dev] [PATCH v2] net/pcap: support software Tx nanosecond timestamps X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Stephen, On Tue, 9 Jun 2020 12:43:57 -0700, Stephen Hemminger wrote: > On Tue, 9 Jun 2020 15:07:19 -0400 > Vivien Didelot wrote: > > > > > +#define NSEC_PER_SEC 1000000000L > > + > > static inline void > > calculate_timestamp(struct timeval *ts) { > > uint64_t cycles; > > @@ -294,8 +296,14 @@ calculate_timestamp(struct timeval *ts) { > > > > cycles = rte_get_timer_cycles() - start_cycles; > > cur_time.tv_sec = cycles / hz; > > - cur_time.tv_usec = (cycles % hz) * 1e6 / hz; > > - timeradd(&start_time, &cur_time, ts); > > + cur_time.tv_usec = (cycles % hz) * NSEC_PER_SEC / hz; > > + > > + ts->tv_sec = start_time.tv_sec + cur_time.tv_sec; > > + ts->tv_usec = start_time.tv_usec + cur_time.tv_usec; > > + if (ts->tv_usec >= NSEC_PER_SEC) { > > + ts->tv_usec -= NSEC_PER_SEC; > > + ts->tv_sec += 1; > > + } > > } > > > > You may want to pre-compute the reciprocal here to save the expensive > cost of divide in the fast path. See rte_reciprocal. Please note that I did not change the calculation logic that was previously used here. Thus pre-computing the reciprocal here to save the expensive cost of divide in the fast path seems out of the scope of this patch to me. Can we keep this for a future patch maybe? Thanks, Vivien