lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <e0684202-6926-4bd1-86f6-2bb682524712@app.fastmail.com>
Date: Wed, 13 Mar 2024 12:53:08 +0100
From: "Arnd Bergmann" <arnd@...db.de>
To: "Zhihao Cheng" <chengzhihao1@...wei.com>,
 "Arnd Bergmann" <arnd@...nel.org>, "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 12:29, Zhihao Cheng wrote:
> 在 2024/3/13 16:46, Arnd Bergmann 写道:
>> From: Arnd Bergmann <arnd@...db.de>
>> 
>> The use of do_div() in ubi_nvmem_reg_read() makes calling it on
>> 32-bit machines rather expensive. Since the 'from' variable is
>> known to be a 32-bit quantity, it is clearly never needed and
>> can be optimized into a regular division operation.
>> 
> Do you meet a performance problem on a 32-bit machine? There are too 
> many places invoking do_div, why do you optimize this one?
> Have you tested the influence on a x86_64 platform after this patch 
> applied? Looks like that do_div is more efficient in x86.

This one was just introduced. The call site looks like a fast
path and it caused a build regression that Daniel addressed with
an suboptimal commit b8a77b9a5f9c ("mtd: ubi: fix NVMEM over
UBI volumes on 32-bit systems").

The way it usually goes is that someone adds an open-coded
64-bit division that causes a link failure, which prompts
the original developer to either rewrite the code to avoid
the long division if possible, or add do_div() after showing
that it is now performance critical, e.g. only called at
probe time.

     Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ