From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755609AbcFQPJh (ORCPT ); Fri, 17 Jun 2016 11:09:37 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:35854 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751690AbcFQPJe (ORCPT ); Fri, 17 Jun 2016 11:09:34 -0400 MIME-Version: 1.0 In-Reply-To: <20160615152816.2800830-2-arnd@arndb.de> References: <20160615152816.2800830-1-arnd@arndb.de> <20160615152816.2800830-2-arnd@arndb.de> From: Saeed Mahameed Date: Fri, 17 Jun 2016 18:09:00 +0300 Message-ID: Subject: Re: [PATCH 2/2] mlx5: fix 64-bit division on times To: Arnd Bergmann Cc: Matan Barak , Leon Romanovsky , Saeed Mahameed , "David S. Miller" , Achiad Shochat , Tariq Toukan , Gal Pressman , Maor Gottlieb , Huy Nguyen , Linux Netdev List , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 15, 2016 at 6:27 PM, Arnd Bergmann wrote: > The mlx5 driver fails to build on 32-bit architectures after some > references to 64-bit divisions got added: > > drivers/net/built-in.o: In function `mlx5e_rx_am': > :(.text+0xf88ac): undefined reference to `__aeabi_ldivmod' > > The driver even performs three division here, and it uses the > obsolete 'struct timespec' that we want to get rid of. > > Using ktime_t and ktime_us_delta() replaces one of the divisions > and is mildly more efficient, aside from working across 'settimeofday' > calls and being the right type for the y2038 conversion. > > Using a u32 instead of s64 to store the number of microseconds > limits the maximum time to about 71 minutes, but if we exceed that > time, we probably don't care about the result any more for the > purpose of rx coalescing. > > For the number of packets, we are taking the difference between > two 'unsigned int', so the result won't ever be greater than that > either. > > After those changes, the other two divisions are done as 32-bit > arithmetic operations, which are much faster. Nice catch Arnd, we originally fixed this with div_u64, but your solution looks wiser. does ktime_t gives time in a resolution same as timespec ? As discussed before this patch can't be applied on net-next as the original patch which it meant to fix is yet to be submitted, I will CC you once we submit the fixed patch.