[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <21cd0f32-c94b-4b2b-8fa6-ebe12756b0c4@app.fastmail.com>
Date: Wed, 13 Mar 2024 14:39:01 +0100
From: "Arnd Bergmann" <arnd@...nel.org>
To: "Zhihao Cheng" <chengzhihao1@...wei.com>, "Arnd Bergmann" <arnd@...db.de>,
"Richard Weinberger" <richard@....at>,
"Miquel Raynal" <miquel.raynal@...tlin.com>,
"Vignesh Raghavendra" <vigneshr@...com>,
"Daniel Golle" <daniel@...rotopia.org>
Cc: linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mtd: ubi: avoid expensive do_div() on 32-bit machines
On Wed, Mar 13, 2024, at 14:29, Zhihao Cheng wrote:
> 在 2024/3/13 20:21, Arnd Bergmann 写道:
>> On Wed, Mar 13, 2024, at 13:10, Zhihao Cheng wrote:
>>> 在 2024/3/13 19:53, Arnd Bergmann 写道:
>>>> On Wed, Mar 13, 2024, at 12:29, Zhihao Cheng wrote:
>>>>
>>>> The way it usually goes is that someone adds an open-coded
>>>> 64-bit division that causes a link failure, which prompts
>>> I'm a little confused, what kind of link failure? Could you show an example?
>>
>> The open-coded 64-bit division without using do_div() shows up as
>>
>> x86_64-linux-ld: drivers/mtd/ubi/nvmem.o: in function `ubi_nvmem_reg_read':
>> nvmem.c:(.text+0x10a): undefined reference to `__umoddi3'
>> x86_64-linux-ld: nvmem.c:(.text+0x11f): undefined reference to `__udivdi3'
>> x86_64-linux-ld: drivers/mtd/ubi/nvmem.o: in function `ubi_nvmem_reg_read.cold':
>> nvmem.c:(.text.unlikely+0x2d): undefined reference to `__umoddi3'
>> > The idea is that gcc expects __umoddi3 to be provided by libgcc,
>> but Linux intentionally leaves it out in order to catch accidental
>> 64-bit divisions.
>>
>
> Thanks for explaination, which means that do_div is used for 64-bit
> division to solve the link failure caused by missed libgcc. Since
> parameter 'from' is u32, there is no need to invoke do_div on a 32-bit
> platform, you just want to stop the wasting behavior on a 32-bit
> platform. Do I understand right?
Yes, correct.
Arnd
Powered by blists - more mailing lists