From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2E94C43381 for ; Mon, 25 Feb 2019 16:48:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B79FE20842 for ; Mon, 25 Feb 2019 16:48:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728459AbfBYQsA (ORCPT ); Mon, 25 Feb 2019 11:48:00 -0500 Received: from mga01.intel.com ([192.55.52.88]:14175 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728076AbfBYQsA (ORCPT ); Mon, 25 Feb 2019 11:48:00 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Feb 2019 08:47:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,411,1544515200"; d="scan'208";a="120656164" Received: from jbrandeb-mobl2.amr.corp.intel.com (HELO localhost) ([10.252.135.102]) by orsmga008.jf.intel.com with ESMTP; 25 Feb 2019 08:47:59 -0800 Date: Mon, 25 Feb 2019 08:47:59 -0800 From: Jesse Brandeburg To: Arnd Bergmann Cc: Jeff Kirsher , David Miller , Networking , , , , jacob.e.keller@intel.com Subject: Re: [net-next 05/14] i40e: fix up 32 bit timespec references Message-ID: <20190225084759.00004795@intel.com> In-Reply-To: References: <20170726103123.76743-1-jeffrey.t.kirsher@intel.com> <20170726103123.76743-6-jeffrey.t.kirsher@intel.com> X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, 25 Feb 2019 15:46:18 +0100 Arnd Bergmann wrote: > I just stumbled over code added by this older patch, and can't make sense > of the commit description here. Was this an attempt to fix a bug, or > just a cleanup? Thanks Arnd for mentioning/posting this! This was an attempt at a clean up, unfortunately I made a mistake which introduced a bug. > > - then = ns_to_timespec64(delta); > > mutex_lock(&pf->tmreg_lock); > > > > i40e_ptp_read(pf, &now); > > - now = timespec64_add(now, then); > > + timespec64_add_ns(&now, delta); > > i40e_ptp_write(pf, (const struct timespec64 *)&now); > > The problem I noticed here is that 'delta' is a user provided 64-bit > number from clock_adjtime(), and timespec64_add_ns() performs uses > a repeated addition instead of a div/mod pair. When the number > is large, we may end up adding a single second 8 billion times, > which may take a while even on a fast CPU. > > Should the commit 0ac30ce43323 ("i40e: fix up 32 bit timespec > references") just be reverted? Interestingly, we just were discussing this fix this past Friday, and have a patch internally to fix the issue correctly. Either way it is a commit (revert or fix) so we might as well just send the fix ASAP. Our team should have something posted to intel-wired-lan/netdev shortly, and we'll get the patch officially to netdev after a brief test.