Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964885AbcKOOuW (ORCPT ); Tue, 15 Nov 2016 09:50:22 -0500 Received: from mail-by2nam01on0087.outbound.protection.outlook.com ([104.47.34.87]:12608 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751678AbcKOOuV (ORCPT ); Tue, 15 Nov 2016 09:50:21 -0500 From: Bart Van Assche To: "jthumshirn@suse.de" CC: "jejb@linux.vnet.ibm.com" , "hch@infradead.org" , "linux-kernel@vger.kernel.org" , "hare@suse.de" , "martin.petersen@oracle.com" , "linux-scsi@vger.kernel.org" , "arnd@arndb.de" Subject: Re: [PATCH] libfc: fix seconds_since_last_reset miscalculation Thread-Topic: [PATCH] libfc: fix seconds_since_last_reset miscalculation Thread-Index: AQHSOZxoB4rqxR59R0+2RX5K3eLbraDZz0gAgABcpYA= Date: Tue, 15 Nov 2016 14:50:17 +0000 Message-ID: <1479221415.3426.3.camel@sandisk.com> References: <1478594694-98847-1-git-send-email-jthumshirn@suse.de> <20161115091840.7cldqui4dpi7nrz5@linux-x5ow.site> In-Reply-To: <20161115091840.7cldqui4dpi7nrz5@linux-x5ow.site> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@sandisk.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [24.7.116.167] x-microsoft-exchange-diagnostics: 1;BLUPR02MB1681;7:LFOgt7Qr9rccZWkfeoWJTijL6vHDQLt5a6/Zzs87AtOAWV5UjKieVwokVXC1qWtSAFS0dMBe7zn3hyXvpCNj+QBEFYIefAamMrzAta2fKJJwrJ6xdv/hXnR3XcmM1xvZLv3qyQbwMFf4+tSXDq/G40gdI8c4pkdbtiFzhVPp8Ar2CTPCNqPjQTq54n5K+kpgI2U0R0aRoBrLkBHDaKtpJo4TaeLMA4gxt4wY8QkZqOTTdkno9RwduisU1wFDiyPWsArYgK9oiOKgk/xhnaeRHjdc30tCA/Gy0rR3uQsP/Q6k7By2MF2OB95p0W6arTt0IJ9G2E0scElDRD9H9Rc+XRz5dILOFvicNSCqoxs7NR0=;20:Zg9Ek5B+TERyu1KgbSkq/NWeeu5Zv3vDxHy3frdWJjzdVkrazDwbKMA6EJzZOzfFxFqgE2eybPO+dXBFVJ39w/Z2BLn5sZ4Cv4e0f/nRjGkBwm3Uw8dKyI+eIcIQaU375dwjmi3XivwEz9p0aAabKM20wIVn70JQixpa22U2p0clI/71sTRjeOvWUS4KfRdducL+Grsb4qtHeg2/oApm3xhWqFhzYKpX7t9q7DU+fjDsLho3aAWWSSsGGiTOX7qx x-ms-office365-filtering-correlation-id: 4488f3ab-3f4e-4e9d-e92d-08d40d66b77d x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BLUPR02MB1681; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6060326)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6061324);SRVR:BLUPR02MB1681;BCL:0;PCL:0;RULEID:;SRVR:BLUPR02MB1681; x-forefront-prvs: 012792EC17 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(189002)(377424004)(24454002)(199003)(66066001)(229853002)(305945005)(106356001)(77096005)(2351001)(105586002)(33646002)(2501003)(8676002)(4001150100001)(110136003)(6916009)(189998001)(7736002)(1730700003)(7846002)(97736004)(122556002)(2950100002)(81156014)(81166006)(5660300001)(106116001)(6116002)(102836003)(86362001)(3846002)(8936002)(87936001)(92566002)(5640700001)(103116003)(36756003)(4326007)(2900100001)(2906002)(68736007)(3660700001)(76176999)(54356999)(99286002)(50986999)(3280700002)(101416001);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR02MB1681;H:BLUPR02MB1683.namprd02.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Nov 2016 14:50:17.8747 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR02MB1681 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id uAFEoWxg028611 Content-Length: 874 Lines: 23 On Tue, 2016-11-15 at 10:18 +0100, Johannes Thumshirn wrote: > On Tue, Nov 08, 2016 at 03:04:43PM +0000, Bart Van Assche wrote: > > I think the above code will miscalculate seconds_since_last_reset > > if  > > 'jiffies' wraps around after an lport has been created and before  > > seconds_since_last_reset is computed. Shouldn't > > seconds_since_last_reset  > > be computed as follows? > > > > fc_stats->seconds_since_last_reset = (jiffies - boot_time) / > > HZ; > > But what happens when jiffies - boot_time becomes negative? Then we > reintroduce the bug again and have 'fcoeadm -s' show weird values. Hello Johannes, If your concern is about 'jiffies' wrapping around on 32-bit systems then you should use get_jiffies_64(). get_jiffies_64() - boot_time can't become negative. It namely takes several million years before a 64-bit HZ counter wraps around. Bart.