* [PATCH] fs/buffer.c: Add checking buffer head stat before clear
@ 2021-02-03 6:14 Shaokun Zhang
2021-02-05 23:45 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Shaokun Zhang @ 2021-02-03 6:14 UTC (permalink / raw)
To: linux-fsdevel, linux-kernel
Cc: Yang Guo, Alexander Viro, Andrew Morton, Nick Piggin, Shaokun Zhang
From: Yang Guo <guoyang2@huawei.com>
clear_buffer_new() is used to clear buffer new stat. When PAGE_SIZE
is 64K, most buffer heads in the list are not needed to clear.
clear_buffer_new() has an enpensive atomic modification operation,
Let's add checking buffer head before clear it as __block_write_begin_int
does which is good for performance.
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Piggin <npiggin@suse.de>
Signed-off-by: Yang Guo <guoyang2@huawei.com>
Signed-off-by: Shaokun Zhang <zhangshaokun@hisilicon.com>
---
fs/buffer.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/buffer.c b/fs/buffer.c
index 32647d2011df..f1c3a5b27a90 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2083,7 +2083,8 @@ static int __block_commit_write(struct inode *inode, struct page *page,
set_buffer_uptodate(bh);
mark_buffer_dirty(bh);
}
- clear_buffer_new(bh);
+ if (buffer_new(bh))
+ clear_buffer_new(bh);
block_start = block_end;
bh = bh->b_this_page;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/buffer.c: Add checking buffer head stat before clear
2021-02-03 6:14 [PATCH] fs/buffer.c: Add checking buffer head stat before clear Shaokun Zhang
@ 2021-02-05 23:45 ` Andrew Morton
2021-02-08 6:12 ` Shaokun Zhang
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2021-02-05 23:45 UTC (permalink / raw)
To: Shaokun Zhang
Cc: linux-fsdevel, linux-kernel, Yang Guo, Alexander Viro, Nick Piggin
On Wed, 3 Feb 2021 14:14:50 +0800 Shaokun Zhang <zhangshaokun@hisilicon.com> wrote:
> From: Yang Guo <guoyang2@huawei.com>
>
> clear_buffer_new() is used to clear buffer new stat. When PAGE_SIZE
> is 64K, most buffer heads in the list are not needed to clear.
> clear_buffer_new() has an enpensive atomic modification operation,
> Let's add checking buffer head before clear it as __block_write_begin_int
> does which is good for performance.
Did this produce any measurable improvement?
Perhaps we should give clear_buffer_x() the same optimization as
set_buffer_x()?
static __always_inline void set_buffer_##name(struct buffer_head *bh) \
{ \
if (!test_bit(BH_##bit, &(bh)->b_state)) \
set_bit(BH_##bit, &(bh)->b_state); \
} \
static __always_inline void clear_buffer_##name(struct buffer_head *bh) \
{ \
clear_bit(BH_##bit, &(bh)->b_state); \
} \
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/buffer.c: Add checking buffer head stat before clear
2021-02-05 23:45 ` Andrew Morton
@ 2021-02-08 6:12 ` Shaokun Zhang
0 siblings, 0 replies; 3+ messages in thread
From: Shaokun Zhang @ 2021-02-08 6:12 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-fsdevel, linux-kernel, Yang Guo, Alexander Viro, Nick Piggin
Hi Andrew,
在 2021/2/6 7:45, Andrew Morton 写道:
> On Wed, 3 Feb 2021 14:14:50 +0800 Shaokun Zhang <zhangshaokun@hisilicon.com> wrote:
>
>> From: Yang Guo <guoyang2@huawei.com>
>>
>> clear_buffer_new() is used to clear buffer new stat. When PAGE_SIZE
>> is 64K, most buffer heads in the list are not needed to clear.
>> clear_buffer_new() has an enpensive atomic modification operation,
>> Let's add checking buffer head before clear it as __block_write_begin_int
>> does which is good for performance.
>
> Did this produce any measurable improvement?
It has been tested on Huwei Kunpeng 920 which is ARM64 platform and test commond is below:
numactl --cpunodebind=0 --membind=0 fio -name=randwrite -numjobs=16 -filename=/mnt/test1
-rw=randwrite -ioengine=libaio -direct=0 -iodepth=64 -sync=0 -norandommap -group_reporting
-runtime=60 -time_based -bs=4k -size=5G
The test result before patch:
WRITE: bw=930MiB/s (976MB/s), 930MiB/s-930MiB/s (976MB/s-976MB/s), io=54.5GiB (58.5GB),
run=60001-60001msec
The test result after patch:
WRITE: bw=958MiB/s (1005MB/s), 958MiB/s-958MiB/s (1005MB/s-1005MB/s), io=56.1GiB (60.3GB),
run=60001-60001msec
>
> Perhaps we should give clear_buffer_x() the same optimization as
> set_buffer_x()?
>
Good catch,
but we check it more about it, if we do it the same as set_buffer_x(),
many more codes will be fixed, such as ext4_wait_block_bitmap
it has done sanity check using buffer_new and clear_buffer_new
will check it again.
Thanks,
Shaokun
>
> static __always_inline void set_buffer_##name(struct buffer_head *bh) \
> { \
> if (!test_bit(BH_##bit, &(bh)->b_state)) \
> set_bit(BH_##bit, &(bh)->b_state); \
> } \
> static __always_inline void clear_buffer_##name(struct buffer_head *bh) \
> { \
> clear_bit(BH_##bit, &(bh)->b_state); \
> } \
>
>
> .
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-08 6:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 6:14 [PATCH] fs/buffer.c: Add checking buffer head stat before clear Shaokun Zhang
2021-02-05 23:45 ` Andrew Morton
2021-02-08 6:12 ` Shaokun Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).