Re: [PATCH] ext4: change the type of ext4 cache stats to percpu_counter to improve performance
Hi Theodore, On 2019/8/26 23:57, Theodore Y. Ts'o wrote: > On Mon, Aug 26, 2019 at 04:24:20PM +0800, Shaokun Zhang wrote: >>> The other problem with this patch is that it initializes >>> es_stats_cache_hits and es_stats_cache_miesses too late. They will >>> get used when the journal inode is loaded. This is mostly harmless, >> >> I have checked it again, @es_stats_cache_hits and @es_stats_cache_miesses >> have been initialized before the journal inode is loaded, Maybe I miss >> something else? > > No, sorry, that was my mistake. I misread things when I was looking > over your patch last night. > > Please resubmit your patch once you've fixed things up and tested it. > Sure, will do it soon. > I would recommend that you at least try running your patch using the > kvm-xfstests's smoke test[1] before submitting them. It will save you > and me time. > Ok, thanks your guidance. Shaokun, > [1] > https://github.com/tytso/xfstests-bld/blob/master/Documentation/kvm-quickstart.md > > Thanks, > > - Ted > > > . >
Re: [PATCH] ext4: change the type of ext4 cache stats to percpu_counter to improve performance
On Mon, Aug 26, 2019 at 04:24:20PM +0800, Shaokun Zhang wrote: > > The other problem with this patch is that it initializes > > es_stats_cache_hits and es_stats_cache_miesses too late. They will > > get used when the journal inode is loaded. This is mostly harmless, > > I have checked it again, @es_stats_cache_hits and @es_stats_cache_miesses > have been initialized before the journal inode is loaded, Maybe I miss > something else? No, sorry, that was my mistake. I misread things when I was looking over your patch last night. Please resubmit your patch once you've fixed things up and tested it. I would recommend that you at least try running your patch using the kvm-xfstests's smoke test[1] before submitting them. It will save you and me time. [1] https://github.com/tytso/xfstests-bld/blob/master/Documentation/kvm-quickstart.md Thanks, - Ted
Re: [PATCH] ext4: change the type of ext4 cache stats to percpu_counter to improve performance
Hi Ted, On 2019/8/26 8:47, Theodore Y. Ts'o wrote: > On Sun, Aug 25, 2019 at 10:28:03AM -0700, Eric Biggers wrote: >> This patch is causing the following. Probably because there's no calls to >> percpu_counter_destroy() for the new counters? > > Yeah, I noticed this from my test runs last night as well. It looks > like original patch was never tested with CONFIG_HOTPLUG_CPU. > Sorry that We may miss it completely, we shall double check it and make the proper patch carefully. > The other problem with this patch is that it initializes > es_stats_cache_hits and es_stats_cache_miesses too late. They will > get used when the journal inode is loaded. This is mostly harmless, I have checked it again, @es_stats_cache_hits and @es_stats_cache_miesses have been initialized before the journal inode is loaded, Maybe I miss something else? egrep "ext4_es_register_shrinker|ext4_load_journal" fs/ext4/super.c 4260: if (ext4_es_register_shrinker(sbi)) 4302: err = ext4_load_journal(sb, es, journal_devnum); Thanks, Shaokun > but it's also wrong. > > I've dropped this patch from the ext4 git tree. > > - Ted > > . >
Re: [PATCH] ext4: change the type of ext4 cache stats to percpu_counter to improve performance
Hi Eric, On 2019/8/26 1:28, Eric Biggers wrote: > On Sat, Aug 24, 2019 at 11:25:24PM -0400, Theodore Y. Ts'o wrote: >> On Fri, Aug 23, 2019 at 10:47:34AM +0800, Shaokun Zhang wrote: >>> From: Yang Guo >>> >>> @es_stats_cache_hits and @es_stats_cache_misses are accessed frequently in >>> ext4_es_lookup_extent function, it would influence the ext4 read/write >>> performance in NUMA system. >>> Let's optimize it using percpu_counter, it is profitable for the >>> performance. >>> >>> The test command is as below: >>> fio -name=randwrite -numjobs=8 -filename=/mnt/test1 -rw=randwrite >>> -ioengine=libaio -direct=1 -iodepth=64 -sync=0 -norandommap -group_reporting >>> -runtime=120 -time_based -bs=4k -size=5G >>> >>> And the result is better 10% than the initial implement: >>> without the patch,IOPS=197k, BW=770MiB/s (808MB/s)(90.3GiB/120002msec) >>> with the patch, IOPS=218k, BW=852MiB/s (894MB/s)(99.9GiB/120002msec) >>> >>> Cc: "Theodore Ts'o" >>> Cc: Andreas Dilger >>> Signed-off-by: Yang Guo >>> Signed-off-by: Shaokun Zhang >> >> Applied with some adjustments so it would apply. I also changed the patch >> summary to: >> >> ext4: use percpu_counters for extent_status cache hits/misses >> >> - Ted > > This patch is causing the following. Probably because there's no calls to > percpu_counter_destroy() for the new counters? > Apologies, We missed it and let's fix it soon. Thanks, Shaokun > == > BUG: KASAN: use-after-free in __list_del_entry_valid+0x168/0x180 > lib/list_debug.c:51 > Read of size 8 at addr 888063168fa8 by task umount/611 > > CPU: 1 PID: 611 Comm: umount Not tainted 5.3.0-rc4-00015-gcc08b68e62ec #6 > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS > 1.12.0-20181126_142135-anatol 04/01/2014 > Call Trace: > __dump_stack lib/dump_stack.c:77 [inline] > dump_stack+0x86/0xca lib/dump_stack.c:113 > print_address_description+0x6e/0x2e7 mm/kasan/report.c:351 > __kasan_report.cold+0x1b/0x35 mm/kasan/report.c:482 > kasan_report+0x12/0x17 mm/kasan/common.c:612 > __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132 > __list_del_entry_valid+0x168/0x180 lib/list_debug.c:51 > __list_del_entry include/linux/list.h:131 [inline] > list_del include/linux/list.h:139 [inline] > percpu_counter_destroy+0x5d/0x230 lib/percpu_counter.c:157 > ext4_put_super+0x319/0xbb0 fs/ext4/super.c:1010 > generic_shutdown_super+0x128/0x320 fs/super.c:458 > kill_block_super+0x97/0xe0 fs/super.c:1310 > deactivate_locked_super+0x7b/0xd0 fs/super.c:331 > deactivate_super+0x138/0x150 fs/super.c:362 > cleanup_mnt+0x298/0x3f0 fs/namespace.c:1102 > __cleanup_mnt+0xd/0x10 fs/namespace.c:1109 > task_work_run+0x103/0x180 kernel/task_work.c:113 > tracehook_notify_resume include/linux/tracehook.h:188 [inline] > exit_to_usermode_loop+0x10b/0x130 arch/x86/entry/common.c:163 > prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline] > syscall_return_slowpath arch/x86/entry/common.c:274 [inline] > do_syscall_64+0x343/0x450 arch/x86/entry/common.c:299 > entry_SYSCALL_64_after_hwframe+0x49/0xbe > RIP: 0033:0x7f7caed23d77 > Code: 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 31 f6 e9 09 00 > 00 00 66 0f 1f 84 00 00 00 00 00 b8 a6 00 8 > RSP: 002b:7ffe960e7c98 EFLAGS: 0246 ORIG_RAX: 00a6 > RAX: RBX: 560c039e1060 RCX: 7f7caed23d77 > RDX: 0001 RSI: RDI: 560c039e3c90 > RBP: 560c039e3c90 R08: 560c039e2ec0 R09: 0014 > R10: 06b4 R11: 0246 R12: 7f7caf225e64 > R13: R14: 560c039e1240 R15: 7ffe960e7f20 > > Allocated by task 596: > save_stack mm/kasan/common.c:69 [inline] > set_track mm/kasan/common.c:77 [inline] > __kasan_kmalloc.part.0+0x41/0xb0 mm/kasan/common.c:487 > __kasan_kmalloc.constprop.0+0xba/0xc0 mm/kasan/common.c:468 > kasan_kmalloc+0x9/0x10 mm/kasan/common.c:501 > kmem_cache_alloc_trace+0x11e/0x2e0 mm/slab.c:3550 > kmalloc include/linux/slab.h:552 [inline] > kzalloc include/linux/slab.h:748 [inline] > ext4_fill_super+0x111/0x80a0 fs/ext4/super.c:3610 > mount_bdev+0x286/0x350 fs/super.c:1283 > ext4_mount+0x10/0x20 fs/ext4/super.c:6007 > legacy_get_tree+0x101/0x1f0 fs/fs_context.c:661 > vfs_get_tree+0x86/0x2e0 fs/super.c:1413 > do_new_mount fs/namespace.c:2791 [inline] > do_mount+0x1093/0x1b30 fs/namespace.c:3111 > ksys_mount+0x7d/0xd0 fs/namespace.c:3320 > __do_sys_mount fs/namespace.c:3334 [inline] > __se_sys_mount fs/namespace.c:3331 [inline] > __x64_sys_mount+0xb9/0x150 fs/namespace.c:3331 > do_syscall_64+0x8f/0x450 arch/x86/entry/common.c:296 > entry_SYSCALL_64_after_hwframe+0x49/0xbe > > Freed by task 600: > save_stack mm/kasan/common.c:69 [inline] > set_track mm/kasan/common.c:77 [inline] > __kasan_slab_free+0x127/0x1f0 mm/kasan/common.c:449 > kasan_slab_free+0xe/0x10
Re: [PATCH] ext4: change the type of ext4 cache stats to percpu_counter to improve performance
On Sun, Aug 25, 2019 at 10:28:03AM -0700, Eric Biggers wrote: > This patch is causing the following. Probably because there's no calls to > percpu_counter_destroy() for the new counters? Yeah, I noticed this from my test runs last night as well. It looks like original patch was never tested with CONFIG_HOTPLUG_CPU. The other problem with this patch is that it initializes es_stats_cache_hits and es_stats_cache_miesses too late. They will get used when the journal inode is loaded. This is mostly harmless, but it's also wrong. I've dropped this patch from the ext4 git tree. - Ted
Re: [PATCH] ext4: change the type of ext4 cache stats to percpu_counter to improve performance
On Sat, Aug 24, 2019 at 11:25:24PM -0400, Theodore Y. Ts'o wrote: > On Fri, Aug 23, 2019 at 10:47:34AM +0800, Shaokun Zhang wrote: > > From: Yang Guo > > > > @es_stats_cache_hits and @es_stats_cache_misses are accessed frequently in > > ext4_es_lookup_extent function, it would influence the ext4 read/write > > performance in NUMA system. > > Let's optimize it using percpu_counter, it is profitable for the > > performance. > > > > The test command is as below: > > fio -name=randwrite -numjobs=8 -filename=/mnt/test1 -rw=randwrite > > -ioengine=libaio -direct=1 -iodepth=64 -sync=0 -norandommap -group_reporting > > -runtime=120 -time_based -bs=4k -size=5G > > > > And the result is better 10% than the initial implement: > > without the patch,IOPS=197k, BW=770MiB/s (808MB/s)(90.3GiB/120002msec) > > with the patch, IOPS=218k, BW=852MiB/s (894MB/s)(99.9GiB/120002msec) > > > > Cc: "Theodore Ts'o" > > Cc: Andreas Dilger > > Signed-off-by: Yang Guo > > Signed-off-by: Shaokun Zhang > > Applied with some adjustments so it would apply. I also changed the patch > summary to: > > ext4: use percpu_counters for extent_status cache hits/misses > > - Ted This patch is causing the following. Probably because there's no calls to percpu_counter_destroy() for the new counters? == BUG: KASAN: use-after-free in __list_del_entry_valid+0x168/0x180 lib/list_debug.c:51 Read of size 8 at addr 888063168fa8 by task umount/611 CPU: 1 PID: 611 Comm: umount Not tainted 5.3.0-rc4-00015-gcc08b68e62ec #6 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-20181126_142135-anatol 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x86/0xca lib/dump_stack.c:113 print_address_description+0x6e/0x2e7 mm/kasan/report.c:351 __kasan_report.cold+0x1b/0x35 mm/kasan/report.c:482 kasan_report+0x12/0x17 mm/kasan/common.c:612 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132 __list_del_entry_valid+0x168/0x180 lib/list_debug.c:51 __list_del_entry include/linux/list.h:131 [inline] list_del include/linux/list.h:139 [inline] percpu_counter_destroy+0x5d/0x230 lib/percpu_counter.c:157 ext4_put_super+0x319/0xbb0 fs/ext4/super.c:1010 generic_shutdown_super+0x128/0x320 fs/super.c:458 kill_block_super+0x97/0xe0 fs/super.c:1310 deactivate_locked_super+0x7b/0xd0 fs/super.c:331 deactivate_super+0x138/0x150 fs/super.c:362 cleanup_mnt+0x298/0x3f0 fs/namespace.c:1102 __cleanup_mnt+0xd/0x10 fs/namespace.c:1109 task_work_run+0x103/0x180 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:188 [inline] exit_to_usermode_loop+0x10b/0x130 arch/x86/entry/common.c:163 prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline] syscall_return_slowpath arch/x86/entry/common.c:274 [inline] do_syscall_64+0x343/0x450 arch/x86/entry/common.c:299 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x7f7caed23d77 Code: 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 31 f6 e9 09 00 00 00 66 0f 1f 84 00 00 00 00 00 b8 a6 00 8 RSP: 002b:7ffe960e7c98 EFLAGS: 0246 ORIG_RAX: 00a6 RAX: RBX: 560c039e1060 RCX: 7f7caed23d77 RDX: 0001 RSI: RDI: 560c039e3c90 RBP: 560c039e3c90 R08: 560c039e2ec0 R09: 0014 R10: 06b4 R11: 0246 R12: 7f7caf225e64 R13: R14: 560c039e1240 R15: 7ffe960e7f20 Allocated by task 596: save_stack mm/kasan/common.c:69 [inline] set_track mm/kasan/common.c:77 [inline] __kasan_kmalloc.part.0+0x41/0xb0 mm/kasan/common.c:487 __kasan_kmalloc.constprop.0+0xba/0xc0 mm/kasan/common.c:468 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:501 kmem_cache_alloc_trace+0x11e/0x2e0 mm/slab.c:3550 kmalloc include/linux/slab.h:552 [inline] kzalloc include/linux/slab.h:748 [inline] ext4_fill_super+0x111/0x80a0 fs/ext4/super.c:3610 mount_bdev+0x286/0x350 fs/super.c:1283 ext4_mount+0x10/0x20 fs/ext4/super.c:6007 legacy_get_tree+0x101/0x1f0 fs/fs_context.c:661 vfs_get_tree+0x86/0x2e0 fs/super.c:1413 do_new_mount fs/namespace.c:2791 [inline] do_mount+0x1093/0x1b30 fs/namespace.c:3111 ksys_mount+0x7d/0xd0 fs/namespace.c:3320 __do_sys_mount fs/namespace.c:3334 [inline] __se_sys_mount fs/namespace.c:3331 [inline] __x64_sys_mount+0xb9/0x150 fs/namespace.c:3331 do_syscall_64+0x8f/0x450 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 600: save_stack mm/kasan/common.c:69 [inline] set_track mm/kasan/common.c:77 [inline] __kasan_slab_free+0x127/0x1f0 mm/kasan/common.c:449 kasan_slab_free+0xe/0x10 mm/kasan/common.c:457 __cache_free mm/slab.c:3425 [inline] kfree+0xc1/0x1e0 mm/slab.c:3756 ext4_put_super+0x78c/0xbb0 fs/ext4/super.c:1061 generic_shutdown_super+0x128/0x320 fs/super.c:458 kill_block_super+0x97/0xe0 fs/super.c:1310 deactivate_locked_super+0x7b/0xd0
Re: [PATCH] ext4: change the type of ext4 cache stats to percpu_counter to improve performance
On Fri, Aug 23, 2019 at 10:47:34AM +0800, Shaokun Zhang wrote: > From: Yang Guo > > @es_stats_cache_hits and @es_stats_cache_misses are accessed frequently in > ext4_es_lookup_extent function, it would influence the ext4 read/write > performance in NUMA system. > Let's optimize it using percpu_counter, it is profitable for the > performance. > > The test command is as below: > fio -name=randwrite -numjobs=8 -filename=/mnt/test1 -rw=randwrite > -ioengine=libaio -direct=1 -iodepth=64 -sync=0 -norandommap -group_reporting > -runtime=120 -time_based -bs=4k -size=5G > > And the result is better 10% than the initial implement: > without the patch,IOPS=197k, BW=770MiB/s (808MB/s)(90.3GiB/120002msec) > with the patch, IOPS=218k, BW=852MiB/s (894MB/s)(99.9GiB/120002msec) > > Cc: "Theodore Ts'o" > Cc: Andreas Dilger > Signed-off-by: Yang Guo > Signed-off-by: Shaokun Zhang Applied with some adjustments so it would apply. I also changed the patch summary to: ext4: use percpu_counters for extent_status cache hits/misses - Ted