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 32A8BCE7CF4 for ; Tue, 1 Oct 2024 08:37:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7248028005B; Tue, 1 Oct 2024 04:37:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D40D280036; Tue, 1 Oct 2024 04:37:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FF3C28005B; Tue, 1 Oct 2024 04:37:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2C92B280036 for ; Tue, 1 Oct 2024 04:37:12 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BF88280B90 for ; Tue, 1 Oct 2024 08:37:11 +0000 (UTC) X-FDA: 82624378662.28.DD6CD02 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf02.hostedemail.com (Postfix) with ESMTP id 660C08000D for ; Tue, 1 Oct 2024 08:37:08 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="C/vywLpT"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=IqibOtaW; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="C/vywLpT"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=IqibOtaW; spf=pass (imf02.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727771701; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Wz6iF7VA/XvwkekcIHafjhP+48pOMPmGqg5ohl9g+/c=; b=8fpszeQYVMY55Gh0hGNS/wu+hSrLgou0D0uKR668VafrESgLxceV4x9ldH9biS8/kFd6Yd SIU3HhO0r+4EeQHKGbMc0YwErXXo3W9JvJNSP6lAnCBozoIjfniqR2CUgCY85pT3ndjrKC ygvrGofq1XK7nbiZBNXxzCl9aAOCDDs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727771701; a=rsa-sha256; cv=none; b=agsfsy+NkHJ+E6yi3Ga6+ODwlJQhupD9wzzXDn2cwhKolcyjKDm4nJKjWISh3h6lLH1slV mGHYb92uPn2Mjpg+YPCgSFhjGWgOWV3tAJ8mcNHDcqGmEKkGAwN17U9pgEhdqzR+ma8OPi 6ZhyIZ+bcwdMS0MX2Dpj9V8Deo9R+8I= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="C/vywLpT"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=IqibOtaW; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="C/vywLpT"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=IqibOtaW; spf=pass (imf02.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 910BB21AFE; Tue, 1 Oct 2024 08:37:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1727771826; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wz6iF7VA/XvwkekcIHafjhP+48pOMPmGqg5ohl9g+/c=; b=C/vywLpTeb8iVDIjG5slIvToARzmWXiYCXaqVwADoLhuFj09D0a1X/VUGGI59jnJxTJDWH rKSM4I7+lZRvtZOZy0VGvHKbfsGIdMk/RD+iAbDamLtMflSLPQmm8FZr8aJ2PnA7Oimb4a eszHU8HWWyCZKmmDqNgaD2ztK7qvuvQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1727771826; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wz6iF7VA/XvwkekcIHafjhP+48pOMPmGqg5ohl9g+/c=; b=IqibOtaW835sOiirqnRMWp3ZL/xLWkEV4m1N7vFcusweGOjSkGYMAKBJ8ZEEbu9LFlKMS2 PK1d/shX7dY2wyBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1727771826; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wz6iF7VA/XvwkekcIHafjhP+48pOMPmGqg5ohl9g+/c=; b=C/vywLpTeb8iVDIjG5slIvToARzmWXiYCXaqVwADoLhuFj09D0a1X/VUGGI59jnJxTJDWH rKSM4I7+lZRvtZOZy0VGvHKbfsGIdMk/RD+iAbDamLtMflSLPQmm8FZr8aJ2PnA7Oimb4a eszHU8HWWyCZKmmDqNgaD2ztK7qvuvQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1727771826; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wz6iF7VA/XvwkekcIHafjhP+48pOMPmGqg5ohl9g+/c=; b=IqibOtaW835sOiirqnRMWp3ZL/xLWkEV4m1N7vFcusweGOjSkGYMAKBJ8ZEEbu9LFlKMS2 PK1d/shX7dY2wyBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4347913A6E; Tue, 1 Oct 2024 08:37:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id VBOhD7K0+2bgLwAAD6G6ig (envelope-from ); Tue, 01 Oct 2024 08:37:06 +0000 Message-ID: <5ccae4ec-0b98-4f84-89be-9ba49f75e85e@suse.cz> Date: Tue, 1 Oct 2024 10:39:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH slab hotfixes 2/2] kunit: move call to kunit_run_all_tests() after rcu_end_inkernel_boot() To: Guenter Roeck , Andrew Morton , Christoph Lameter , David Rientjes , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: "Paul E. McKenney" , Boqun Feng , Uladzislau Rezki , rcu@vger.kernel.org, David Gow , Rae Moar , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Brendan Higgins References: <20240930-b4-slub-kunit-fix-v1-0-32ca9dbbbc11@suse.cz> <20240930-b4-slub-kunit-fix-v1-2-32ca9dbbbc11@suse.cz> <9dd56c26-12db-4b69-af0e-fdea33bb8208@roeck-us.net> From: Vlastimil Babka Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Stat-Signature: axqwrc5xxjbouziyepz9fnszufrhpmfg X-Rspamd-Queue-Id: 660C08000D X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727771828-20726 X-HE-Meta: U2FsdGVkX1/VroxavxSWqCkv3qFzYdNpk/ypEOtl0pdX0t7lfAUImGDtETeOEROSPA40DV6NdQVHhJ9EnuDl0cwSdtMaUUrZVqa4a1KhCDtAtxffiPhRA/fqDBcaDPslscN8QTR2+OesJYBuu4D6OpACCvR96zydGHHRc1/6OTyve62m84uTV1ctEAYr08INoPm6hpdEIiIUj95ur0wGYYzTVh9WTiOb+lf2LF5ULvh+Z0KX/uCPyhwbbJ9olNHXUccU/5hkQh6j3DfeulDP4WbZHNXRgScSX9qBXe6WTqHssHwxkGGAAtn2s+sGlV1h8TPl1SW3/lGf7ENoAUCVHWh/Qo+BumAk6+KA/Tj6gat7HK8YWlTtAB4++q6rY96OvnKe/89x8Hl4xjZy5kNg1BOsfxyEdxOnhMqH8kBUu4CSiPQMA3ale/hyVDaPE8xgtIYLsdapIhKg5qyE3H0gmr9QjpU448wbdbsh3L6cB2KTmQ/TzqPshDj4l/bfmWW/MVl5MavaG8FrnTSIOVBYzDzOvruzcXaS+7WdF79XrXpq3cfDLPYB9v9ZN1+S5QeEv1GiVv9gYpXkAyEoq0CEaaJnlrcP8oiEJo1Pyiu9qopaJXBBuEVmsS/PNE3lqB1FYbf8DfEEpRr8gUplSAgL2OjYlEd1G1pdnCrCGseZcBj0n6PVPseFW/H2WqFWIvap6iVIb82gv1C+rpexpJ0dI07s1i3t4J6exrUyS0X3DS5JeOJ3mbhghqKm8tpHe91yx/G/k2GqIH8njS8vqyfN1q3/2YawAP/pzqFY4ICvjnMHjy61Uz+QehAzeaURwPBCcjq3HhC49mRFGSFj40ZNVWugZJ24tuSgSnINLH3o3ROXbxo0mGrPfLOZ9nsgk3LvRZX6sJe2do/5odh0ysg3BkgrofPo0XN+279EJry9NOibTb4VyVWPxrZI1hMODqtONegRZ2lIjGbc/LygJCw VIyGS6zh Ead/H0/6vMkLAFBKMvJz8DDP0XurM/7/q6nn4j5O6C4BN8fWeilBl8el1nygdfbXBpWiJ/xkMEeYGoKYMxyhkGLSmp5xGWfBokWZZOnV4VrQCSPaFkPUU3OKWOHA+F3L20xL/HLRmbz2aPrhu+0QbpoW31g/OcU/g7Owb7fhjLiMT6bldraerMdY7aTMcyXlvQlUOOiSDWgvt4I6xjUP+QSkXXnHW+wiFMYs7EyzsvGj/OP4t/xwfppMnI7UzD6dN0ect/G54Q0uuYgVY8TgyQrSf2m13iDk1WOKJffCfYQYB20r9zDaEL3duwKeWjYEIFCVS/ZoBtUHYMXBidNWKqhyTmZDAxrTPf5Cu92inG5YsiERwS2pVn22dz1qXkbFQfGaiItqmDanayqBheuM2JYvF4tzkqGzzPIKhjRQGFdJFhatGsG/Akaru2vjy8POzXpSoTfESbP3UBtHt2xHt7JrM07SQWGF0ce2MdGkoomPiFNj8ZVRUG/WfgU8vBufc1acm4PYeKOUT+02OCrpltjYCYJOck/0eGUynhmBlG2YgZmGPDAZdAUGmULfKElJlp2BQ4w0aBRPEZvKNWWyBiZOwFJOsJw7vjBBv0EGrzsPJlyq97WNarXcqzg== 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: List-Subscribe: List-Unsubscribe: On 10/1/24 1:55 AM, Guenter Roeck wrote: > On 9/30/24 11:50, Guenter Roeck wrote: >> On 9/30/24 01:37, Vlastimil Babka wrote: >>> Guenter Roeck reports that the new slub kunit tests added by commit >>> 4e1c44b3db79 ("kunit, slub: add test_kfree_rcu() and >>> test_leak_destroy()") cause a lockup on boot on several architectures >>> when the kunit tests are configured to be built-in and not modules. >>> >>> These tests invoke kfree_rcu() and kvfree_rcu_barrier() and boot >>> sequence inspection showed the runner for built-in kunit tests >>> kunit_run_all_tests() is called before setting system_state to >>> SYSTEM_RUNNING and calling rcu_end_inkernel_boot(), so this seems like a >>> likely cause. So while I was unable to reproduce the problem myself, >>> moving the call to kunit_run_all_tests() a bit later in the boot seems >>> to have fixed the lockup problem according to Guenter's limited testing. >>> >>> No kunit tests should be broken by calling the built-in executor a bit >>> later, as when compiled as modules, they are still executed even later >>> than this. >>> > > Actually, that is wrong. > > Turns out kunit_iov_iter (and other kunit tests) are marked __init. > That means those unit tests have to run before the init code is released, > and it actually _is_ harmful to run the tests after rcu_end_inkernel_boot() > because at that time free_initmem() has already been called. Oh, guess that explains why the kunit_run_all_tests() executor is called so suspiciously early. Of course when built as modules, __init has a different lifetime. Guess I will just skip the two new tests using kfree_rcu() when the slub kunit is built-in then. Thanks for testing. > Guenter > >>> Fixes: 4e1c44b3db79 ("kunit, slub: add test_kfree_rcu() and >>> test_leak_destroy()") >>> Reported-by: Guenter Roeck >>> Closes: >>> https://lore.kernel.org/all/6fcb1252-7990-4f0d-8027-5e83f0fb9409@roeck-us.net/ >>> Cc: "Paul E. McKenney" >>> Cc: Boqun Feng >>> Cc: Uladzislau Rezki >>> Cc: rcu@vger.kernel.org >>> Cc: Brendan Higgins >>> Cc: David Gow >>> Cc: Rae Moar >>> Cc: linux-kselftest@vger.kernel.org >>> Cc: kunit-dev@googlegroups.com >>> Signed-off-by: Vlastimil Babka >>> --- >>>   init/main.c | 4 ++-- >>>   1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/init/main.c b/init/main.c >>> index >>> c4778edae7972f512d5eefe8400075ac35a70d1c..7890ebb00e84b8bd7bac28923fb1fe571b3e9ee2 100644 >>> --- a/init/main.c >>> +++ b/init/main.c >>> @@ -1489,6 +1489,8 @@ static int __ref kernel_init(void *unused) >>>       rcu_end_inkernel_boot(); >>> +    kunit_run_all_tests(); >>> + >>>       do_sysctl_args(); >>>       if (ramdisk_execute_command) { >>> @@ -1579,8 +1581,6 @@ static noinline void __init >>> kernel_init_freeable(void) >>>       do_basic_setup(); >>> -    kunit_run_all_tests(); >>> - >>>       wait_for_initramfs(); >>>       console_on_rootfs(); >>> >> Unfortunately it doesn't work. With this patch applied, I get many >> backtraces >> similar to the following, and ultimately the image crashes. This is >> with arm64. >> I do not see the problem if I drop this patch. >> >> Guenter >> >> --- >> [    9.465871]     KTAP version 1 >> [    9.465964]     # Subtest: iov_iter >> [    9.466056]     # module: kunit_iov_iter >> [    9.466115]     1..12 >> [    9.467000] Unable to handle kernel paging request at virtual >> address ffffc37db5c9f26c >> [    9.467244] Mem abort info: >> [    9.467332]   ESR = 0x0000000086000007 >> [    9.467454]   EC = 0x21: IABT (current EL), IL = 32 bits >> [    9.467576]   SET = 0, FnV = 0 >> [    9.467667]   EA = 0, S1PTW = 0 >> [    9.467762]   FSC = 0x07: level 3 translation fault >> [    9.467912] swapper pgtable: 4k pages, 48-bit VAs, >> pgdp=0000000042a59000 >> [    9.468055] [ffffc37db5c9f26c] pgd=0000000000000000, >> p4d=1000000044b36003, pud=1000000044b37003, pmd=1000000044b3a003, >> pte=0000000000000000 >> [    9.469430] Internal error: Oops: 0000000086000007 [#1] PREEMPT SMP >> [    9.469687] Modules linked in: >> [    9.470035] CPU: 0 UID: 0 PID: 550 Comm: kunit_try_catch Tainted: >> G                 N 6.12.0-rc1-00005-ga65e3eb58cdb #1 >> [    9.470290] Tainted: [N]=TEST >> [    9.470356] Hardware name: linux,dummy-virt (DT) >> [    9.470530] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO -DIT -SSBS >> BTYPE=--) >> [    9.470656] pc : iov_kunit_copy_to_kvec+0x0/0x334 >> [    9.471055] lr : kunit_try_run_case+0x6c/0x15c >> [    9.471145] sp : ffff800080883de0 >> [    9.471210] x29: ffff800080883e20 x28: 0000000000000000 x27: >> 0000000000000000 >> [    9.471376] x26: 0000000000000000 x25: 0000000000000000 x24: >> ffff80008000bb68 >> [    9.471501] x23: ffffc37db3f7093c x22: ffff80008000b940 x21: >> ffff545847af4c00 >> [    9.471622] x20: ffff545847cd3940 x19: ffff80008000bb50 x18: >> 0000000000000006 >> [    9.471742] x17: 6c61746f7420303a x16: 70696b7320303a6c x15: >> 0000000000000172 >> [    9.471863] x14: 0000000000020000 x13: 0000000000000000 x12: >> ffffc37db6a600c8 >> [    9.471983] x11: 0000000000000043 x10: 0000000000000043 x9 : >> 1fffffffffffffff >> [    9.472122] x8 : 00000000ffffffff x7 : 000000001040d4fd x6 : >> ffffc37db70c3810 >> [    9.472243] x5 : 0000000000000000 x4 : ffffffffc4653600 x3 : >> 000000003b9ac9ff >> [    9.472363] x2 : 0000000000000001 x1 : ffffc37db5c9f26c x0 : >> ffff80008000bb50 >> [    9.472572] Call trace: >> [    9.472636]  iov_kunit_copy_to_kvec+0x0/0x334 >> [    9.472740]  kunit_generic_run_threadfn_adapter+0x28/0x4c >> [    9.472835]  kthread+0x11c/0x120 >> [    9.472903]  ret_from_fork+0x10/0x20 >> [    9.473146] Code: ???????? ???????? ???????? ???????? (????????) >> [    9.473505] ---[ end trace 0000000000000000 ]--- >> >