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 859E3C021B8 for ; Tue, 25 Feb 2025 18:21:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 020B96B0093; Tue, 25 Feb 2025 13:21:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F12E4280003; Tue, 25 Feb 2025 13:21:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8C2A6B0096; Tue, 25 Feb 2025 13:21:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 742AE6B0093 for ; Tue, 25 Feb 2025 13:21:29 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 957F11CB1F8 for ; Tue, 25 Feb 2025 18:21:28 +0000 (UTC) X-FDA: 83159284656.23.1F43932 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by imf09.hostedemail.com (Postfix) with ESMTP id BCF7814000E for ; Tue, 25 Feb 2025 18:21:25 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=doPNLYg5; spf=pass (imf09.hostedemail.com: domain of urezki@gmail.com designates 209.85.208.178 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740507686; 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=LM39+n13BPvn+J2rcwr32WzrTD41uNSLl8+j9j8BSvA=; b=aBW+vCchkM5LbCMtjZw5EsgC85Dfeomjk8fdt33HCqOJb/enm/FBJraSpMpjdy3J4HZCeO fnOGRUj07dcXMg8PB2Y9+lB9xAClEmlU1lAKXHuwnGP099LlNdZbZyrH2BupQ0HYSROYNo zLS9ao6LY/ZAL9pSxe6qSRrdZl3aI8o= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=doPNLYg5; spf=pass (imf09.hostedemail.com: domain of urezki@gmail.com designates 209.85.208.178 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740507686; a=rsa-sha256; cv=none; b=s95XWQKEvEFu0ogvyvuTk1NSo+EpafkDRCT6Z+dlHpHc8kP5hl6ReUbTOKyoSo4l90d4g+ JvvC8/QIF/FVUIywIBpYuxWFbOSMryWBvOD9KlB0yl440dgD0LrZ7nbZfD2S+3+eI5f3qy fJleAJraMOQyedcN1ivVkcZdj8/nNzE= Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-30615661f98so57085261fa.2 for ; Tue, 25 Feb 2025 10:21:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740507683; x=1741112483; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=LM39+n13BPvn+J2rcwr32WzrTD41uNSLl8+j9j8BSvA=; b=doPNLYg5KD6QxG4ZCrugN5uRa1gfkZF4V17MVVcl+Bgj4+6EOOx8FHjfyoZbNNt+Zq hlF7ikfSVwhIgSERNCUDYjid6tbwFHppqzzPI2C8sAUTtrlPM7FcIn/JTSCFLgVbpqT+ pobMex2944hlj5qF8JRu2/xpfh+Rg7nfZgET4fAt1ZE1KL9YVhchjejOjiGcDvv83JxM WNpX7FAFzf8NBWegfi+IOW82TSyGdm5faGxd5LM12pCcBOzrHPUFgfgyv5xk3787k0WK +IJ9SJeggSJ9k77+KeRnReSQg1cNlORoHVaLghpEnqJN21skP3GvtMe6QCSMVu7lZBCG L8qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740507683; x=1741112483; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LM39+n13BPvn+J2rcwr32WzrTD41uNSLl8+j9j8BSvA=; b=NByJjJESlLtDydUPnKOLMexnTv/vbtw071STltFso6pA8I48RyZY3hnaNx3hWwcJ7h dfXPsYUncD/1Gmj5fV0wtM2ZDO1e0pMf1vuFLG/nvrNU6GWmHWWtmKwjViQEBYx/7dGr 1I6wpNmk6Q+mOfJlnhJRADCO3ym/MoKms2Oq0vr5hfkRobItIBhvSk/cCkEtx81lRCD/ +bAxoLjDs3032qumuhSIBfo6GPGn0w6usxH9iLCsVoLGrFdKMilW5RaLe2xgs5rZnKLj GLAzKnNGu9l7tU8YNb9JzrjUkfTxq0WOLNVH/dNHcUeC7daYSgE5Vo9VcRIQ2SGKHd8E q6mw== X-Forwarded-Encrypted: i=1; AJvYcCXxmUVOqUJ0pJJDNI1gJRyrrQ+TklXMknVnQu1PbydgGMnRX5zoW9XTXyi+WG/gGo8j96SkTghq/w==@kvack.org X-Gm-Message-State: AOJu0YzJva6WMiFKWa6/riUgO2nSulovQgD6FghRCh+zLeDfb1slleS2 /vyJW1bEoK/lvWYCQyVE0zLuzffiG6mMZfZoxKaPg24DT7NH8NsbViaRQGo6 X-Gm-Gg: ASbGncuq+5eXz0xIaaetS7uk/eFt7GHKnwArJrhu4Qs0j1Xwa2Qh3CHS+ouLjtmcIav BIHNU7B768UMVjPc/dRR7JjXlbSJhuPyQxFUZzLTWTcAbiSh5bhwnEw+hxqd3RhV+Fc5B5kAMg3 ZFGTDm5Ehkol+UTNmNtwBGzT2LNVZ1ydWO/ltUKK/7SD7ciemUXh9YB57dwiiZ1piGGk5aa9xZU tGl40rVCZBi52OV6s+NXltSCz9GER+TfHiasydLjZN3X3lJpHFRmik/JDSkxGPYdCWRz5lvxISo y1UgH+UK1YyapGc5Ye6vBCD/WroSOwpgEnSX9+jDoV5xlDiY X-Google-Smtp-Source: AGHT+IFoRObJBmJo9tEE6zKnPjMDesmLGd9MWFxr0CK/4CAxinoSjkausHa4uzqAObVBev170EdBPA== X-Received: by 2002:a2e:860e:0:b0:306:10d6:28a5 with SMTP id 38308e7fff4ca-30a80c0ede0mr21557411fa.1.1740507683218; Tue, 25 Feb 2025 10:21:23 -0800 (PST) Received: from pc636 (host-95-203-6-24.mobileonline.telia.com. [95.203.6.24]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-30a819ebffesm2996571fa.43.2025.02.25.10.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2025 10:21:22 -0800 (PST) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Tue, 25 Feb 2025 19:21:19 +0100 To: Keith Busch , Vlastimil Babka Cc: Keith Busch , Vlastimil Babka , "Paul E. McKenney" , Joel Fernandes , Josh Triplett , Boqun Feng , Christoph Lameter , David Rientjes , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Julia Lawall , Jakub Kicinski , "Jason A. Donenfeld" , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org, Alexander Potapenko , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Jann Horn , Mateusz Guzik , linux-nvme@lists.infradead.org, leitao@debian.org Subject: Re: [PATCH v2 6/7] mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy() Message-ID: References: <20240807-b4-slab-kfree_rcu-destroy-v2-0-ea79102f428c@suse.cz> <20240807-b4-slab-kfree_rcu-destroy-v2-6-ea79102f428c@suse.cz> <2811463a-751f-4443-9125-02628dc315d9@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Queue-Id: BCF7814000E X-Stat-Signature: 75h81pzj757g5iazctqxrgfpt6ks1s7t X-Rspamd-Server: rspam03 X-HE-Tag: 1740507685-581927 X-HE-Meta: U2FsdGVkX1+e3PNELxweaHcML7g6qAAaweEh0Q+N4j2cxHlslNMa7z+kkpbri+VPkMLfGkMnBJABucmogM0OhZaLaH0rmI4c7kriYZuU96TtSRHlecKvPNY0rVBoMyXmXFw51oNTR2fAls0hIRi3rfDKHQMC1iDKy0FtYwmRYLSmoT0Wyp4K3holQJtrl6aNehztKfHoq0PabGIYDSXmidZJeujU1A6TH7Y4rcbcmzKlQ85PYq2zleeAWSh1mH5wT03Pr8OuJwZJOARzAzI/IEQWJO7lnESoteNcHVWrK3VicQxRRymMuTPOgDcQexf8iXEZ1+o+CAqgD6sTud3NLGm6MFLoo2+AWkVt+s8RV5v918zL80Yopc5bayc/D4ds4D4h1vgDX4103A1SxWeqPjyLMWGBLfSUIFw1C3vdYAy4ibQy1BoMsdGas0tjzjxfQvxv7Dc3CS2Vxv/q/Jppt8KJ4CL4AoIsXY1KJCEeBmlGLDZDNJDfb6wwgxanaH9h/iB/EQjzAO5KaIuLEfaJX1Cpes3BRmgmblCyQt4kOcgxyB0nd+ZK9YyaklCIjyOrqja4vTAnlVtprJCt5hAbrgP2UTQz0Y31s+BphY08Uf8Spqr5PHfgudAzCAjAjU1Hp51QF0n7L9nZ5dXRa6zB9gDBj1Gc8ihAQaRKdwm2W5wgW/lrkPbD8g7rmuCLLEjeQVW3tz2cv2VGHrXSR+uGGH3hPe0D9GSidQ8UzJ4U12wlQu5LQZykrb8rOWIrdS6Mq9xLL0cLfJ7SrKeII+a8RJqrgrLkznyhby6CAP0V58LSKEjREMRL3mLW2P7ppH5v0Rk9VDOwukNQ5BnKqm00bKoxkdUL7LO24k4MD1aeSP+/6VuElyAV95miWu31+2adIaLt1pzkWKKLoKK8SGkxkWuRDEe1ugUIuXbEWV1tbqiBeXjBlYZXGmtL5Zkw4pIQb+m4SLCjybHrV0tNq0K /0x8gOrQ ZTuSbmCULhF2Mtkyj48XGfCv0OTppIbT1OACBSFZ0mkc6rs+bVY2YwHRyMVX8sG9ac1AXagMACf6aZ4bUxpzGYhdyOLMCZQtaAzgvzEbFQGhWBTwaujW7IbyLskVCQkfO4OOD0us8YXzpjzqiMbTKD5fLFfW6R9TZf2l2OX0PdwECJwbPJ1Nsvk8/T/CK3lIbxZZQygViPLXS8wV7STD9bcnL7RE5z6FfswRtYekwDC0YCIxxe9IUhZTkhpznsO0971XvwuH5mf2Y8vTR4OaNTsEgIOGK0UgAQ2C3WwjnhYy2l6vIxfZOJQrjZQBhsoxuAnGOrp8ATvcSWDOcHC7rjVqU+j0qi6qny21eA4hfizou9Fjnunz2tYknWf9PIxxJYG2lMqdTK7gzGeIH6l+aoqLRY6OhJZybLi35VFhjZLUWM1i9AD+zhAiqgFKHkREdMYfZreH72DSv6mpn3t6s9lVjoREqdsQB69zC1kojQ9m1RupcIt+S0LdNVurhqUo1oV3YuBfF/UkOCGG3W9KXrThoZFSLt73EOtOao3aSxUnZyrPZMtQ0nOiNkfMLJHk56HNx 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 Tue, Feb 25, 2025 at 06:41:19PM +0100, Uladzislau Rezki wrote: > On Tue, Feb 25, 2025 at 10:05:37AM -0700, Keith Busch wrote: > > On Tue, Feb 25, 2025 at 09:03:38AM -0700, Keith Busch wrote: > > > On Tue, Feb 25, 2025 at 10:57:38AM +0100, Vlastimil Babka wrote: > > > > I tried to create a kunit test for it, but it doesn't trigger anything. Maybe > > > > it's too simple, or racy, and thus we are not flushing any of the queues from > > > > kvfree_rcu_barrier()? > > > > > > Thanks, your test readily triggers it for me, but only if I load > > > rcutorture at the same time. > > > > Oops, I sent the wrong kernel messages. This is the relevant part: > > > > [ 142.371052] workqueue: WQ_MEM_RECLAIM > > test_kfree_rcu_destroy_wq:cache_destroy_workfn [slub_kunit] is > > flushing !WQ_MEM_RECLAIM events_unbound:kfree_rcu_work > > [ 142.371072] WARNING: CPU: 11 PID: 186 at kernel/workqueue.c:3715 > > check_flush_dependency.part.0+0xad/0x100 > > [ 142.375748] Modules linked in: slub_kunit(E) rcutorture(E) > > torture(E) kunit(E) iTCO_wdt(E) iTCO_vendor_support(E) > > intel_uncore_frequency_common(E) skx_edac_common(E) nfit(E) > > libnvdimm(E) kvm_intel(E) kvm(E) evdev(E) bochs(E) serio_raw(E) > > drm_kms_helper(E) i2c_i801(E) e1000e(E) i2c_smbus(E) intel_agp(E) > > intel_gtt(E) lpc_ich(E) agpgart(E) mfd_core(E) drm_shm] > > [ 142.384553] CPU: 11 UID: 0 PID: 186 Comm: kworker/u64:11 Tainted: G > > E N 6.13.0-04839-g5e7b40f0ddce-dirty #831 > > [ 142.386755] Tainted: [E]=UNSIGNED_MODULE, [N]=TEST > > [ 142.387849] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), > > BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014 > > [ 142.390236] Workqueue: test_kfree_rcu_destroy_wq > > cache_destroy_workfn [slub_kunit] > > [ 142.391863] RIP: 0010:check_flush_dependency.part.0+0xad/0x100 > > [ 142.393183] Code: 75 dc 48 8b 55 18 49 8d 8d 78 01 00 00 4d 89 f0 > > 48 81 c6 78 01 00 00 48 c7 c7 00 e1 9a 82 c6 05 4f 39 c5 02 01 e8 53 > > bd fd ff <0f> 0b 5b 5d 41 5c 41 5d 41 5e c3 80 3d 39 39 c5 02 00 75 83 > > 41 8b > > [ 142.396981] RSP: 0018:ffffc900007cfc90 EFLAGS: 00010092 > > [ 142.398124] RAX: 000000000000008f RBX: ffff88803e9b10a0 RCX: 0000000000000027 > > [ 142.399605] RDX: ffff88803eba0d08 RSI: 0000000000000001 RDI: ffff88803eba0d00 > > [ 142.401092] RBP: ffff888007d9a480 R08: ffffffff83b8c808 R09: 0000000000000003 > > [ 142.402548] R10: ffffffff8348c820 R11: ffffffff83a11d58 R12: ffff888007150000 > > [ 142.404098] R13: ffff888005961400 R14: ffffffff813221a0 R15: ffff888005961400 > > [ 142.405561] FS: 0000000000000000(0000) GS:ffff88803eb80000(0000) > > knlGS:0000000000000000 > > [ 142.407297] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > > [ 142.408658] CR2: 00007f826bd1a000 CR3: 00000000069db002 CR4: 0000000000772ef0 > > [ 142.410259] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > > [ 142.411871] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > > [ 142.413341] PKRU: 55555554 > > [ 142.414038] Call Trace: > > [ 142.414658] > > [ 142.415249] ? __warn+0x8d/0x180 > > [ 142.416035] ? check_flush_dependency.part.0+0xad/0x100 > > [ 142.417182] ? report_bug+0x160/0x170 > > [ 142.418041] ? handle_bug+0x4f/0x90 > > [ 142.418861] ? exc_invalid_op+0x14/0x70 > > [ 142.419853] ? asm_exc_invalid_op+0x16/0x20 > > [ 142.420877] ? kfree_rcu_shrink_scan+0x120/0x120 > > [ 142.422029] ? check_flush_dependency.part.0+0xad/0x100 > > [ 142.423244] __flush_work+0x38a/0x4a0 > > [ 142.424157] ? find_held_lock+0x2b/0x80 > > [ 142.425070] ? flush_rcu_work+0x26/0x40 > > [ 142.425953] ? lock_release+0xb3/0x250 > > [ 142.426785] ? __mutex_unlock_slowpath+0x2c/0x270 > > [ 142.427906] flush_rcu_work+0x30/0x40 > > [ 142.428756] kvfree_rcu_barrier+0xe9/0x130 > > [ 142.429649] kmem_cache_destroy+0x2b/0x1f0 > > [ 142.430578] cache_destroy_workfn+0x20/0x40 [slub_kunit] > > [ 142.431729] process_one_work+0x1cd/0x560 > > [ 142.432620] worker_thread+0x183/0x310 > > [ 142.433487] ? rescuer_thread+0x330/0x330 > > [ 142.434428] kthread+0xd8/0x1d0 > > [ 142.435248] ? ret_from_fork+0x17/0x50 > > [ 142.436165] ? lock_release+0xb3/0x250 > > [ 142.437106] ? kthreads_online_cpu+0xf0/0xf0 > > [ 142.438133] ret_from_fork+0x2d/0x50 > > [ 142.439045] ? kthreads_online_cpu+0xf0/0xf0 > > [ 142.440428] ret_from_fork_asm+0x11/0x20 > > [ 142.441476] > > [ 142.442152] irq event stamp: 22858 > > [ 142.443002] hardirqs last enabled at (22857): [] > > _raw_spin_unlock_irq+0x24/0x30 > > [ 142.445032] hardirqs last disabled at (22858): [] > > _raw_spin_lock_irq+0x43/0x50 > > [ 142.451450] softirqs last enabled at (22714): [] > > __irq_exit_rcu+0xac/0xd0 > > [ 142.453345] softirqs last disabled at (22709): [] > > __irq_exit_rcu+0xac/0xd0 > > [ 142.455305] ---[ end trace 0000000000000000 ]--- > Thanks! > > I can trigger this also: > > > [ 21.712856] KTAP version 1 > [ 21.712862] 1..1 > [ 21.714486] KTAP version 1 > [ 21.714490] # Subtest: slub_test > [ 21.714492] # module: slub_kunit > [ 21.714495] 1..10 > [ 21.750359] ok 1 test_clobber_zone > [ 21.750955] ok 2 test_next_pointer > [ 21.751532] ok 3 test_first_word > [ 21.751991] ok 4 test_clobber_50th_byte > [ 21.752493] ok 5 test_clobber_redzone_free > [ 21.753004] stackdepot: allocating hash table of 1048576 entries via kvcalloc > [ 21.756176] ok 6 test_kmalloc_redzone_access > [ 21.806549] ok 7 test_kfree_rcu > [ 22.058010] ------------[ cut here ]------------ > [ 22.058015] workqueue: WQ_MEM_RECLAIM test_kfree_rcu_destroy_wq:cache_destroy_workfn [slub_kunit] is flushing !WQ_MEM_RECLAIM events_unbound:kfree_rcu_work > [ 22.058039] WARNING: CPU: 19 PID: 474 at kernel/workqueue.c:3715 check_flush_dependency.part.0+0xbe/0x130 > [ 22.058047] Modules linked in: slub_kunit(E) kunit(E) binfmt_misc(E) bochs(E) drm_client_lib(E) drm_shmem_helper(E) ppdev(E) drm_kms_helper(E) snd_pcm(E) sg(E) snd_timer(E) evdev(E) snd(E) joydev(E) parport_pc(E) parport(E) soundcore(E) serio_raw(E) button(E) pcspkr(E) drm(E) fuse(E) dm_mod(E) efi_pstore(E) configfs(E) loop(E) qemu_fw_cfg(E) ip_tables(E) x_tables(E) autofs4(E) ext4(E) crc16(E) mbcache(E) jbd2(E) sr_mod(E) sd_mod(E) cdrom(E) ata_generic(E) ata_piix(E) libata(E) scsi_mod(E) i2c_piix4(E) psmouse(E) e1000(E) i2c_smbus(E) scsi_common(E) floppy(E) > [ 22.058091] CPU: 19 UID: 0 PID: 474 Comm: kworker/u257:0 Kdump: loaded Tainted: G E N 6.14.0-rc1+ #286 > [ 22.058096] Tainted: [E]=UNSIGNED_MODULE, [N]=TEST > [ 22.058097] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 > [ 22.058099] Workqueue: test_kfree_rcu_destroy_wq cache_destroy_workfn [slub_kunit] > [ 22.058103] RIP: 0010:check_flush_dependency.part.0+0xbe/0x130 > [ 22.058106] Code: 75 d0 48 8b 55 18 49 8d 8d c0 00 00 00 4d 89 f0 48 81 c6 c0 00 00 00 48 c7 c7 b0 7d c8 bd c6 05 6c 78 53 01 01 e8 a2 ae fd ff <0f> 0b 5b 5d 41 5c 41 5d 41 5e c3 cc cc cc cc f6 c4 08 74 94 31 ed > [ 22.058108] RSP: 0018:ffff95e5c123fd50 EFLAGS: 00010086 > [ 22.058111] RAX: 0000000000000000 RBX: ffff89a4ff22d5a0 RCX: 0000000000000000 > [ 22.058113] RDX: 0000000000000003 RSI: ffffffffbdce1697 RDI: 00000000ffffffff > [ 22.058114] RBP: ffff89961043a780 R08: 0000000000000000 R09: 0000000000000003 > [ 22.058116] R10: ffff95e5c123fbe8 R11: ffff89a53fefefa8 R12: ffff89960cb6b080 > [ 22.058117] R13: ffff899600051400 R14: ffffffffbcf2ba80 R15: ffff89960005a800 > [ 22.058120] FS: 0000000000000000(0000) GS:ffff89a4ff2c0000(0000) knlGS:0000000000000000 > [ 22.058122] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > [ 22.058124] CR2: 000055bf2cbc6038 CR3: 000000010dc1e000 CR4: 00000000000006f0 > [ 22.058128] Call Trace: > [ 22.058130] > [ 22.058133] ? __warn+0x85/0x130 > [ 22.058137] ? check_flush_dependency.part.0+0xbe/0x130 > [ 22.058139] ? report_bug+0x18d/0x1c0 > [ 22.058142] ? prb_read_valid+0x17/0x20 > [ 22.058147] ? handle_bug+0x58/0x90 > [ 22.058151] ? exc_invalid_op+0x13/0x60 > [ 22.058154] ? asm_exc_invalid_op+0x16/0x20 > [ 22.058158] ? __pfx_kfree_rcu_work+0x10/0x10 > [ 22.058162] ? check_flush_dependency.part.0+0xbe/0x130 > [ 22.058165] __flush_work+0xd6/0x320 > [ 22.058168] flush_rcu_work+0x39/0x50 > [ 22.058171] kvfree_rcu_barrier+0xe9/0x130 > [ 22.058174] kmem_cache_destroy+0x18/0x140 > [ 22.058177] process_one_work+0x184/0x3a0 > [ 22.058180] worker_thread+0x24d/0x360 > [ 22.058183] ? __pfx_worker_thread+0x10/0x10 > [ 22.058185] kthread+0xfc/0x230 > [ 22.058189] ? finish_task_switch.isra.0+0x85/0x2a0 > [ 22.058192] ? __pfx_kthread+0x10/0x10 > [ 22.058195] ret_from_fork+0x30/0x50 > [ 22.058199] ? __pfx_kthread+0x10/0x10 > [ 22.058202] ret_from_fork_asm+0x1a/0x30 > [ 22.058206] > [ 22.058207] ---[ end trace 0000000000000000 ]--- > [ 23.123507] ok 8 test_kfree_rcu_wq_destroy > [ 23.151033] ok 9 test_leak_destroy > [ 23.151612] ok 10 test_krealloc_redzone_zeroing > [ 23.151617] # slub_test: pass:10 fail:0 skip:0 total:10 > [ 23.151619] # Totals: pass:10 fail:0 skip:0 total:10 > [ 23.151620] ok 1 slub_test > urezki@pc638:~$ > > > but i had to adapt slightly the Vlastimil's test: > > diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c > index f11691315c2f..222f6d204b0d 100644 > --- a/lib/slub_kunit.c > +++ b/lib/slub_kunit.c > @@ -6,6 +6,7 @@ > #include > #include > #include > +#include > #include "../mm/slab.h" > > static struct kunit_resource resource; > @@ -181,6 +182,63 @@ static void test_kfree_rcu(struct kunit *test) > KUNIT_EXPECT_EQ(test, 0, slab_errors); > } > > +struct cache_destroy_work { > + struct work_struct work; > + struct kmem_cache *s; > +}; > + > +static void cache_destroy_workfn(struct work_struct *w) > +{ > + struct cache_destroy_work *cdw; > + > + cdw = container_of(w, struct cache_destroy_work, work); > + kmem_cache_destroy(cdw->s); > +} > + > +#define KMEM_CACHE_DESTROY_NR 10 > + > +static void test_kfree_rcu_wq_destroy(struct kunit *test) > +{ > + struct test_kfree_rcu_struct *p; > + struct cache_destroy_work cdw; > + struct workqueue_struct *wq; > + struct kmem_cache *s; > + unsigned int rnd; > + int i; > + > + if (IS_BUILTIN(CONFIG_SLUB_KUNIT_TEST)) > + kunit_skip(test, "can't do kfree_rcu() when test is built-in"); > + > + INIT_WORK_ONSTACK(&cdw.work, cache_destroy_workfn); > + wq = alloc_workqueue("test_kfree_rcu_destroy_wq", > + WQ_HIGHPRI | WQ_UNBOUND | WQ_MEM_RECLAIM, 0); > + > + if (!wq) > + kunit_skip(test, "failed to alloc wq"); > + > + for (i = 0; i < KMEM_CACHE_DESTROY_NR; i++) { > + s = test_kmem_cache_create("TestSlub_kfree_rcu_wq_destroy", > + sizeof(struct test_kfree_rcu_struct), > + SLAB_NO_MERGE); > + > + if (!s) > + kunit_skip(test, "failed to create cache"); > + > + rnd = get_random_u8() % 255; > + p = kmem_cache_alloc(s, GFP_KERNEL); > + kfree_rcu(p, rcu); > + > + cdw.s = s; > + > + msleep(rnd); > + queue_work(wq, &cdw.work); > + flush_work(&cdw.work); > + } > + > + destroy_workqueue(wq); > + KUNIT_EXPECT_EQ(test, 0, slab_errors); > +} > + > static void test_leak_destroy(struct kunit *test) > { > struct kmem_cache *s = test_kmem_cache_create("TestSlub_leak_destroy", > @@ -254,6 +312,7 @@ static struct kunit_case test_cases[] = { > KUNIT_CASE(test_clobber_redzone_free), > KUNIT_CASE(test_kmalloc_redzone_access), > KUNIT_CASE(test_kfree_rcu), > + KUNIT_CASE(test_kfree_rcu_wq_destroy), > KUNIT_CASE(test_leak_destroy), > KUNIT_CASE(test_krealloc_redzone_zeroing), > {} > > -- > Uladzislau Rezki > WQ_MEM_RECLAIM-patch fixes this for me: diff --git a/mm/slab_common.c b/mm/slab_common.c index 4030907b6b7d..1b5ed5512782 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -1304,6 +1304,8 @@ module_param(rcu_min_cached_objs, int, 0444); static int rcu_delay_page_cache_fill_msec = 5000; module_param(rcu_delay_page_cache_fill_msec, int, 0444); +static struct workqueue_struct *rcu_reclaim_wq; + /* Maximum number of jiffies to wait before draining a batch. */ #define KFREE_DRAIN_JIFFIES (5 * HZ) #define KFREE_N_BATCHES 2 @@ -1632,10 +1634,10 @@ __schedule_delayed_monitor_work(struct kfree_rcu_cpu *krcp) if (delayed_work_pending(&krcp->monitor_work)) { delay_left = krcp->monitor_work.timer.expires - jiffies; if (delay < delay_left) - mod_delayed_work(system_unbound_wq, &krcp->monitor_work, delay); + mod_delayed_work(rcu_reclaim_wq, &krcp->monitor_work, delay); return; } - queue_delayed_work(system_unbound_wq, &krcp->monitor_work, delay); + queue_delayed_work(rcu_reclaim_wq, &krcp->monitor_work, delay); } static void @@ -1733,7 +1735,7 @@ kvfree_rcu_queue_batch(struct kfree_rcu_cpu *krcp) // "free channels", the batch can handle. Break // the loop since it is done with this CPU thus // queuing an RCU work is _always_ success here. - queued = queue_rcu_work(system_unbound_wq, &krwp->rcu_work); + queued = queue_rcu_work(rcu_reclaim_wq, &krwp->rcu_work); WARN_ON_ONCE(!queued); break; } @@ -1883,7 +1885,7 @@ run_page_cache_worker(struct kfree_rcu_cpu *krcp) if (rcu_scheduler_active == RCU_SCHEDULER_RUNNING && !atomic_xchg(&krcp->work_in_progress, 1)) { if (atomic_read(&krcp->backoff_page_cache_fill)) { - queue_delayed_work(system_unbound_wq, + queue_delayed_work(rcu_reclaim_wq, &krcp->page_cache_work, msecs_to_jiffies(rcu_delay_page_cache_fill_msec)); } else { @@ -2120,6 +2122,10 @@ void __init kvfree_rcu_init(void) int i, j; struct shrinker *kfree_rcu_shrinker; + rcu_reclaim_wq = alloc_workqueue("rcu_reclaim", + WQ_UNBOUND | WQ_MEM_RECLAIM, 0); + WARN_ON(!rcu_reclaim_wq); + /* Clamp it to [0:100] seconds interval. */ if (rcu_delay_page_cache_fill_msec < 0 || rcu_delay_page_cache_fill_msec > 100 * MSEC_PER_SEC) { it passes: [ 15.972416] KTAP version 1 [ 15.972421] 1..1 [ 15.973467] KTAP version 1 [ 15.973470] # Subtest: slub_test [ 15.973472] # module: slub_kunit [ 15.973474] 1..10 [ 15.974483] ok 1 test_clobber_zone [ 15.974927] ok 2 test_next_pointer [ 15.975308] ok 3 test_first_word [ 15.975672] ok 4 test_clobber_50th_byte [ 15.976035] ok 5 test_clobber_redzone_free [ 15.976128] stackdepot: allocating hash table of 1048576 entries via kvcalloc [ 15.979505] ok 6 test_kmalloc_redzone_access [ 16.014408] ok 7 test_kfree_rcu [ 17.726602] ok 8 test_kfree_rcu_wq_destroy [ 17.750323] ok 9 test_leak_destroy [ 17.750883] ok 10 test_krealloc_redzone_zeroing [ 17.750887] # slub_test: pass:10 fail:0 skip:0 total:10 [ 17.750890] # Totals: pass:10 fail:0 skip:0 total:10 [ 17.750891] ok 1 slub_test -- Uladzislau Rezki