From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751527AbbHLWU7 (ORCPT ); Wed, 12 Aug 2015 18:20:59 -0400 Received: from mail.kernel.org ([198.145.29.136]:52283 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750811AbbHLWU5 (ORCPT ); Wed, 12 Aug 2015 18:20:57 -0400 Subject: Re: enabling libgcc for 64-bit divisions, was Re: PROBLEM: XFS on ARM corruption 'Structure needs cleaning' To: Linus Torvalds , Christoph Hellwig References: <5579B804.9050707@skylable.com> <20150612122108.GB60661@bfoster.bfoster> <557AD4D4.3010901@skylable.com> <20150612225209.GA20262@dastard> <20150812062445.GA4520@infradead.org> Cc: katsuki.uwatoko@toshiba.co.jp, "linux-arm-kernel@lists.infradead.org" , Dave Chinner , gangchen@rdamicro.com, Russell King - ARM Linux , karanvir.singh@hgst.com, luca@skylable.com, christopher.squires@hgst.com, edwin@skylable.com, wayne.burri@hgst.com, Linux Kernel Mailing List From: Andy Lutomirski Message-ID: <55CBC6C6.3090306@kernel.org> Date: Wed, 12 Aug 2015 15:20:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/12/2015 08:49 AM, Linus Torvalds wrote: > On Tue, Aug 11, 2015 at 11:24 PM, Christoph Hellwig wrote: >> >> Maybe it's time to rely on gcc to handle 64 bit divisions now? > > Ugh. gcc still does a pretty horrible job at it. While gcc knows that > a widening 32x32->64 multiplication can be simplified, it doesn't do > the same thing for a 64/32->64 division, and always calls __udivdi3 > for it. > > Now, __udivdi3 does avoid the general nasty case by then testing the > upper 32 bits of the divisor against zero, so it's not entirely > disastrous. It's just ugly. > > But perhaps more importantly, I'm not at all sure libgcc is > kernel-safe. In particular, I'm not at all sure it *remains* > kernel-safe. Just as an example: can you guarantee that libgcc doesn't > implement integer division on some architecture by using the FP > hardware? > > There's been a few cases where not having libgcc saved us headaches. I > forget the exact details, but it was something like several years ago > that we had gcc start to generate some insane crap exception handling > for C code generation, and the fact that we didn't include libgcc was > what made us catch it because of the resulting link error. > > libgcc just isn't reliable in kernel space. I'm not opposed to some > random architecture using it (arch/tile does include "-lgcc" for > example), but I _do_ object to the notion that we say "let's use > libgcc in general". > > So no. I do not believe that the occasional pain of a few people who > do 64-bit divides incorrectly is a good enough argument to start using > libgcc. > Does your objection still apply if we supplied our own implementations of a handful of libgcc helpers? --Andy > Linus >