From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B467C3DA78 for ; Tue, 17 Jan 2023 18:33:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20C4D6B0074; Tue, 17 Jan 2023 13:33:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E5CE6B0078; Tue, 17 Jan 2023 13:33:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0850C6B007B; Tue, 17 Jan 2023 13:33:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EB23A6B0074 for ; Tue, 17 Jan 2023 13:33:00 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BDC7EA05FC for ; Tue, 17 Jan 2023 18:33:00 +0000 (UTC) X-FDA: 80365137720.04.A859775 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by imf09.hostedemail.com (Postfix) with ESMTP id 9279214001D for ; Tue, 17 Jan 2023 18:32:58 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b="XCLE/+dW"; spf=pass (imf09.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.219.178 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673980379; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=t/Yj1dkETHJ3x/vd9B2cSXc0BtF92b0sf7AI+rPbVN0=; b=Cheto1JB15jooXIEBhjHzYM9+wfQP2GuddsUkXxDrMiSlhv9MUb+edNxqw6y/Av5bB4O76 Rokvpap39n4mqehsJ3VK9+pddIqf+hAi3JUUtMo1S9MP465rGknZawQk+z2y9USiohPT5j mJ6ivu5eB0antzqhFXgyNNIMXBTZ9nA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b="XCLE/+dW"; spf=pass (imf09.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.219.178 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673980379; a=rsa-sha256; cv=none; b=ufwexkDbpm64czE+oAZCEjb9hoI1sUTtvZdJrD0D5aeVvIMNG0R9EpKYOO4KKMBzCEBNnd 71ALbKYL584KsXEjCLHdPtNG3BgyEY4zK+wHDXBDW688Zf/maKYoig7ooQwp01TK7wb61P BfUQlzNpJZzzd3hfVW4X1FMNiX0Qt30= Received: by mail-yb1-f178.google.com with SMTP id e202so11812767ybh.11 for ; Tue, 17 Jan 2023 10:32:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=t/Yj1dkETHJ3x/vd9B2cSXc0BtF92b0sf7AI+rPbVN0=; b=XCLE/+dWnhPFHp0Rjc45XkkaJtd/3aeBb1T0m6KOH6FOQ3duqOHkSne6Erdt0xqRvR LQe+kifp9lcJdtA03kTU5SGMsqQugmGdSLpd2Q2WTVkHIhWK7chONEMxksCRtnlBR/+e GyV+R9HcOZ5gfXDs6DPbyI/iCP1P/BakruKyk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=t/Yj1dkETHJ3x/vd9B2cSXc0BtF92b0sf7AI+rPbVN0=; b=hfL54S8r8Q9I9Xq1idgct6trHKpyehSS3RM+E1+SAxPZsabUkQZBY4TAlP6tlAthu/ Kz+3aPh9Wi9+apoUc3vALsMKyY7cBmqFfumXsnTkbhuSK+IzmJI2vpxO7ZA8MkZQOu07 FeGuHw+v7MNQ6ZhNa0egpYYlDG+LxU9Cxjmcmzn6HZnSJdcyXEuKhcOvuHD/e05vDGIP KjcDnGCcc+R41ciBdYz7su/+s9Trm5f+qyY1Khnc6RORzj9o7GilybUllER3M6pn7YhX Et8pueOZHpWeRmcFkfJd0LjglPWdR/iTCssJkGDpIqzS395j7B9B2Fz4QNJTvdJJrmqF BHrA== X-Gm-Message-State: AFqh2kqWF5u9ejzsBwhOsIAHdJXSd+cy7ANfMj3Mzmmh1N9w9oCWXatF w6p6uIWkV9draYjwCLYnur7eg8gIAHmKdVmq X-Google-Smtp-Source: AMrXdXtpv01BqYv+t606L5Q1An4eQHPf76vX3rV0cpi+1DGGh3LWKDRaBgayot2cvV2o0Mezg/oifA== X-Received: by 2002:a25:9783:0:b0:7d2:17ba:8a08 with SMTP id i3-20020a259783000000b007d217ba8a08mr3728925ybo.50.1673980377457; Tue, 17 Jan 2023 10:32:57 -0800 (PST) Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com. [209.85.160.170]) by smtp.gmail.com with ESMTPSA id 64-20020a370c43000000b006cfc1d827cbsm20384500qkm.9.2023.01.17.10.32.57 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Jan 2023 10:32:57 -0800 (PST) Received: by mail-qt1-f170.google.com with SMTP id o5so6936992qtr.11 for ; Tue, 17 Jan 2023 10:32:57 -0800 (PST) X-Received: by 2002:a37:4651:0:b0:705:b232:4ed9 with SMTP id t78-20020a374651000000b00705b2324ed9mr143177qka.216.1673979933694; Tue, 17 Jan 2023 10:25:33 -0800 (PST) MIME-Version: 1.0 References: <202301170941.49728982-oliver.sang@intel.com> <2f483247-da76-9ec9-3e51-f690939f4585@suse.cz> In-Reply-To: From: Linus Torvalds Date: Tue, 17 Jan 2023 10:25:17 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [linus:master] [hugetlb] 7118fc2906: kernel_BUG_at_lib/list_debug.c To: Feng Tang Cc: Vlastimil Babka , "Sang, Oliver" , Mike Kravetz , "oe-lkp@lists.linux.dev" , lkp , "linux-kernel@vger.kernel.org" , Jann Horn , "Song, Youquan" , Andrea Arcangeli , Jan Kara , John Hubbard , "Kirill A . Shutemov" , Matthew Wilcox , Michal Hocko , Muchun Song , Andrew Morton , "linux-mm@kvack.org" , Hyeonggon Yoo <42.hyeyoo@gmail.com>, "Yin, Fengwei" , hongjiu.lu@intel.com Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9279214001D X-Stat-Signature: hsqfrrjq5sqkpktasun1zp6a7f4euwzk X-Rspam-User: X-HE-Tag: 1673980378-623194 X-HE-Meta: U2FsdGVkX18nC1gaFMc4vjEr+pYWzXrVlrsi2KIQT8jVDsUqjKgnPUWeIBIX35zL3USboHdKrWOWsITFTyi7WSfjoZKfxmjWc+1CPVj5pjFPbMnMdqibRq9D6o2Cvl6z7jyLI4TXFMyceGlp9UtM4RcMctCJNk5Lu3yFiITjlxFjuuEd8G6vWr8jtUHNfo6MwFrXOAWT7NFu6DD8omA/Fl+ubUrksRQHiCtRHLLI7dsukQXj4PUdT9ywqOBUeXZdLuo490/afztT6ZyAG43lYRCPlWQZrZdOgvV69nmB+aowcrL8qaVqLDJTyO4cgsKHpbTU8cWFKrjJHO7Hy1Aj6fZxV9LarpDmadrWtG0Wuf5qTMuSoJmob7EtbgLrYkijtuHGaXToHshy27S2SjlXOf1PpNlAEPpPsx28PiYUhSXIgQCzfoXlpi1g+Bg0qFTgx1wrF1ULkYd8Kifr7nQ9E4euvS9ALR7R4PN9fJpnKu3AvpHEXYjPOj7ji1ljgT2qIJGPsCspLl1ZCZD/aEXqDWZyHyYp7Q9U9JV+8MXR6yeI5ASsoYhCgeqEg5u2ISYUFljJzVKzBq1CP7QqUljN5/s1i88C+P01AnONDyztsBUmqACa0J2W716X17XBrbbXkwEX5i/cLIJWFsRYVpdHQZjvf9rke/UkZwLxzh6LSeS/t0muHCKILd7HJBsvT9uNPQn3CD8VeuAGsQanEs/6WFGRuPXz3kSduonC3pVsH8v5J80WTWAjEcsNkC7tyLXPdvNvRvuKzUaUiwsV3zDGyJWQ0wEs3+VvXE8jUMlZyfBpwVnpWJTJHsj9mjTpU8XTSppazPY6p86t99xmj3YpX1K/A1phTn0t/SnStOivlJDXqvvLh/YbEMA/aMyygEY0PHNpJG8Le56XffOg6weDsf1DD+1c4Fc310Kncc4sF8qlPl/H4ltWoGhRd6x9nrm0qXhQIaguQ3vi7CzVpIe JNfTIYLA rDfVqc6PZtvdxWBx/ktNIBzty5G/gUsLpko0OV8A/UC4qGlPYpMI60l/xMrtBIcfHsFys5frQvGyFGnF+5MGF5gYZrbSS9aQy9a9hGQ743PS3DhwDKUG/9ULSsVgaJczhi93avxfU17SdwBiN3GJ0Pymqui/TK4MR/MlgmlXXVrvLA5eCkbQyPbW/OeSpxL8jOXlFgMkrulI39AzJCUKKopEO1R6xN0ff15udDJvmaHKTzIjCCfXOy7tlRFJgYf5X3riz0REeXor/JVPxtPgE1AsjWDanUswuvrDiLu1k5mk5WyX0iBskswDmUXS7K8bzu4ACPJNy0y+6vHuBOl0rWfw8wYEcpMp6Auwn4EuEV4D1howYMH8ncLX9u0spnvSeaXoAkS3RCf9Uct6yYIk+LDewqcBEn+Ns2J94jhJm07kwsDZkEVweFW3zbEGqkqMMyEvz X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Jan 17, 2023 at 4:22 AM Feng Tang wrote: > > With the following patch to use 'O1' instead 'O2' gcc optoin for > page_alloc.c, the list corruption issue can't be reproduced for > commit 7118fc2906 in 1000 runs. Ugh. It would be lovely if you could just narrow it down with #pragma GCC optimize ("O1") ... #pragma GCC optimize ("O2") around just that prep_compound_page(), but when I tried it myself I get some function attribute mismatch errors. > As is can't be reproduced with X86_64 build, it could be i386 > compiling related. Your particular config causes a huge amount of nasty 64-bit arithmetic according to the objdump code, with sequences like c13b3cbb: 83 05 d0 28 6c c5 01 addl $0x1,0xc56c28d0 c13b3cc2: 83 15 d4 28 6c c5 00 adcl $0x0,0xc56c28d4 which seems to be just from some coverage profiling being on (CONFIG_GCOV?), or something. It makes it very hard to read the code. You also have UBSAN enabled, which - again - makes for some really grotty asm that hides any actual logic. Finally, your objdump version also does some horrendous decoding, like c13b3e29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi which is just a 7-byte 'nop' instruction, but again, it makes it rather hard to actually read the code. With the i386 defconfig, gcc generates a function that is just ~30 instructions for me, so this makes a huge difference in the legibility of the code. I wonder if you can recreate the issue with a much more straightforward config. By all means, leave DEBUG_PAGEALLOC and SLUB debugging on, but without the things like UBSAN and GCOV. > I also objdumped 'prep_compound_page' for vmlinux of 7118fc2906 and > its parent commit 48b8d744ea84, which have big difference than the > simple 'set_page_count()' change, but I can't tell which part is > abnormal, so attach them for further check. Yeah, I can't make heads or tails of them either, see above on how illegible the objdump files are. And that's despite not even having all of prep_compound_page() in them (it's missing prep_compound_page.cold, which is probably just UBSAN fixup code, but who knows..) That said, with the i386 defconfig, the only change from adding set_page_count() to the loop seems to be exactly that: .L589: - movl $1024, 12(%eax) + movl $0, 28(%eax) addl $32, %eax + movl $1024, -20(%eax) movl %esi, -28(%eax) movl $0, -12(%eax) cmpl %edx, %eax (don't ask me why gcc does *one* access using the pre-incremented pointer, and then the rest to the post-incremented ones, but whatever - it means that it's not just "add a mov $0", it's also changing how the p->mapping = TAIL_MAPPING; instruction is done, which is that - movl $1024, 12(%eax) + movl $1024, -20(%eax) part of the change) Linus