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 1FD2DC76196 for ; Tue, 11 Apr 2023 14:25:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA910280009; Tue, 11 Apr 2023 10:25:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A346F280001; Tue, 11 Apr 2023 10:25:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D2CF280009; Tue, 11 Apr 2023 10:25:19 -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 7693E280001 for ; Tue, 11 Apr 2023 10:25:19 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 30ECC140C98 for ; Tue, 11 Apr 2023 14:25:19 +0000 (UTC) X-FDA: 80669332758.07.EC554BA Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf21.hostedemail.com (Postfix) with ESMTP id CEECE1C0016 for ; Tue, 11 Apr 2023 14:25:15 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=InNRK7xY; spf=pass (imf21.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681223117; a=rsa-sha256; cv=none; b=imxNb7khbgL9rSQNCBU967DzP5qvbVaQP5sUvX33yXZKa91xmXrFVA8BP4fkZGn2TSV/42 8k4VsBZ661vLP9IVcROjAbFpd7BRR4XtNQmHz4aDzuxrFh3jH5ITs6SUuaPYWeoIavVe7l 2LlS8GJQkWzd6ZxMJozSg1Rsjjfapy8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=InNRK7xY; spf=pass (imf21.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681223117; 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=aA7yXN2+joEEpx3b7NOs0sHQ48HGW5HeFIOcYZGJQBg=; b=8Qmr62HttX3Xf7Zea4hVktbHO5lOjZ4OjNYUzviIaO/4T8UtiX3Y8ZdRsz1yaHi5t4lWeU h90ZQ9kbzTni8ZogjM66W7myAgaERQIUDJduMQNl0GC6sr0xNnkwfXouzsGiByywAgI2SC CBiOyhnDPVMKEZLKa6a2uQTN4PsZg1A= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1a52648fcddso2195255ad.0 for ; Tue, 11 Apr 2023 07:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1681223114; x=1683815114; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=aA7yXN2+joEEpx3b7NOs0sHQ48HGW5HeFIOcYZGJQBg=; b=InNRK7xYUtsP0RDhwa4iJNlfY20/3ga2Y0fEzIPEJ0GP3rIFSZbBIUPAYccdhF91NP dYZUzVNDVsVN+gaQdIiiiylpiW3f9YwZVs+xrHGII8JR9af23y8n5R1WuUH0XnmWSZPN vKZZCvZDC8hCG/zZ99KDy3kONCzfliryQlHJEGvq9vne0Fy4otIf9oA0ApPUKD3sh/vc WJZfNLRgkgDgHDl9+4zPhtXAEGnbjsyJ59l9IH3vqW3BIN9p2P2IshMA70laqQoQ/8BW XGSGPxe/o0Vrff1wyBs0TtwQcOZRZnDSTJnBRzJZ2cfNt3SqKjeSv9CYuZKLjHSZr3/Y ypUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681223114; x=1683815114; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aA7yXN2+joEEpx3b7NOs0sHQ48HGW5HeFIOcYZGJQBg=; b=DwdAhb6XdKzHL4N4E0o/u972rqLbuwlDXp9qrJIuvzewysEsohx0nSOKlPBReXhtlT lH0nLovJzjk11+9+4dpx/T/ZCWPyM4/p+IccX70/5Wp2uvRTfRo7PPJpfEkNsPle1Cj+ ymvfwd9ShDVcP/LwCHHmVTWAwklLobN9T3V025kce9Q+TxCTnuzM2CZnRI772cPRUXha Sn0J/5J4MFHJjc3KOE9inDItHn4v4ovTDrcP7xae7xIpG2U0ejYWeu+4692gmBOL5Ns4 aEUp0Dm1pMZC3QsWl/k4t/tpooHz9Q0i6L4eV4n3QhaIZXEYCD6XIU9gdbLs6tc9flXU Ghdw== X-Gm-Message-State: AAQBX9cb5NLWNVQYTzB778PRVEYoBCYO17yMiyOH4oHjjDBsilFAlisq D7GLfNjsKe0lVyZApMQbnm7wAQ== X-Google-Smtp-Source: AKy350bQ2ra+ZXetukJ7ouMbRthj7VXcB4A0+lPJqVl2wB2w7X5R+G66Xn43uyLmj+e+OV5XltwqaQ== X-Received: by 2002:a17:90a:cf0c:b0:236:7144:669f with SMTP id h12-20020a17090acf0c00b002367144669fmr14473327pju.2.1681223114321; Tue, 11 Apr 2023 07:25:14 -0700 (PDT) Received: from [10.200.10.123] ([139.177.225.225]) by smtp.gmail.com with ESMTPSA id s1-20020a17090ae68100b00234115a2221sm8570146pjy.39.2023.04.11.07.25.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Apr 2023 07:25:13 -0700 (PDT) Message-ID: <932bf921-a076-e166-4f95-1adb24d544cf@bytedance.com> Date: Tue, 11 Apr 2023 22:25:06 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH] mm: slub: annotate kmem_cache_node->list_lock as raw_spinlock Content-Language: en-US To: 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 Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhao Gongyi , Sebastian Andrzej Siewior , Thomas Gleixner , RCU , "Paul E . McKenney" References: <20230411130854.46795-1-zhengqi.arch@bytedance.com> From: Qi Zheng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Queue-Id: CEECE1C0016 X-Rspamd-Server: rspam01 X-Stat-Signature: bb6tpe1q95g16d3dipn56duro65xhffq X-HE-Tag: 1681223115-769260 X-HE-Meta: U2FsdGVkX1+JtwsRFulngjxANVYn3/rv6AOE2VBcP+v6YduqQw1fDKNIbrIEym/uuT2VAqidRihiokKyhiM6n65X5AK9VjWw79ED6RK0Z8GA64QGXa1sVvYesQzcUAmpEbT6Q268yf+7+1/Fnu6PAIj7Z8K1bYvpZg/q72hxERLl3YeEWkJ8ZnE603ettvigk4VtBpVbGI6moyD6O7+xIC5dPTxbb7/K8QQow1uxqJctqkWtUrRjiTUlVslL1RKKLaBJGoOYcpAz1x7TpWtRo9/+3VvZZmGaHXtthf3i1w57KQMLQ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V4NgID/sVNwHhRTkOGlFh0qZ2jww3tAReZGOYvuYON0zoqS7/E9JcHYs1Bowq/PYOKKuA+E2h1dYaxkx0PctqBdXviGqLTsgvrw/bDAcj08XkC1/yn9wctbw/+U 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 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 >>>> 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? >> >> 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