From: Pratyush Yadav <pratyush@kernel.org>
To: "Michael Walle" <mwalle@kernel.org>
Cc: "Pratyush Yadav" <pratyush@kernel.org>,
"Tudor Ambarus" <tudor.ambarus@linaro.org>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Dan Carpenter" <dan.carpenter@linaro.org>,
<linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mtd: spi-nor: replace unnecessary div64_u64() with div_u64()
Date: Mon, 29 Apr 2024 16:42:30 +0200 [thread overview]
Message-ID: <mafs0mspcb57t.fsf@kernel.org> (raw)
In-Reply-To: <D0WNIVK1DBL5.3KQOD1K2O128P@kernel.org> (Michael Walle's message of "Mon, 29 Apr 2024 15:47:13 +0200")
On Mon, Apr 29 2024, Michael Walle wrote:
> Hi,
>
> On Mon Apr 29, 2024 at 3:27 PM CEST, Pratyush Yadav wrote:
>> On Mon, Apr 29 2024, Michael Walle wrote:
>>
>> > Both occurences of div64_u64() just have a u8 or u32 divisor. Use
>> > div_u64() instead.
>>
>> Does this improve performance or is this only for correctness?
>
> See function doc for div_u64():
>
> * This is the most common 64bit divide and should be used if possible,
> * as many 32bit archs can optimize this variant better than a full 64bit
> * divide.
Thanks. I think it would be good to add this to the commit message:
Both occurences of div64_u64() just have a u8 or u32 divisor. Use
div_u64() instead. Many 32 bit architectures can optimize this
variant better than a full 64 bit divide.
No need to resend, I can do this when applying.
>
>> Patch LGTM otherwise.
>>
>> Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
>>
>> BTW, I also noticed that there is a do_div() call in spi_nor_write()
>> that also uses a u64 dividend and u32 divisor. I was wondering why it
>> uses do_div() and not div_u64() (I am not sure what the difference
>> between the two is) but I suppose it doesn't matter much since your
>> spring cleaning series will delete that code anyway.
>
> do_div() is a macro and is modifying the dividend in place, whereas
> div_u64() will return it. do_div() is using u32 for the divisor
> anyway.
>
> -michael
>
--
Regards,
Pratyush Yadav
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: Pratyush Yadav <pratyush@kernel.org>
To: "Michael Walle" <mwalle@kernel.org>
Cc: "Pratyush Yadav" <pratyush@kernel.org>,
"Tudor Ambarus" <tudor.ambarus@linaro.org>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Dan Carpenter" <dan.carpenter@linaro.org>,
<linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mtd: spi-nor: replace unnecessary div64_u64() with div_u64()
Date: Mon, 29 Apr 2024 16:42:30 +0200 [thread overview]
Message-ID: <mafs0mspcb57t.fsf@kernel.org> (raw)
In-Reply-To: <D0WNIVK1DBL5.3KQOD1K2O128P@kernel.org> (Michael Walle's message of "Mon, 29 Apr 2024 15:47:13 +0200")
On Mon, Apr 29 2024, Michael Walle wrote:
> Hi,
>
> On Mon Apr 29, 2024 at 3:27 PM CEST, Pratyush Yadav wrote:
>> On Mon, Apr 29 2024, Michael Walle wrote:
>>
>> > Both occurences of div64_u64() just have a u8 or u32 divisor. Use
>> > div_u64() instead.
>>
>> Does this improve performance or is this only for correctness?
>
> See function doc for div_u64():
>
> * This is the most common 64bit divide and should be used if possible,
> * as many 32bit archs can optimize this variant better than a full 64bit
> * divide.
Thanks. I think it would be good to add this to the commit message:
Both occurences of div64_u64() just have a u8 or u32 divisor. Use
div_u64() instead. Many 32 bit architectures can optimize this
variant better than a full 64 bit divide.
No need to resend, I can do this when applying.
>
>> Patch LGTM otherwise.
>>
>> Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
>>
>> BTW, I also noticed that there is a do_div() call in spi_nor_write()
>> that also uses a u64 dividend and u32 divisor. I was wondering why it
>> uses do_div() and not div_u64() (I am not sure what the difference
>> between the two is) but I suppose it doesn't matter much since your
>> spring cleaning series will delete that code anyway.
>
> do_div() is a macro and is modifying the dividend in place, whereas
> div_u64() will return it. do_div() is using u32 for the divisor
> anyway.
>
> -michael
>
--
Regards,
Pratyush Yadav
next prev parent reply other threads:[~2024-04-29 14:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 12:11 [PATCH] mtd: spi-nor: replace unnecessary div64_u64() with div_u64() Michael Walle
2024-04-29 12:11 ` Michael Walle
2024-04-29 13:27 ` Pratyush Yadav
2024-04-29 13:27 ` Pratyush Yadav
2024-04-29 13:47 ` Michael Walle
2024-04-29 13:47 ` Michael Walle
2024-04-29 14:42 ` Pratyush Yadav [this message]
2024-04-29 14:42 ` Pratyush Yadav
2024-04-30 15:45 ` Pratyush Yadav
2024-04-30 15:45 ` Pratyush Yadav
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mafs0mspcb57t.fsf@kernel.org \
--to=pratyush@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=mwalle@kernel.org \
--cc=richard@nod.at \
--cc=tudor.ambarus@linaro.org \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.