Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1682576 > unrolled thread
| Started by | Adam Borowski <kilobyte@angband.pl> |
|---|---|
| First post | 2017-07-06 18:40 +0200 |
| Last post | 2017-07-12 05:40 +0200 |
| Articles | 9 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v2 3/4] btrfs: Add zstd support Adam Borowski <kilobyte@angband.pl> - 2017-07-06 18:40 +0200
Re: [PATCH v2 3/4] btrfs: Add zstd support Nick Terrell <terrelln@fb.com> - 2017-07-08 01:20 +0200
Re: [PATCH v2 3/4] btrfs: Add zstd support Adam Borowski <kilobyte@angband.pl> - 2017-07-08 01:50 +0200
Re: [PATCH v2 3/4] btrfs: Add zstd support Adam Borowski <kilobyte@angband.pl> - 2017-07-08 05:10 +0200
Re: [PATCH v2 3/4] btrfs: Add zstd support "Austin S. Hemmelgarn" <ahferroin7@gmail.com> - 2017-07-10 14:40 +0200
Re: [PATCH v2 3/4] btrfs: Add zstd support Nick Terrell <terrelln@fb.com> - 2017-07-10 23:00 +0200
Re: [PATCH v2 3/4] btrfs: Add zstd support Nick Terrell <terrelln@fb.com> - 2017-07-11 07:00 +0200
Re: [PATCH v2 3/4] btrfs: Add zstd support Nick Terrell <terrelln@fb.com> - 2017-07-11 08:10 +0200
Re: [PATCH v2 3/4] btrfs: Add zstd support Adam Borowski <kilobyte@angband.pl> - 2017-07-12 05:40 +0200
| From | Adam Borowski <kilobyte@angband.pl> |
|---|---|
| Date | 2017-07-06 18:40 +0200 |
| Subject | Re: [PATCH v2 3/4] btrfs: Add zstd support |
| Message-ID | <u0hYT-819-33@gated-at.bofh.it> |
On Thu, Jun 29, 2017 at 12:41:07PM -0700, Nick Terrell wrote: > Add zstd compression and decompression support to BtrFS. zstd at its > fastest level compresses almost as well as zlib, while offering much > faster compression and decompression, approaching lzo speeds. Got a reproducible crash on amd64: [98235.266511] BUG: unable to handle kernel paging request at ffffc90001251000 [98235.267485] IP: ZSTD_storeSeq.constprop.24+0x67/0xe0 [98235.269395] PGD 227034067 [98235.269397] P4D 227034067 [98235.271587] PUD 227035067 [98235.273657] PMD 223323067 [98235.275744] PTE 0 [98235.281545] Oops: 0002 [#1] SMP [98235.283353] Modules linked in: loop veth tun fuse arc4 rtl8xxxu mac80211 cfg80211 cp210x pl2303 rfkill usbserial nouveau video mxm_wmi ttm [98235.285203] CPU: 0 PID: 10850 Comm: kworker/u12:9 Not tainted 4.12.0+ #1 [98235.287070] Hardware name: System manufacturer System Product Name/M4A77T, BIOS 2401 05/18/2011 [98235.288964] Workqueue: btrfs-delalloc btrfs_delalloc_helper [98235.290934] task: ffff880224984140 task.stack: ffffc90007e5c000 [98235.292731] RIP: 0010:ZSTD_storeSeq.constprop.24+0x67/0xe0 [98235.294579] RSP: 0018:ffffc90007e5fa68 EFLAGS: 00010282 [98235.296395] RAX: ffffc90001251001 RBX: 0000000000000094 RCX: ffffc9000118f930 [98235.298380] RDX: 0000000000000006 RSI: ffffc900011b06b0 RDI: ffffc9000118d1e0 [98235.300321] RBP: 000000000000009f R08: 1fffffffffffbe58 R09: 0000000000000000 [98235.302282] R10: ffffc9000118f970 R11: 0000000000000005 R12: ffffc9000118f878 [98235.304221] R13: 000000000000005b R14: ffffc9000118f915 R15: ffffc900011cfe88 [98235.306147] FS: 0000000000000000(0000) GS:ffff88022fc00000(0000) knlGS:0000000000000000 [98235.308162] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [98235.310129] CR2: ffffc90001251000 CR3: 000000021018d000 CR4: 00000000000006f0 [98235.312095] Call Trace: [98235.314008] ? ZSTD_compressBlock_fast+0x94b/0xb30 [98235.315975] ? ZSTD_compressContinue_internal+0x1a0/0x580 [98235.317938] ? ZSTD_compressStream_generic+0x248/0x2f0 [98235.319877] ? ZSTD_compressStream+0x41/0x60 [98235.321821] ? zstd_compress_pages+0x236/0x5d0 [98235.323724] ? btrfs_compress_pages+0x5e/0x80 [98235.325684] ? compress_file_range.constprop.79+0x1eb/0x750 [98235.327668] ? async_cow_start+0x2e/0x50 [98235.329594] ? btrfs_worker_helper+0x1b9/0x1d0 [98235.331486] ? process_one_work+0x158/0x2f0 [98235.333361] ? worker_thread+0x45/0x3a0 [98235.335253] ? process_one_work+0x2f0/0x2f0 [98235.337189] ? kthread+0x10e/0x130 [98235.339020] ? kthread_park+0x60/0x60 [98235.340819] ? ret_from_fork+0x22/0x30 [98235.342637] Code: 8b 4e d0 4c 89 48 d0 4c 8b 4e d8 4c 89 48 d8 4c 8b 4e e0 4c 89 48 e0 4c 8b 4e e8 4c 89 48 e8 4c 8b 4e f0 4c 89 48 f0 4c 8b 4e f8 <4c> 89 48 f8 48 39 f1 75 a2 4e 8d 04 c0 48 8b 31 48 83 c0 08 48 [98235.346773] RIP: ZSTD_storeSeq.constprop.24+0x67/0xe0 RSP: ffffc90007e5fa68 [98235.348809] CR2: ffffc90001251000 [98235.363216] ---[ end trace 5fb3ad0f2aec0605 ]--- [98235.363218] BUG: unable to handle kernel paging request at ffffc9000393a000 [98235.363239] IP: ZSTD_storeSeq.constprop.24+0x67/0xe0 [98235.363241] PGD 227034067 [98235.363242] P4D 227034067 [98235.363243] PUD 227035067 [98235.363244] PMD 21edec067 [98235.363245] PTE 0 (More of the above follows.) My reproducer copies an uncompressed tarball onto a fresh filesystem: .---- #!/bin/sh set -e losetup -D; umount /mnt/vol1 ||: dd if=/dev/zero of=/tmp/disk bs=2048 seek=1048575 count=1 mkfs.btrfs -msingle /tmp/disk losetup -f /tmp/disk sleep 1 # yay udev races mount -onoatime,compress=$1 /dev/loop0 /mnt/vol1 time sh -c 'cp -p ~kilobyte/tmp/kernel.tar /mnt/vol1 && umount /mnt/vol1' losetup -D `---- (run it with arg of "zstd") Kernel is 4.12.0 + btrfs-for-4.13 + v4 of Qu's chunk check + some unrelated stuff + zstd; in case it matters I've pushed my tree to https://github.com/kilobyte/linux/tree/zstd-crash The payload is a tarball of the above, but, for debugging compression you need the exact byte stream. https://angband.pl/tmp/kernel.tar.xz -- without xz, I compressed it for transport. Meow! -- ⢀⣴⠾⠻⢶⣦⠀ ⣾⠁⢠⠒⠀⣿⡁ A dumb species has no way to open a tuna can. ⢿⡄⠘⠷⠚⠋⠀ A smart species invents a can opener. ⠈⠳⣄⠀⠀⠀⠀ A master species delegates.
[toc] | [next] | [standalone]
| From | Nick Terrell <terrelln@fb.com> |
|---|---|
| Date | 2017-07-08 01:20 +0200 |
| Message-ID | <u0KHw-2xj-3@gated-at.bofh.it> |
| In reply to | #1682576 |
On 7/6/17, 9:32 AM, "Adam Borowski" <kilobyte@angband.pl> wrote: > On Thu, Jun 29, 2017 at 12:41:07PM -0700, Nick Terrell wrote: >> Add zstd compression and decompression support to BtrFS. zstd at its >> fastest level compresses almost as well as zlib, while offering much >> faster compression and decompression, approaching lzo speeds. > > Got a reproducible crash on amd64: > > [98235.266511] BUG: unable to handle kernel paging request at ffffc90001251000 > [98235.267485] IP: ZSTD_storeSeq.constprop.24+0x67/0xe0 > [98235.269395] PGD 227034067 > [98235.269397] P4D 227034067 > [98235.271587] PUD 227035067 > [98235.273657] PMD 223323067 > [98235.275744] PTE 0 > > [98235.281545] Oops: 0002 [#1] SMP > [98235.283353] Modules linked in: loop veth tun fuse arc4 rtl8xxxu mac80211 cfg80211 cp210x pl2303 rfkill usbserial nouveau video mxm_wmi ttm > [98235.285203] CPU: 0 PID: 10850 Comm: kworker/u12:9 Not tainted 4.12.0+ #1 > [98235.287070] Hardware name: System manufacturer System Product Name/M4A77T, BIOS 2401 05/18/2011 > [98235.288964] Workqueue: btrfs-delalloc btrfs_delalloc_helper > [98235.290934] task: ffff880224984140 task.stack: ffffc90007e5c000 > [98235.292731] RIP: 0010:ZSTD_storeSeq.constprop.24+0x67/0xe0 > [98235.294579] RSP: 0018:ffffc90007e5fa68 EFLAGS: 00010282 > [98235.296395] RAX: ffffc90001251001 RBX: 0000000000000094 RCX: ffffc9000118f930 > [98235.298380] RDX: 0000000000000006 RSI: ffffc900011b06b0 RDI: ffffc9000118d1e0 > [98235.300321] RBP: 000000000000009f R08: 1fffffffffffbe58 R09: 0000000000000000 > [98235.302282] R10: ffffc9000118f970 R11: 0000000000000005 R12: ffffc9000118f878 > [98235.304221] R13: 000000000000005b R14: ffffc9000118f915 R15: ffffc900011cfe88 > [98235.306147] FS: 0000000000000000(0000) GS:ffff88022fc00000(0000) knlGS:0000000000000000 > [98235.308162] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > [98235.310129] CR2: ffffc90001251000 CR3: 000000021018d000 CR4: 00000000000006f0 > [98235.312095] Call Trace: > [98235.314008] ? ZSTD_compressBlock_fast+0x94b/0xb30 > [98235.315975] ? ZSTD_compressContinue_internal+0x1a0/0x580 > [98235.317938] ? ZSTD_compressStream_generic+0x248/0x2f0 > [98235.319877] ? ZSTD_compressStream+0x41/0x60 > [98235.321821] ? zstd_compress_pages+0x236/0x5d0 > [98235.323724] ? btrfs_compress_pages+0x5e/0x80 > [98235.325684] ? compress_file_range.constprop.79+0x1eb/0x750 > [98235.327668] ? async_cow_start+0x2e/0x50 > [98235.329594] ? btrfs_worker_helper+0x1b9/0x1d0 > [98235.331486] ? process_one_work+0x158/0x2f0 > [98235.333361] ? worker_thread+0x45/0x3a0 > [98235.335253] ? process_one_work+0x2f0/0x2f0 > [98235.337189] ? kthread+0x10e/0x130 > [98235.339020] ? kthread_park+0x60/0x60 > [98235.340819] ? ret_from_fork+0x22/0x30 > [98235.342637] Code: 8b 4e d0 4c 89 48 d0 4c 8b 4e d8 4c 89 48 d8 4c 8b 4e e0 4c 89 48 e0 4c 8b 4e e8 4c 89 48 e8 4c 8b 4e f0 4c 89 48 f0 4c 8b 4e f8 <4c> 89 48 f8 48 39 f1 75 a2 4e 8d 04 c0 48 8b 31 48 83 c0 08 48 > [98235.346773] RIP: ZSTD_storeSeq.constprop.24+0x67/0xe0 RSP: ffffc90007e5fa68 > [98235.348809] CR2: ffffc90001251000 > [98235.363216] ---[ end trace 5fb3ad0f2aec0605 ]--- > [98235.363218] BUG: unable to handle kernel paging request at ffffc9000393a000 > [98235.363239] IP: ZSTD_storeSeq.constprop.24+0x67/0xe0 > [98235.363241] PGD 227034067 > [98235.363242] P4D 227034067 > [98235.363243] PUD 227035067 > [98235.363244] PMD 21edec067 > [98235.363245] PTE 0 > (More of the above follows.) > > My reproducer copies an uncompressed tarball onto a fresh filesystem: > .---- > #!/bin/sh > set -e > > losetup -D; umount /mnt/vol1 ||: > dd if=/dev/zero of=/tmp/disk bs=2048 seek=1048575 count=1 > mkfs.btrfs -msingle /tmp/disk > losetup -f /tmp/disk > sleep 1 # yay udev races > mount -onoatime,compress=$1 /dev/loop0 /mnt/vol1 > time sh -c 'cp -p ~kilobyte/tmp/kernel.tar /mnt/vol1 && umount /mnt/vol1' > losetup -D > `---- > (run it with arg of "zstd") > > Kernel is 4.12.0 + btrfs-for-4.13 + v4 of Qu's chunk check + some unrelated > stuff + zstd; in case it matters I've pushed my tree to > https://github.com/kilobyte/linux/tree/zstd-crash > > The payload is a tarball of the above, but, for debugging compression you > need the exact byte stream. https://angband.pl/tmp/kernel.tar.xz -- > without xz, I compressed it for transport. Thanks for the bug report Adam! I'm looking into the failure, and haven't been able to reproduce it yet. I've built my kernel from your tree, and I ran your script with the kernel.tar tarball 100 times, but haven't gotten a failure yet. I have a few questions to guide my debugging. - How many cores are you running with? I’ve run the script with 1, 2, and 4 cores. - Which version of gcc are you using to compile the kernel? I’m using gcc-6.2.0-5ubuntu12. - Are the failures always in exactly the same place, and does it fail 100% of the time or just regularly?
[toc] | [prev] | [next] | [standalone]
| From | Adam Borowski <kilobyte@angband.pl> |
|---|---|
| Date | 2017-07-08 01:50 +0200 |
| Message-ID | <u0Lax-2HY-7@gated-at.bofh.it> |
| In reply to | #1683461 |
On Fri, Jul 07, 2017 at 11:17:49PM +0000, Nick Terrell wrote: > On 7/6/17, 9:32 AM, "Adam Borowski" <kilobyte@angband.pl> wrote: > > Got a reproducible crash on amd64: > > > > [98235.266511] BUG: unable to handle kernel paging request at ffffc90001251000 > > [98235.314008] ? ZSTD_compressBlock_fast+0x94b/0xb30 > > [98235.315975] ? ZSTD_compressContinue_internal+0x1a0/0x580 > > [98235.317938] ? ZSTD_compressStream_generic+0x248/0x2f0 > > [98235.319877] ? ZSTD_compressStream+0x41/0x60 > > [98235.321821] ? zstd_compress_pages+0x236/0x5d0 > > [98235.323724] ? btrfs_compress_pages+0x5e/0x80 > > [98235.325684] ? compress_file_range.constprop.79+0x1eb/0x750 > > Thanks for the bug report Adam! I'm looking into the failure, and haven't > been able to reproduce it yet. I've built my kernel from your tree, and > I ran your script with the kernel.tar tarball 100 times, but haven't gotten > a failure yet. Crashed the same way 4 out of 4 tries for me. > I have a few questions to guide my debugging. > > - How many cores are you running with? I’ve run the script with 1, 2, and 4 cores. > - Which version of gcc are you using to compile the kernel? I’m using gcc-6.2.0-5ubuntu12. > - Are the failures always in exactly the same place, and does it fail 100% > of the time or just regularly? 6 cores -- all on bare metal. gcc-7.1.0-9. Lemme try with gcc-6, a different config or in a VM. -- ⢀⣴⠾⠻⢶⣦⠀ ⣾⠁⢠⠒⠀⣿⡁ A dumb species has no way to open a tuna can. ⢿⡄⠘⠷⠚⠋⠀ A smart species invents a can opener. ⠈⠳⣄⠀⠀⠀⠀ A master species delegates.
[toc] | [prev] | [next] | [standalone]
| From | Adam Borowski <kilobyte@angband.pl> |
|---|---|
| Date | 2017-07-08 05:10 +0200 |
| Message-ID | <u0Oi5-57m-1@gated-at.bofh.it> |
| In reply to | #1683462 |
On Sat, Jul 08, 2017 at 01:40:18AM +0200, Adam Borowski wrote: > On Fri, Jul 07, 2017 at 11:17:49PM +0000, Nick Terrell wrote: > > On 7/6/17, 9:32 AM, "Adam Borowski" <kilobyte@angband.pl> wrote: > > > Got a reproducible crash on amd64: > > > Thanks for the bug report Adam! I'm looking into the failure, and haven't > > been able to reproduce it yet. I've built my kernel from your tree, and > > I ran your script with the kernel.tar tarball 100 times, but haven't gotten > > a failure yet. > > > I have a few questions to guide my debugging. > > > > - How many cores are you running with? I’ve run the script with 1, 2, and 4 cores. > > - Which version of gcc are you using to compile the kernel? I’m using gcc-6.2.0-5ubuntu12. > > - Are the failures always in exactly the same place, and does it fail 100% > > of the time or just regularly? > > 6 cores -- all on bare metal. gcc-7.1.0-9. > Lemme try with gcc-6, a different config or in a VM. I've tried the following: * gcc-6, defconfig (+btrfs obviously) * gcc-7, defconfig * gcc-6, my regular config * gcc-7, my regular config * gcc-7, debug + UBSAN + etc * gcc-7, defconfig, qemu-kvm with only 1 core Every build with gcc-7 reproduces the crash, every with gcc-6 does not. -- ⢀⣴⠾⠻⢶⣦⠀ ⣾⠁⢠⠒⠀⣿⡁ A dumb species has no way to open a tuna can. ⢿⡄⠘⠷⠚⠋⠀ A smart species invents a can opener. ⠈⠳⣄⠀⠀⠀⠀ A master species delegates.
[toc] | [prev] | [next] | [standalone]
| From | "Austin S. Hemmelgarn" <ahferroin7@gmail.com> |
|---|---|
| Date | 2017-07-10 14:40 +0200 |
| Message-ID | <u1G8P-53s-39@gated-at.bofh.it> |
| In reply to | #1683519 |
On 2017-07-07 23:07, Adam Borowski wrote: > On Sat, Jul 08, 2017 at 01:40:18AM +0200, Adam Borowski wrote: >> On Fri, Jul 07, 2017 at 11:17:49PM +0000, Nick Terrell wrote: >>> On 7/6/17, 9:32 AM, "Adam Borowski" <kilobyte@angband.pl> wrote: >>>> Got a reproducible crash on amd64: >> >>> Thanks for the bug report Adam! I'm looking into the failure, and haven't >>> been able to reproduce it yet. I've built my kernel from your tree, and >>> I ran your script with the kernel.tar tarball 100 times, but haven't gotten >>> a failure yet. >> >>> I have a few questions to guide my debugging. >>> >>> - How many cores are you running with? I’ve run the script with 1, 2, and 4 cores. >>> - Which version of gcc are you using to compile the kernel? I’m using gcc-6.2.0-5ubuntu12. >>> - Are the failures always in exactly the same place, and does it fail 100% >>> of the time or just regularly? >> >> 6 cores -- all on bare metal. gcc-7.1.0-9. >> Lemme try with gcc-6, a different config or in a VM. > > I've tried the following: > * gcc-6, defconfig (+btrfs obviously) > * gcc-7, defconfig > * gcc-6, my regular config > * gcc-7, my regular config > * gcc-7, debug + UBSAN + etc > * gcc-7, defconfig, qemu-kvm with only 1 core > > Every build with gcc-7 reproduces the crash, every with gcc-6 does not. > Got a GCC7 tool-chain built, and I can confirm this here too, tested with various numbers of cores ranging from 1-32 in a QEMU+KVM VM, with various combinations of debug options and other config switches.
[toc] | [prev] | [next] | [standalone]
| From | Nick Terrell <terrelln@fb.com> |
|---|---|
| Date | 2017-07-10 23:00 +0200 |
| Message-ID | <u1NWH-1rM-39@gated-at.bofh.it> |
| In reply to | #1684199 |
On 7/10/17, 5:36 AM, "Austin S. Hemmelgarn" <ahferroin7@gmail.com> wrote: > On 2017-07-07 23:07, Adam Borowski wrote: >> On Sat, Jul 08, 2017 at 01:40:18AM +0200, Adam Borowski wrote: >>> On Fri, Jul 07, 2017 at 11:17:49PM +0000, Nick Terrell wrote: >>>> On 7/6/17, 9:32 AM, "Adam Borowski" <kilobyte@angband.pl> wrote: >>>>> Got a reproducible crash on amd64: >>> >>>> Thanks for the bug report Adam! I'm looking into the failure, and haven't >>>> been able to reproduce it yet. I've built my kernel from your tree, and >>>> I ran your script with the kernel.tar tarball 100 times, but haven't gotten >>>> a failure yet. >>> >>>> I have a few questions to guide my debugging. >>>> >>>> - How many cores are you running with? I’ve run the script with 1, 2, and 4 cores. >>>> - Which version of gcc are you using to compile the kernel? I’m using gcc-6.2.0-5ubuntu12. >>>> - Are the failures always in exactly the same place, and does it fail 100% >>>> of the time or just regularly? >>> >>> 6 cores -- all on bare metal. gcc-7.1.0-9. >>> Lemme try with gcc-6, a different config or in a VM. >> >> I've tried the following: >> * gcc-6, defconfig (+btrfs obviously) >> * gcc-7, defconfig >> * gcc-6, my regular config >> * gcc-7, my regular config >> * gcc-7, debug + UBSAN + etc >> * gcc-7, defconfig, qemu-kvm with only 1 core >> >> Every build with gcc-7 reproduces the crash, every with gcc-6 does not. >> > Got a GCC7 tool-chain built, and I can confirm this here too, tested > with various numbers of cores ranging from 1-32 in a QEMU+KVM VM, with > various combinations of debug options and other config switches. I was running in an Ubuntu 16.10 VM on a MacBook Pro. I built with gcc-6.2 with KASAN, and couldn't trigger it, as expected. I built with gcc-7.1.0 built from source, and couldn't reproduce it. However, when I set up qemu-kvm on another device, and compiled with gcc-7.1.0 built from source, I was able to reproduce the bug. Now that I can reproduce it, I'll look into a fix. Thanks Adam and Austin for finding, reproducing, and verifying the bug.
[toc] | [prev] | [next] | [standalone]
| From | Nick Terrell <terrelln@fb.com> |
|---|---|
| Date | 2017-07-11 07:00 +0200 |
| Message-ID | <u1Vrc-68T-17@gated-at.bofh.it> |
| In reply to | #1684199 |
On 7/10/17, 5:36 AM, "Austin S. Hemmelgarn" <ahferroin7@gmail.com> wrote:
> On 2017-07-07 23:07, Adam Borowski wrote:
>> On Sat, Jul 08, 2017 at 01:40:18AM +0200, Adam Borowski wrote:
>>> On Fri, Jul 07, 2017 at 11:17:49PM +0000, Nick Terrell wrote:
>>>> On 7/6/17, 9:32 AM, "Adam Borowski" <kilobyte@angband.pl> wrote:
>>>>> Got a reproducible crash on amd64:
>>>
>>>> Thanks for the bug report Adam! I'm looking into the failure, and haven't
>>>> been able to reproduce it yet. I've built my kernel from your tree, and
>>>> I ran your script with the kernel.tar tarball 100 times, but haven't gotten
>>>> a failure yet.
>>>
>>>> I have a few questions to guide my debugging.
>>>>
>>>> - How many cores are you running with? I’ve run the script with 1, 2, and 4 cores.
>>>> - Which version of gcc are you using to compile the kernel? I’m using gcc-6.2.0-5ubuntu12.
>>>> - Are the failures always in exactly the same place, and does it fail 100%
>>>> of the time or just regularly?
>>>
>>> 6 cores -- all on bare metal. gcc-7.1.0-9.
>>> Lemme try with gcc-6, a different config or in a VM.
>>
>> I've tried the following:
>> * gcc-6, defconfig (+btrfs obviously)
>> * gcc-7, defconfig
>> * gcc-6, my regular config
>> * gcc-7, my regular config
>> * gcc-7, debug + UBSAN + etc
>> * gcc-7, defconfig, qemu-kvm with only 1 core
>>
>> Every build with gcc-7 reproduces the crash, every with gcc-6 does not.
>>
> Got a GCC7 tool-chain built, and I can confirm this here too, tested
> with various numbers of cores ranging from 1-32 in a QEMU+KVM VM, with
> various combinations of debug options and other config switches.
The problem is caused by a gcc-7 bug [1]. It miscompiles
ZSTD_wildcopy(void *dst, void const *src, ptrdiff_t len) when len is 0.
It only happens when it can't analyze ZSTD_copy8(), which is the case in
the kernel, because memcpy() is implemented with inline assembly. The
generated code is slow anyways, so I propose this workaround, which will
be included in the next patch set. I've confirmed that it fixes the bug for
me. This alternative implementation is also 10-20x faster, and compiles to
the same x86 assembly as the original ZSTD_wildcopy() with the userland
memcpy() implementation [2].
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81388#add_comment
[2] https://godbolt.org/g/q5YpLx
Signed-off-by: Nick Terrell <terrelln@fb.com>
---
lib/zstd/zstd_internal.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/zstd/zstd_internal.h b/lib/zstd/zstd_internal.h
index 6748719..ade0365 100644
--- a/lib/zstd/zstd_internal.h
+++ b/lib/zstd/zstd_internal.h
@@ -126,7 +126,9 @@ static const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
/*-*******************************************
* Shared functions to include for inlining
*********************************************/
-static void ZSTD_copy8(void *dst, const void *src) { memcpy(dst, src, 8); }
+static void ZSTD_copy8(void *dst, const void *src) {
+ ZSTD_write64(dst, ZSTD_read64(src));
+}
#define COPY8(d, s) \
{ \
ZSTD_copy8(d, s); \
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Nick Terrell <terrelln@fb.com> |
|---|---|
| Date | 2017-07-11 08:10 +0200 |
| Message-ID | <u1WwV-74G-9@gated-at.bofh.it> |
| In reply to | #1684774 |
On 7/10/17, 9:57 PM, "Nick Terrell" <terrelln@fb.com> wrote:
> The problem is caused by a gcc-7 bug [1]. It miscompiles
> ZSTD_wildcopy(void *dst, void const *src, ptrdiff_t len) when len is 0.
> It only happens when it can't analyze ZSTD_copy8(), which is the case in
> the kernel, because memcpy() is implemented with inline assembly. The
> generated code is slow anyways, so I propose this workaround, which will
> be included in the next patch set. I've confirmed that it fixes the bug for
> me. This alternative implementation is also 10-20x faster, and compiles to
> the same x86 assembly as the original ZSTD_wildcopy() with the userland
> memcpy() implementation [2].
>
> [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81388#add_comment
> [2] https://godbolt.org/g/q5YpLx
>
> Signed-off-by: Nick Terrell <terrelln@fb.com>
> ---
> lib/zstd/zstd_internal.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/zstd/zstd_internal.h b/lib/zstd/zstd_internal.h
> index 6748719..ade0365 100644
> --- a/lib/zstd/zstd_internal.h
> +++ b/lib/zstd/zstd_internal.h
> @@ -126,7 +126,9 @@ static const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
> /*-*******************************************
> * Shared functions to include for inlining
> *********************************************/
> -static void ZSTD_copy8(void *dst, const void *src) { memcpy(dst, src, 8); }
> +static void ZSTD_copy8(void *dst, const void *src) {
> + ZSTD_write64(dst, ZSTD_read64(src));
> +}
Sorry, my patch still triggered the gcc bug, I used the wrong compiler.
This patch works, and runs about the same speed as before the patch for
small inputs, and slightly faster for larger inputs (100+ bytes). I'll
look for a faster workaround if benchmarks show it matters.
Signed-off-by: Nick Terrell <terrelln@fb.com>
---
lib/zstd/zstd_internal.h | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/lib/zstd/zstd_internal.h b/lib/zstd/zstd_internal.h
index 6748719..839014d 100644
--- a/lib/zstd/zstd_internal.h
+++ b/lib/zstd/zstd_internal.h
@@ -139,12 +139,8 @@ static void ZSTD_copy8(void *dst, const void *src) { memcpy(dst, src, 8); }
#define WILDCOPY_OVERLENGTH 8
ZSTD_STATIC void ZSTD_wildcopy(void *dst, const void *src, ptrdiff_t length)
{
- const BYTE *ip = (const BYTE *)src;
- BYTE *op = (BYTE *)dst;
- BYTE *const oend = op + length;
- do
- COPY8(op, ip)
- while (op < oend);
+ if (length > 0)
+ memcpy(dst, src, length);
}
ZSTD_STATIC void ZSTD_wildcopy_e(void *dst, const void *src, void *dstEnd) /* should be faster for decoding, but strangely, not verified on all platform */
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Adam Borowski <kilobyte@angband.pl> |
|---|---|
| Date | 2017-07-12 05:40 +0200 |
| Message-ID | <u2gFk-2Ld-11@gated-at.bofh.it> |
| In reply to | #1684788 |
On Tue, Jul 11, 2017 at 06:01:38AM +0000, Nick Terrell wrote:
> On 7/10/17, 9:57 PM, "Nick Terrell" <terrelln@fb.com> wrote:
> > The problem is caused by a gcc-7 bug [1]. It miscompiles
> > ZSTD_wildcopy(void *dst, void const *src, ptrdiff_t len) when len is 0.
>
> Sorry, my patch still triggered the gcc bug, I used the wrong compiler.
> This patch works, and runs about the same speed as before the patch for
> small inputs, and slightly faster for larger inputs (100+ bytes). I'll
> look for a faster workaround if benchmarks show it matters.
Confirmed, the fix stops the crash for me. Yay!
> --- a/lib/zstd/zstd_internal.h
> +++ b/lib/zstd/zstd_internal.h
> @@ -139,12 +139,8 @@ static void ZSTD_copy8(void *dst, const void *src) { memcpy(dst, src, 8); }
> #define WILDCOPY_OVERLENGTH 8
> ZSTD_STATIC void ZSTD_wildcopy(void *dst, const void *src, ptrdiff_t length)
> {
> - const BYTE *ip = (const BYTE *)src;
> - BYTE *op = (BYTE *)dst;
> - BYTE *const oend = op + length;
> - do
> - COPY8(op, ip)
> - while (op < oend);
> + if (length > 0)
> + memcpy(dst, src, length);
> }
>
> ZSTD_STATIC void ZSTD_wildcopy_e(void *dst, const void *src, void *dstEnd) /* should be faster for decoding, but strangely, not verified on all platform */
--
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ A dumb species has no way to open a tuna can.
⢿⡄⠘⠷⠚⠋⠀ A smart species invents a can opener.
⠈⠳⣄⠀⠀⠀⠀ A master species delegates.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web