From patchwork Fri Jun 17 15:47:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102151 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp349089qgy; Fri, 17 Jun 2016 08:46:30 -0700 (PDT) X-Received: by 10.107.182.139 with SMTP id g133mr4374612iof.27.1466178389983; Fri, 17 Jun 2016 08:46:29 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2si15339838pas.175.2016.06.17.08.46.29; Fri, 17 Jun 2016 08:46:29 -0700 (PDT) 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; 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 S933704AbcFQPqQ (ORCPT + 30 others); Fri, 17 Jun 2016 11:46:16 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:50493 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161256AbcFQPqL (ORCPT ); Fri, 17 Jun 2016 11:46:11 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue002) with ESMTPA (Nemesis) id 0MHQA7-1bANBt26Tb-00E6Ms; Fri, 17 Jun 2016 17:45:50 +0200 From: Arnd Bergmann To: Vasu Dev , "James E.J. Bottomley" , "Martin K. Petersen" Cc: y2038@lists.linaro.org, Arnd Bergmann , fcoe-devel@open-fcoe.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: libfc: fix seconds_since_last_reset calculation Date: Fri, 17 Jun 2016 17:47:25 +0200 Message-Id: <20160617154737.633440-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:Ef6Y2wK0S0+0KjiX34aHy+QDBNfuXIoAuwlruswh6qaWk+x9xbv U959skU477M9wA+md7mSBYr2qm/DrRW5SLS9AxU637O3pDnE1wNmFwrZ1FT8HxFJOJMRxsM F0SFmgXZQa7dGWdWDLbWtUprD5wjT9XMtZ2EqkCb9GqgomQXGe7hJel1PeNEWMOLGZblFW0 qZvBF3+j2sguPXuMnzQMQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:+85NUI5aYHk=:thevxnNADDQTO1CR/jDMXZ bYx8G3LJqBuQVVOt3KfEh3vgH2spt6Vh73niqTfEe+EB5XvmVVU6kBJ/KjWWbHcwu+tcq4Y+L zBV4AL43PqzobnSqzJ3nmOPAjSeD4Lvux7K5Q61oyKgLgtlzlLwgM621yFaNVuheLAeBhDQ/o y9gIK91pnLgPDiC1WCBfFTHhOIbDXEsSzABZKxz8d/kERuJ/8HCiFzO/0HqSo1cdM2MR1+iVL BOHckvVIuwYGy3zTjoKAQWVs1dG0DIjq4ZD15G7GQCGf4Afop5fE+AiRNcl69eDAa+IB2lTtz qkyiiuruWaLpxQdl40euP6RT60NxiNh3XJFVZ5yCNltba15Gh4Jl/fUdo4TkRvrTccdUXdQjP t1E0cmnVMn0uWncYPLYt/PElUaPC6Wt6uVckiHTzw5X5gH9jyUFcI8vVVytQx6MAl4EAwwmku uezqOJqnFFUKpUEwOYku/9WFcyj/wp920+mMUvyKz0Aqa+8PoZ0afvJ43YavaHTDHWnVx235Z NDNbwnoce127KqAjG28sX1XmDKqSWrReIJp5qCBbPyBnMAcGCpFNbegI3MrsFVPSt7AUUWb5v yOK2O8P/BzPOXPLMorIAhg2fBr6RhrvcDhMUjvMl2ODoP3qU+QB/ikj37Y4E4wfHYzPYi+qm1 CUvfi0MP03nM3Pdv17aN8Z0tPADIPwiR1wGtLxEhdlXosaOGCVm5Qi4EMkZhkjzfRQdol4Cav yGuMIi3BJfnkLhOZ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The fc_get_host_stats() function contains a complex conversion from jiffies to timespec to seconds. As we try to get rid of uses of struct timespec, we can clean this up and replace it with a simpler computation. Simply dividing the difference in jiffies by HZ is not only much more efficient, it also avoids a problem that causes the seconds_since_last_reset value to be incorrect if jiffies has overrun since the 'boot_time' value was recorded. Signed-off-by: Arnd Bergmann --- drivers/scsi/libfc/fc_lport.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) -- 2.9.0 diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index e01a29863c38..99c6d9251404 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c @@ -301,7 +301,6 @@ struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost) { struct fc_host_statistics *fc_stats; struct fc_lport *lport = shost_priv(shost); - struct timespec v0, v1; unsigned int cpu; u64 fcp_in_bytes = 0; u64 fcp_out_bytes = 0; @@ -309,9 +308,7 @@ struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost) fc_stats = &lport->host_stats; memset(fc_stats, 0, sizeof(struct fc_host_statistics)); - jiffies_to_timespec(jiffies, &v0); - jiffies_to_timespec(lport->boot_time, &v1); - fc_stats->seconds_since_last_reset = (v0.tv_sec - v1.tv_sec); + fc_stats->seconds_since_last_reset = (lport->boot_time - jiffies) / HZ; for_each_possible_cpu(cpu) { struct fc_stats *stats;