Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753085AbcD1RW6 (ORCPT ); Thu, 28 Apr 2016 13:22:58 -0400 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:60770 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752159AbcD1RWy (ORCPT ); Thu, 28 Apr 2016 13:22:54 -0400 Message-ID: <1461864170.2307.19.camel@HansenPartnership.com> Subject: Re: [patch V3] lib: GCD: add binary GCD algorithm From: James Bottomley To: zengzhaoxiu@163.com, akpm@linux-foundation.org, linux@horizon.com, peterz@infradead.org Cc: Zhaoxiu Zeng , Richard Henderson , Ivan Kokshaysky , Matt Turner , Russell King , Yoshinori Sato , Geert Uytterhoeven , James Hogan , Michal Simek , Ralf Baechle , Ley Foon Tan , Jonas Bonn , "James E.J. Bottomley" , Helge Deller , Chen Liqin , Lennox Wu , Rich Felker , "David S. Miller" , linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@vger.kernel.org, linux-metag@vger.kernel.org, linux-mips@linux-mips.org, nios2-dev@lists.rocketboards.org, linux@lists.openrisc.net, linux-parisc@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org Date: Thu, 28 Apr 2016 10:22:50 -0700 In-Reply-To: <1461843824-19853-1-git-send-email-zengzhaoxiu@163.com> References: <1461843824-19853-1-git-send-email-zengzhaoxiu@163.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.5 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 735 Lines: 19 On Thu, 2016-04-28 at 19:43 +0800, zengzhaoxiu@163.com wrote: > From: Zhaoxiu Zeng > > Because some architectures (alpha, armv6, etc.) don't provide > hardware division, the mod operation is slow! Binary GCD algorithm > uses simple arithmetic operations, it replaces division with > arithmetic shifts, comparisons, and subtractions. > > I have compiled successfully with x86_64_defconfig and > i386_defconfig. What's the reason for wanting to optimize this and thus have to maintain (and test) two separate code paths, which is a significant expense? As far as I can see, gcd() is mosly used in finding optimal clocks for operations, which is usually done at start of day and not time critical. James