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 77F7EC77B73 for ; Wed, 12 Apr 2023 05:51:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00463900002; Wed, 12 Apr 2023 01:51:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF6716B0075; Wed, 12 Apr 2023 01:51:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D96F2900002; Wed, 12 Apr 2023 01:51:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C7E156B0074 for ; Wed, 12 Apr 2023 01:51:47 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8842B1A0F49 for ; Wed, 12 Apr 2023 05:51:47 +0000 (UTC) X-FDA: 80671667454.20.0A478BF Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) by imf15.hostedemail.com (Postfix) with ESMTP id 67084A000F for ; Wed, 12 Apr 2023 05:51:45 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=gA5lCO46; spf=pass (imf15.hostedemail.com: domain of boqun.feng@gmail.com designates 209.85.219.52 as permitted sender) smtp.mailfrom=boqun.feng@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=1681278705; 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=yvoUVygYOW2rUunYuamK7w2S9WEkc7tFRqN89hV4hPk=; b=vyXku4oF5e+Z9YbNHr1Wzz52SFgWeaOr5XiPuHacPHmPVR01YZy2nMqE3LEIPd7HPGPPIE 7CEeYjPVy1hErO4wX8yxhYWts9/7vZkEOkbXSsyEDM4NeqzxvKibB8fJFJW+Q7z0kRID2W uJnMmpX7GJevE6VWYhpJET/vk7+TDpU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=gA5lCO46; spf=pass (imf15.hostedemail.com: domain of boqun.feng@gmail.com designates 209.85.219.52 as permitted sender) smtp.mailfrom=boqun.feng@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681278705; a=rsa-sha256; cv=none; b=coBV4eK8kMotZL4g8wTYYXxQAjjgJ7L0uDsZ0mQ2swiqhLvJ7YOtxrggXOEaHKFIpCi0aa hYE6HUHY4A/E7DU7vFej7oaUnOzgZy04iFrQb9YJ/SMgDnEv7rUWMuwF+EckZ4y39xT3Hq HKK9wfJMSfxcx6uzTCDwnnN+L6nkI+w= Received: by mail-qv1-f52.google.com with SMTP id dw2so20707968qvb.11 for ; Tue, 11 Apr 2023 22:51:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681278704; x=1683870704; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=yvoUVygYOW2rUunYuamK7w2S9WEkc7tFRqN89hV4hPk=; b=gA5lCO46B+6ruQh/YRtnNjPsNTHjdUCzaAlHSLkulLacw1xZYb/eyxzFs+y7PCYtT3 bhQFC3NOEPbZUS7CpJJOLHoDIb4DALTFUjAlKU54Rc4tZNZpClEkz1lyTQwiA/wLnn0n zy76SqHmpyq0WaA9mCv/ezvrBzFwufytiEqrkPlFJH0K0MVeUmvpdEDRrYvsaIPfCl0u 4mBbDr/eJENN4le1LgTeGNqDYjXaylZCXjn7z8au9wcdT1PpuotFwjrZ3lzVZeOybmsi GhMJIUEIdrcfDbMN0h7bgG54qXf8BenQ22fjil05Zle2jFBWeOGlbOy+mDFLhf32dUww u5qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681278704; x=1683870704; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yvoUVygYOW2rUunYuamK7w2S9WEkc7tFRqN89hV4hPk=; b=xF7KwHSmP4Csdd9ehCA4QPnuo10+CxzuvXYpjI1p9n7XxCn3k5ImzBtBH2kojOyS7b qECqTtZ6p4/rJoxNdiZgi+eN2l4RHG+DQJkN1rLHqpmHMyCUzeSiyPKSoXYL42BXneUB mhO3f2cHDYkyFzcHWuzHc6OgsmzXkezLPhzxtSd2jZzJfTIZYLIOmJ4QQMmw/5ZXu222 /Y7Ws1uTDVxW6DBSni3AyK4KJlLUTZMRlkvyojpQYIkCg1TAPxvyeWb2B6YertOXH4rL QPuhDfwW7Rx1BhZzzbvROO/kfdxBRgjxLQFddJYZqoXcS63Y9OFcuDX1y7qZjP7UupqI s1ZQ== X-Gm-Message-State: AAQBX9cOhYAZM3kqcbfrSCsgf0dojJJXbMtU2lX09ZcGzaCRCDY03aoS Q+HRzFSrvC4f4OjijcixqFE= X-Google-Smtp-Source: AKy350ZROPNKm2R2IXTYYFnwI965VTRavSgYHkf77npfXYkY7KCJJrKBsX2OLzOP5lOPt/r36ojSGA== X-Received: by 2002:a05:6214:2027:b0:5ee:a282:d38e with SMTP id 7-20020a056214202700b005eea282d38emr2735807qvf.10.1681278704507; Tue, 11 Apr 2023 22:51:44 -0700 (PDT) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id ep9-20020a05621418e900b005e14936cb09sm3779649qvb.11.2023.04.11.22.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 22:51:43 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id 32FDA27C0054; Wed, 12 Apr 2023 01:51:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 12 Apr 2023 01:51:43 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdekhedguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeeuohhq uhhnucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrf grthhtvghrnhephedugfduffffteeutddvheeuveelvdfhleelieevtdeguefhgeeuveei udffiedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epsghoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedt ieegqddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfh higihmvgdrnhgrmhgv X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 12 Apr 2023 01:51:41 -0400 (EDT) Date: Tue, 11 Apr 2023 22:51:39 -0700 From: Boqun Feng To: Qi Zheng Cc: Vlastimil Babka , 42.hyeyoo@gmail.com, akpm@linux-foundation.org, roman.gushchin@linux.dev, iamjoonsoo.kim@lge.com, rientjes@google.com, penberg@kernel.org, cl@linux.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhao Gongyi , Sebastian Andrzej Siewior , Thomas Gleixner , RCU , "Paul E . McKenney" Subject: Re: [PATCH] mm: slub: annotate kmem_cache_node->list_lock as raw_spinlock Message-ID: References: <20230411130854.46795-1-zhengqi.arch@bytedance.com> <932bf921-a076-e166-4f95-1adb24d544cf@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <932bf921-a076-e166-4f95-1adb24d544cf@bytedance.com> X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 67084A000F X-Rspam-User: X-Stat-Signature: xk387chn8fch344j68pwdw3iit9ko6in X-HE-Tag: 1681278705-617201 X-HE-Meta: U2FsdGVkX195PGuezm6BtP/CQF7Daac+WCkAG++jPaXk5C/FMjWEBEjMCs1/sAPa+2bYf3ZumVEGWPGBznpd1y5oWhFnYSO87541ufv6cWXgAqx85OPvXWbK6Scq80vg7FFiTRUYRCMCh6mAE71kksIBd3EAeFfgrmIXBzR6vACBnwNII80C/5nhRmKvXaC6ZAIUyUm/AaEBBu/9gkK0oQBl5L1yXckhalRiJrWytgjwNMB04j6eqr+JOY/TD7VDM1i4+3Bc0J03jaXd8seaGtTBGOtG2fP7tRRb8BTpQPPaGfWGfVDHUR9MIR63JYYgpd6RF6yMweybqQrPeyiesQd2ufClmv+9h0M3GlRaEfbXGjrd8p9C11DuYwpHpH2fshdlrrPWaf+6CHl0iqZsaX37wzyW6uWKcEgiMO3J0DaYNBvtZUGolVaHjdCae6/qFMpC8u7+GoVKsJqJKwnI/EZP4n6wl16V2iJlDpJ7qY2/z7UHQIHgIfAf4EILv7Vrxv1BFmx0mtmD2fbrJaAMQWYXImGPbw0Bfnw7dyJh6GDBQd9bBv5220sCn8StLdDzHhkAtyoapOkQBRT9dylLCoTqlx9T8GFwKiAFoJeY3arUX3wSCc1urHPWGyqwg663eFgGTawl2U5ksG5xW2/caEZnoIMkfgr/QmunBnFnJVLFTsN8hKtknB6v0tD3yPXLovKoE3u3hsRekIbw2Xna86JlVZAlp6sUHkInqtQ3j14cG8c1J8xpB3aW6jCweZ1XM2/08Jr7D1nJA5Vus70kWOOIUtVd/EfoI8gSZSlYSq5PZacLg3vRLgXQtIw8j0nzq7AD1QtoAhXuhhUnQwATwi3OsR1tyTqN2/JAEuK5INOBEV+V8g5EE5Rybx78gYRFvxoSRSXM2QoG6N5zxsGWjRMxj+QHxqXOlim1M3aIEMVpR52jPs6eQGxDk7CRENvw3MyDzAORQsCRo9FVgta VHBW30TJ GpI/qX2EhgWh0P/tD4JtFvcX/nMznWgAGYJsnsItZFQXLNeN9Y3J2mzH7qSMkvnFe4ZbRMaIWpHEnD5sBmNXwp6f5CX2CjsHV0M3ILaY76XvQCYDnXBhoSN/4PEHzEMdKBZFM6fxse51Jvgrnf5YTXR8AKussy+JF8pKbDtMHE7mVDYN7wUKVibq0Ue4AtlG0uyPO1eQqEJ43O+yGEi3GWqnnnyZNq+nlkbPKIUr9dRGSnzfMtfLuB5XbXkpGW3M7D+gB0FiZTX3iw4ED6Dmac1T3K31J7R49okkbZIdfVuOAS4A+BeQv+SQIt7xPVN1oX/vwwuDqoC3XjFB7s0C22I5NSQ74peqJYjni5I47jMOqFDI2d808LKqTIB0SXpC68vwk048ihmPXr9bX5KGJw2VvfF2wC3VveUgjMTlXveFAyxXw9EeC78hMXzzhXwOi2xMsiIyNJxI6QkH87zdiuA/+kHZncZbGTJMhSdbjrRLQsaeagQRsLEeSIpFz9K5sApkwGzBbK88vU0QTmhA1S0xLYG7DJYyyxHITeBRzRyWuCt5tExzailAlQAd6/gV4VI3wHI+LnquFGYg= 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, Apr 11, 2023 at 10:25:06PM +0800, Qi Zheng wrote: > > > On 2023/4/11 22:19, Vlastimil Babka wrote: > > On 4/11/23 16:08, Qi Zheng wrote: > > > > > > > > > On 2023/4/11 21:40, Vlastimil Babka wrote: > > > > On 4/11/23 15:08, Qi Zheng wrote: > > > > > The list_lock can be held in the critical section of > > > > > raw_spinlock, and then lockdep will complain about it > > > > > like below: > > > > > > > > > > ============================= > > > > > [ BUG: Invalid wait context ] > > > > > 6.3.0-rc6-next-20230411 #7 Not tainted > > > > > ----------------------------- > > > > > swapper/0/1 is trying to lock: > > > > > ffff888100055418 (&n->list_lock){....}-{3:3}, at: ___slab_alloc+0x73d/0x1330 > > > > > other info that might help us debug this: > > > > > context-{5:5} > > > > > 2 locks held by swapper/0/1: > > > > > #0: ffffffff824e8160 (rcu_tasks.cbs_gbl_lock){....}-{2:2}, at: cblist_init_generic+0x22/0x2d0 > > > > > #1: ffff888136bede50 (&ACCESS_PRIVATE(rtpcp, lock)){....}-{2:2}, at: cblist_init_generic+0x232/0x2d0 > > > > > stack backtrace: > > > > > CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.3.0-rc6-next-20230411 #7 > > > > > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 > > > > > Call Trace: > > > > > > > > > > dump_stack_lvl+0x77/0xc0 > > > > > __lock_acquire+0xa65/0x2950 > > > > > ? arch_stack_walk+0x65/0xf0 > > > > > ? arch_stack_walk+0x65/0xf0 > > > > > ? unwind_next_frame+0x602/0x8d0 > > > > > lock_acquire+0xe0/0x300 > > > > > ? ___slab_alloc+0x73d/0x1330 > > > > > ? find_usage_forwards+0x39/0x50 > > > > > ? check_irq_usage+0x162/0xa70 > > > > > ? __bfs+0x10c/0x2c0 > > > > > _raw_spin_lock_irqsave+0x4f/0x90 > > > > > ? ___slab_alloc+0x73d/0x1330 > > > > > ___slab_alloc+0x73d/0x1330 > > > > > ? fill_pool+0x16b/0x2a0 > > > > > ? look_up_lock_class+0x5d/0x160 > > > > > ? register_lock_class+0x48/0x500 > > > > > ? __lock_acquire+0xabc/0x2950 > > > > > ? fill_pool+0x16b/0x2a0 > > > > > kmem_cache_alloc+0x358/0x3b0 > > > > > ? __lock_acquire+0xabc/0x2950 > > > > > fill_pool+0x16b/0x2a0 > > > > > ? __debug_object_init+0x292/0x560 > > > > > ? lock_acquire+0xe0/0x300 > > > > > ? cblist_init_generic+0x232/0x2d0 > > > > > __debug_object_init+0x2c/0x560 This "__debug_object_init" is because INIT_WORK() is called in cblist_init_generic(), so.. > > > > > cblist_init_generic+0x147/0x2d0 > > > > > rcu_init_tasks_generic+0x15/0x190 > > > > > kernel_init_freeable+0x6e/0x3e0 > > > > > ? rest_init+0x1e0/0x1e0 > > > > > kernel_init+0x1b/0x1d0 > > > > > ? rest_init+0x1e0/0x1e0 > > > > > ret_from_fork+0x1f/0x30 > > > > > > > > > > > > > > > The fill_pool() can only be called in the !PREEMPT_RT kernel > > > > > or in the preemptible context of the PREEMPT_RT kernel, so > > > > > the above warning is not a real issue, but it's better to > > > > > annotate kmem_cache_node->list_lock as raw_spinlock to get > > > > > rid of such issue. > > > > > > > > + CC some RT and RCU people > > > > > > Thanks. > > > > > > > > > > > AFAIK raw_spinlock is not just an annotation, but on RT it changes the > > > > implementation from preemptible mutex to actual spin lock, so it would be > > > > > > Yeah. > > > > > > > rather unfortunate to do that for a spurious warning. Can it be somehow > > > > fixed in a better way? ... probably a better fix is to drop locks and call INIT_WORK(), or make the cblist_init_generic() lockless (or part lockless), given it's just initializing the cblist, it's probably doable. But I haven't taken a careful look yet. Regards, Boqun > > > > > > It's indeed unfortunate for the warning in the commit message. But > > > functions like kmem_cache_alloc(GFP_ATOMIC) may indeed be called > > > in the critical section of raw_spinlock or in the hardirq context, which > > > > Hmm, I thought they may not, actually. > > > > > will cause problem in the PREEMPT_RT kernel. So I still think it is > > > reasonable to convert kmem_cache_node->list_lock to raw_spinlock type. > > > > It wouldn't be the complete solution anyway. Once we allow even a GFP_ATOMIC > > slab allocation for such context, it means also page allocation can happen > > to refill the slabs, so lockdep will eventually complain about zone->lock, > > and who knows what else. > > Oh, indeed. :( > > > > > > In addition, there are many fix patches for this kind of warning in the > > > git log, so I also think there should be a general and better solution. :) > > > > Maybe, but given above, I doubt it's this one. > > > > > > > > > > > > > > > > -- > Thanks, > Qi