* [PATCH V2] xfs: use roundup_pow_of_two instead of ffs during xlog_find_tail
[not found] <63b3742c-0efe-c096-c737-a0e0419480bd@outlook.com>
@ 2023-09-12 7:20 ` Wang Jianchao
2023-09-12 22:44 ` Dave Chinner
[not found] ` <59dd15dd-5b35-871d-6d3a-ec779975b089@outlook.com>
1 sibling, 1 reply; 7+ messages in thread
From: Wang Jianchao @ 2023-09-12 7:20 UTC (permalink / raw)
To: djwong; +Cc: linux-xfs, linux-kernel
In our production environment, we find that mounting a 500M /boot
which is umount cleanly needs ~6s. One cause is that ffs() is
used by xlog_write_log_records() to decide the buffer size. It
can cause a lot of small IO easily when xlog_clear_stale_blocks()
needs to wrap around the end of log area and log head block is
not power of two. Things are similar in xlog_find_verify_cycle().
The code is able to handed bigger buffer very well, we can use
roundup_pow_of_two() to replace ffs() directly to avoid small
and sychronous IOs.
Changes in V1:
- Also replace the ffs in xlog_find_verify_cycle()
Signed-off-by: Wang Jianchao <wangjc136@midea.com>
---
fs/xfs/xfs_log_recover.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 82c81d20459d..13b94d2e605b 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -329,7 +329,7 @@ xlog_find_verify_cycle(
* try a smaller size. We need to be able to read at least
* a log sector, or we're out of luck.
*/
- bufblks = 1 << ffs(nbblks);
+ bufblks = roundup_pow_of_two(nbblks);
while (bufblks > log->l_logBBsize)
bufblks >>= 1;
while (!(buffer = xlog_alloc_buffer(log, bufblks))) {
@@ -1528,7 +1528,7 @@ xlog_write_log_records(
* a smaller size. We need to be able to write at least a
* log sector, or we're out of luck.
*/
- bufblks = 1 << ffs(blocks);
+ bufblks = roundup_pow_of_two(blocks);
while (bufblks > log->l_logBBsize)
bufblks >>= 1;
while (!(buffer = xlog_alloc_buffer(log, bufblks))) {
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH V2] xfs: use roundup_pow_of_two instead of ffs during xlog_find_tail
2023-09-12 7:20 ` [PATCH V2] xfs: use roundup_pow_of_two instead of ffs during xlog_find_tail Wang Jianchao
@ 2023-09-12 22:44 ` Dave Chinner
2023-09-13 1:33 ` Wang Jianchao
0 siblings, 1 reply; 7+ messages in thread
From: Dave Chinner @ 2023-09-12 22:44 UTC (permalink / raw)
To: Wang Jianchao; +Cc: djwong, linux-xfs, linux-kernel
On Tue, Sep 12, 2023 at 03:20:56PM +0800, Wang Jianchao wrote:
>
> In our production environment, we find that mounting a 500M /boot
> which is umount cleanly needs ~6s. One cause is that ffs() is
> used by xlog_write_log_records() to decide the buffer size. It
> can cause a lot of small IO easily when xlog_clear_stale_blocks()
> needs to wrap around the end of log area and log head block is
> not power of two. Things are similar in xlog_find_verify_cycle().
>
> The code is able to handed bigger buffer very well, we can use
> roundup_pow_of_two() to replace ffs() directly to avoid small
> and sychronous IOs.
>
> Changes in V1:
> - Also replace the ffs in xlog_find_verify_cycle()
Change logs go either below the --- line or in the cover letter,
not the commit itself.
Other than that, the change looks ok. The use of ffs() was added in
2002 simply to make buffers a power-of-2 size. I don't think it had
anything to do with trying to maximise the actual buffer size at
all, otherwise it would have made to use fls() like
roundup_pow_of_two() does...
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2] xfs: use roundup_pow_of_two instead of ffs during xlog_find_tail
2023-09-12 22:44 ` Dave Chinner
@ 2023-09-13 1:33 ` Wang Jianchao
0 siblings, 0 replies; 7+ messages in thread
From: Wang Jianchao @ 2023-09-13 1:33 UTC (permalink / raw)
To: Dave Chinner; +Cc: djwong, linux-xfs, linux-kernel
On 2023/9/13 06:44, Dave Chinner wrote:
> On Tue, Sep 12, 2023 at 03:20:56PM +0800, Wang Jianchao wrote:
>>
>> In our production environment, we find that mounting a 500M /boot
>> which is umount cleanly needs ~6s. One cause is that ffs() is
>> used by xlog_write_log_records() to decide the buffer size. It
>> can cause a lot of small IO easily when xlog_clear_stale_blocks()
>> needs to wrap around the end of log area and log head block is
>> not power of two. Things are similar in xlog_find_verify_cycle().
>>
>> The code is able to handed bigger buffer very well, we can use
>> roundup_pow_of_two() to replace ffs() directly to avoid small
>> and sychronous IOs.
>>
>> Changes in V1:
>> - Also replace the ffs in xlog_find_verify_cycle()
>
> Change logs go either below the --- line or in the cover letter,
> not the commit itself.
OK
>
> Other than that, the change looks ok. The use of ffs() was added in
> 2002 simply to make buffers a power-of-2 size. I don't think it had
> anything to do with trying to maximise the actual buffer size at
> all, otherwise it would have made to use fls() like
> roundup_pow_of_two() does...
>
> Reviewed-by: Dave Chinner <dchinner@redhat.com>
>
Thanks
Jianchao
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V3] xfs: use roundup_pow_of_two instead of ffs during xlog_find_tail
[not found] ` <59dd15dd-5b35-871d-6d3a-ec779975b089@outlook.com>
@ 2023-09-13 1:38 ` Wang Jianchao
[not found] ` <0a72f462-8b8e-4dec-6ce4-f52e33423957@outlook.com>
1 sibling, 0 replies; 7+ messages in thread
From: Wang Jianchao @ 2023-09-13 1:38 UTC (permalink / raw)
To: djwong; +Cc: linux-xfs, linux-kernel
In our production environment, we find that mounting a 500M /boot
which is umount cleanly needs ~6s. One cause is that ffs() is
used by xlog_write_log_records() to decide the buffer size. It
can cause a lot of small IO easily when xlog_clear_stale_blocks()
needs to wrap around the end of log area and log head block is
not power of two. Things are similar in xlog_find_verify_cycle().
The code is able to handed bigger buffer very well, we can use
roundup_pow_of_two() to replace ffs() directly to avoid small
and sychronous IOs.
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Wang Jianchao <wangjc136@midea.com>
---
Changes in V2:
- Move change log below "---"
- Add reviewed-by Dave Chinner tag
Changes in V1:
- Also replace the ffs in xlog_find_verify_cycle()
fs/xfs/xfs_log_recover.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 82c81d20459d..13b94d2e605b 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -329,7 +329,7 @@ xlog_find_verify_cycle(
* try a smaller size. We need to be able to read at least
* a log sector, or we're out of luck.
*/
- bufblks = 1 << ffs(nbblks);
+ bufblks = roundup_pow_of_two(nbblks);
while (bufblks > log->l_logBBsize)
bufblks >>= 1;
while (!(buffer = xlog_alloc_buffer(log, bufblks))) {
@@ -1528,7 +1528,7 @@ xlog_write_log_records(
* a smaller size. We need to be able to write at least a
* log sector, or we're out of luck.
*/
- bufblks = 1 << ffs(blocks);
+ bufblks = roundup_pow_of_two(blocks);
while (bufblks > log->l_logBBsize)
bufblks >>= 1;
while (!(buffer = xlog_alloc_buffer(log, bufblks))) {
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH V3] xfs: use roundup_pow_of_two instead of ffs during xlog_find_tail
[not found] ` <0a72f462-8b8e-4dec-6ce4-f52e33423957@outlook.com>
@ 2023-09-19 2:06 ` Wang Jianchao
2023-09-19 3:21 ` Darrick J. Wong
0 siblings, 1 reply; 7+ messages in thread
From: Wang Jianchao @ 2023-09-19 2:06 UTC (permalink / raw)
To: djwong; +Cc: linux-xfs, linux-kernel
Ping ? Do I need other update on this patch ?
Thanks
Jianchao
On 2023/9/13 09:38, Wang Jianchao wrote:
>
> In our production environment, we find that mounting a 500M /boot
> which is umount cleanly needs ~6s. One cause is that ffs() is
> used by xlog_write_log_records() to decide the buffer size. It
> can cause a lot of small IO easily when xlog_clear_stale_blocks()
> needs to wrap around the end of log area and log head block is
> not power of two. Things are similar in xlog_find_verify_cycle().
>
> The code is able to handed bigger buffer very well, we can use
> roundup_pow_of_two() to replace ffs() directly to avoid small
> and sychronous IOs.
>
> Reviewed-by: Dave Chinner <dchinner@redhat.com>
> Signed-off-by: Wang Jianchao <wangjc136@midea.com>
> ---
>
> Changes in V2:
> - Move change log below "---"
> - Add reviewed-by Dave Chinner tag
>
> Changes in V1:
> - Also replace the ffs in xlog_find_verify_cycle()
>
> fs/xfs/xfs_log_recover.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index 82c81d20459d..13b94d2e605b 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -329,7 +329,7 @@ xlog_find_verify_cycle(
> * try a smaller size. We need to be able to read at least
> * a log sector, or we're out of luck.
> */
> - bufblks = 1 << ffs(nbblks);
> + bufblks = roundup_pow_of_two(nbblks);
> while (bufblks > log->l_logBBsize)
> bufblks >>= 1;
> while (!(buffer = xlog_alloc_buffer(log, bufblks))) {
> @@ -1528,7 +1528,7 @@ xlog_write_log_records(
> * a smaller size. We need to be able to write at least a
> * log sector, or we're out of luck.
> */
> - bufblks = 1 << ffs(blocks);
> + bufblks = roundup_pow_of_two(blocks);
> while (bufblks > log->l_logBBsize)
> bufblks >>= 1;
> while (!(buffer = xlog_alloc_buffer(log, bufblks))) {
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V3] xfs: use roundup_pow_of_two instead of ffs during xlog_find_tail
2023-09-19 2:06 ` Wang Jianchao
@ 2023-09-19 3:21 ` Darrick J. Wong
2023-09-19 6:34 ` Chandan Babu R
0 siblings, 1 reply; 7+ messages in thread
From: Darrick J. Wong @ 2023-09-19 3:21 UTC (permalink / raw)
To: Wang Jianchao, Chandan Babu R; +Cc: linux-xfs, linux-kernel
On Tue, Sep 19, 2023 at 10:06:56AM +0800, Wang Jianchao wrote:
> Ping ? Do I need other update on this patch ?
Nope, I think this is ok...
> Thanks
> Jianchao
>
> On 2023/9/13 09:38, Wang Jianchao wrote:
> >
> > In our production environment, we find that mounting a 500M /boot
> > which is umount cleanly needs ~6s. One cause is that ffs() is
> > used by xlog_write_log_records() to decide the buffer size. It
> > can cause a lot of small IO easily when xlog_clear_stale_blocks()
> > needs to wrap around the end of log area and log head block is
> > not power of two. Things are similar in xlog_find_verify_cycle().
> >
> > The code is able to handed bigger buffer very well, we can use
> > roundup_pow_of_two() to replace ffs() directly to avoid small
> > and sychronous IOs.
> >
> > Reviewed-by: Dave Chinner <dchinner@redhat.com>
> > Signed-off-by: Wang Jianchao <wangjc136@midea.com>
...so let's see if the release manager will take this patch.
Chandan? Could you pull in the various one-off patches floating around
on the list that have passed review? ;)
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
PS: If you'd like to send a pull request to push things along, please do
--D
> > ---
> >
> > Changes in V2:
> > - Move change log below "---"
> > - Add reviewed-by Dave Chinner tag
> >
> > Changes in V1:
> > - Also replace the ffs in xlog_find_verify_cycle()
> >
> > fs/xfs/xfs_log_recover.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> > index 82c81d20459d..13b94d2e605b 100644
> > --- a/fs/xfs/xfs_log_recover.c
> > +++ b/fs/xfs/xfs_log_recover.c
> > @@ -329,7 +329,7 @@ xlog_find_verify_cycle(
> > * try a smaller size. We need to be able to read at least
> > * a log sector, or we're out of luck.
> > */
> > - bufblks = 1 << ffs(nbblks);
> > + bufblks = roundup_pow_of_two(nbblks);
> > while (bufblks > log->l_logBBsize)
> > bufblks >>= 1;
> > while (!(buffer = xlog_alloc_buffer(log, bufblks))) {
> > @@ -1528,7 +1528,7 @@ xlog_write_log_records(
> > * a smaller size. We need to be able to write at least a
> > * log sector, or we're out of luck.
> > */
> > - bufblks = 1 << ffs(blocks);
> > + bufblks = roundup_pow_of_two(blocks);
> > while (bufblks > log->l_logBBsize)
> > bufblks >>= 1;
> > while (!(buffer = xlog_alloc_buffer(log, bufblks))) {
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V3] xfs: use roundup_pow_of_two instead of ffs during xlog_find_tail
2023-09-19 3:21 ` Darrick J. Wong
@ 2023-09-19 6:34 ` Chandan Babu R
0 siblings, 0 replies; 7+ messages in thread
From: Chandan Babu R @ 2023-09-19 6:34 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Wang Jianchao, Chandan Babu R, linux-xfs, linux-kernel
On Mon, Sep 18, 2023 at 08:21:38 PM -0700, Darrick J. Wong wrote:
> On Tue, Sep 19, 2023 at 10:06:56AM +0800, Wang Jianchao wrote:
>> Ping ? Do I need other update on this patch ?
>
> Nope, I think this is ok...
>
>> Thanks
>> Jianchao
>>
>> On 2023/9/13 09:38, Wang Jianchao wrote:
>> >
>> > In our production environment, we find that mounting a 500M /boot
>> > which is umount cleanly needs ~6s. One cause is that ffs() is
>> > used by xlog_write_log_records() to decide the buffer size. It
>> > can cause a lot of small IO easily when xlog_clear_stale_blocks()
>> > needs to wrap around the end of log area and log head block is
>> > not power of two. Things are similar in xlog_find_verify_cycle().
>> >
>> > The code is able to handed bigger buffer very well, we can use
>> > roundup_pow_of_two() to replace ffs() directly to avoid small
>> > and sychronous IOs.
>> >
>> > Reviewed-by: Dave Chinner <dchinner@redhat.com>
>> > Signed-off-by: Wang Jianchao <wangjc136@midea.com>
>
> ...so let's see if the release manager will take this patch.
>
> Chandan? Could you pull in the various one-off patches floating around
> on the list that have passed review? ;)
I had picked this patch along with others sometime last week.
I have pushed the new set of commits to official xfs-linux git repository and
sent the announcement mail around 30 mins ago.
>
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
>
> PS: If you'd like to send a pull request to push things along, please do
>
--
Chandan
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-09-19 6:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <63b3742c-0efe-c096-c737-a0e0419480bd@outlook.com>
2023-09-12 7:20 ` [PATCH V2] xfs: use roundup_pow_of_two instead of ffs during xlog_find_tail Wang Jianchao
2023-09-12 22:44 ` Dave Chinner
2023-09-13 1:33 ` Wang Jianchao
[not found] ` <59dd15dd-5b35-871d-6d3a-ec779975b089@outlook.com>
2023-09-13 1:38 ` [PATCH V3] " Wang Jianchao
[not found] ` <0a72f462-8b8e-4dec-6ce4-f52e33423957@outlook.com>
2023-09-19 2:06 ` Wang Jianchao
2023-09-19 3:21 ` Darrick J. Wong
2023-09-19 6:34 ` Chandan Babu R
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox