Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp3961555pjo; Tue, 3 Mar 2020 10:08:42 -0800 (PST) X-Google-Smtp-Source: ADFU+vuvjEJt67DC/1kpNgOLMGkJ+/L58a7nzpNbVOPcgL9pfSlPD/vsg0YKcP31rtkeoqJ+gl1J X-Received: by 2002:aca:4b57:: with SMTP id y84mr3400106oia.16.1583258922313; Tue, 03 Mar 2020 10:08:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583258922; cv=none; d=google.com; s=arc-20160816; b=I1IuT/MaZM5L4nKNLxuCDgsdrQkdcX1b7vztTAoKdVaWajT0Xa4sswGgAEhg0DPPqH /IIbAu+fLSlZnTVlQmy5yAjXP5xVyA+GN3nDFGji41I/exw1So/alqb/S6+DE45CiEap z5YYxunwGyTO7lZBBVc75BBDBWb+2Agn4X4rfNsTD1RhGa0F6mwngrpCPyDaPHkshGrm jXLv83PvSrpX+4l+nY7k3EIHkhq7/xM9t6D+NfJ2DLKFALUXCyiADXbrUNcM6W1ZieLm xiWZ14mrxTn/6NSpG8sDXeN9O4BEqObg5zV37MMT0BoSduTao9/NA45SApnsPBXKC3ys Nniw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZuZQngI0iTMYiKcJeOr5hqFjw+7VO4qJPWwGtBQp+MU=; b=RGEzPPk43FynbIeJT/NUqEDtnSmBYoQ7DK194+ZxAjAzbRbE6iKJtDLV7f5fIqRbGY vtb/OY5sMZ622+0C5F4msh77sp1dSn79MFGXmOzaMEIqVyav1hR3/IAi2c6nbhCzWDWJ 5D4b6ZScP2rpnFMmnQBwaHWir7+/XluKcwBIByIm3AUUfuyOBr/yxnWf8p3dufAYlnMx fyXy2sSJaFuKNnLTpLtBMoTAxdfwzGis6lMd04YZ3Ma3f+jpYHSG1QiYW1YMuDu2nMyq OJCisdJz/v7PsDDY+TYwTEAKMe/liB9WlQU1YIvSxDLBPpAHRoa5TAHN+kva+ISyIjse y6Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U1E0sPnY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si5716025otk.137.2020.03.03.10.08.30; Tue, 03 Mar 2020 10:08:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U1E0sPnY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732514AbgCCRy0 (ORCPT + 99 others); Tue, 3 Mar 2020 12:54:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:35520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732314AbgCCRyZ (ORCPT ); Tue, 3 Mar 2020 12:54:25 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3DF19206D5; Tue, 3 Mar 2020 17:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583258064; bh=2k1Uh2+g4UIU3FTUqMeqDDj6AHc8elwxBX5WMs5PIzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U1E0sPnY2VXvnV78tbciVvjkXWYDgiQWT/+efjT0UmUm77n4ESAuiV4+cd1nm43FK 207bOXacfQRoodMvsNxBmOIHxvZwmQaBPTX5idFTKSdgyKGHwL3bjuSzCTonNeGcEN 7g/50gBAv+8fnQOehDG3GNow/PVuDX1ffBoD8RwY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arthur Kiyanovski , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 050/152] net: ena: fix uses of round_jiffies() Date: Tue, 3 Mar 2020 18:42:28 +0100 Message-Id: <20200303174308.103154883@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200303174302.523080016@linuxfoundation.org> References: <20200303174302.523080016@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arthur Kiyanovski [ Upstream commit 2a6e5fa2f4c25b66c763428a3e65363214946931 ] >From the documentation of round_jiffies(): "Rounds a time delta in the future (in jiffies) up or down to (approximately) full seconds. This is useful for timers for which the exact time they fire does not matter too much, as long as they fire approximately every X seconds. By rounding these timers to whole seconds, all such timers will fire at the same time, rather than at various times spread out. The goal of this is to have the CPU wake up less, which saves power." There are 2 parts to this patch: ================================ Part 1: ------- In our case we need timer_service to be called approximately every X=1 seconds, and the exact time does not matter, so using round_jiffies() is the right way to go. Therefore we add round_jiffies() to the mod_timer() in ena_timer_service(). Part 2: ------- round_jiffies() is used in check_for_missing_keep_alive() when getting the jiffies of the expiration of the keep_alive timeout. Here it is actually a mistake to use round_jiffies() because we want the exact time when keep_alive should expire and not an approximate rounded time, which can cause early, false positive, timeouts. Therefore we remove round_jiffies() in the calculation of keep_alive_expired() in check_for_missing_keep_alive(). Fixes: 82ef30f13be0 ("net: ena: add hardware hints capability to the driver") Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)") Signed-off-by: Arthur Kiyanovski Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/amazon/ena/ena_netdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index b4a145220abae..f0cddf250cfd5 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -3035,8 +3035,8 @@ static void check_for_missing_keep_alive(struct ena_adapter *adapter) if (adapter->keep_alive_timeout == ENA_HW_HINTS_NO_TIMEOUT) return; - keep_alive_expired = round_jiffies(adapter->last_keep_alive_jiffies + - adapter->keep_alive_timeout); + keep_alive_expired = adapter->last_keep_alive_jiffies + + adapter->keep_alive_timeout; if (unlikely(time_is_before_jiffies(keep_alive_expired))) { netif_err(adapter, drv, adapter->netdev, "Keep alive watchdog timeout.\n"); @@ -3138,7 +3138,7 @@ static void ena_timer_service(struct timer_list *t) } /* Reset the timer */ - mod_timer(&adapter->timer_service, jiffies + HZ); + mod_timer(&adapter->timer_service, round_jiffies(jiffies + HZ)); } static int ena_calc_io_queue_num(struct pci_dev *pdev, -- 2.20.1