From patchwork Tue Jul 31 16:03:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matteo Croce X-Patchwork-Id: 951697 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41g1T0166Rz9s3N for ; Wed, 1 Aug 2018 02:03:48 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732477AbeGaRoi (ORCPT ); Tue, 31 Jul 2018 13:44:38 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:55109 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732419AbeGaRoi (ORCPT ); Tue, 31 Jul 2018 13:44:38 -0400 Received: by mail-wm0-f68.google.com with SMTP id c14-v6so3679534wmb.4 for ; Tue, 31 Jul 2018 09:03:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kbamGR0f+Fs6rqXcsvFpuECTmWLUMt8b4q9CY2bwYaU=; b=kTr6r4+Z7CX3y9tDtBdELUU5XHVIWVYy4JmhwuJgG1c1naNgTGevrIwz1JBEUL2c6J Li5a1q9Kl5P/nXOx4tG3vb5yP6aE6EPJ87SKxzfa0Ioi2Sayc2j1IhvmJoNNw2BAjRlQ hap+Pr0NnKL+UTeBp8GxMq/GacFavcrVWLdM05/YwADD20H0Vx4tPQXF3qyENGcQrcPR vitVXi2oiUeA3fNVRsl7GtEpsuEbllNoNASeARFRH72r60XL5vuc5SNj0qDH42F3nVPz gIptAkRUKGdqgw3PiBcpDr+a4WcI1l5e0UsHu/sRp7v70fFIUkyV16Jo1EEoNDvO72Y0 2umQ== X-Gm-Message-State: AOUpUlF/NpGKtpt989h2FN5NLsFtH9ufJCSe/xV7wxWWxGcrsvjYjpPR ymEhWWAtPg7NMuazGyZ4bsEIMw== X-Google-Smtp-Source: AAOMgpe7blpd2q7dMl90Nq33muDbHNFHtFRBBoyPyCVyfD0suLGyRRdTlWnChY6ATGjmLJM/FL10rQ== X-Received: by 2002:a1c:dacb:: with SMTP id r194-v6mr215387wmg.56.1533053017260; Tue, 31 Jul 2018 09:03:37 -0700 (PDT) Received: from mcroce-redhat.redhat.com (host5-113-dynamic.33-79-r.retail.telecomitalia.it. [79.33.113.5]) by smtp.gmail.com with ESMTPSA id x129-v6sm3968884wme.11.2018.07.31.09.03.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Jul 2018 09:03:36 -0700 (PDT) From: Matteo Croce To: Wensong Zhang , Simon Horman , Julian Anastasov , lvs-devel@vger.kernel.org, netdev@vger.kernel.org, Jozsef Kadlecsik Cc: Pablo Neira Ayuso , Florian Westphal , netfilter-devel@vger.kernel.org, Eric Dumazet Subject: [PATCH net v2 1/2] jiffies: add utility function to calculate delta in ms Date: Tue, 31 Jul 2018 18:03:32 +0200 Message-Id: <20180731160333.12215-2-mcroce@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180731160333.12215-1-mcroce@redhat.com> References: <20180731160333.12215-1-mcroce@redhat.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org add jiffies_delta_to_msecs() helper func to calculate the delta between two times and eventually 0 if negative. Suggested-by: Eric Dumazet Signed-off-by: Matteo Croce Reviewed-by: Eric Dumazet --- include/linux/jiffies.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index a27cf6652327..fa928242567d 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h @@ -447,6 +447,11 @@ static inline clock_t jiffies_delta_to_clock_t(long delta) return jiffies_to_clock_t(max(0L, delta)); } +static inline unsigned int jiffies_delta_to_msecs(long delta) +{ + return jiffies_to_msecs(max(0L, delta)); +} + extern unsigned long clock_t_to_jiffies(unsigned long x); extern u64 jiffies_64_to_clock_t(u64 x); extern u64 nsec_to_clock_t(u64 x);