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 2398AC76196 for ; Tue, 11 Apr 2023 14:08:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 531B4900002; Tue, 11 Apr 2023 10:08:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E1BC6B0075; Tue, 11 Apr 2023 10:08:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3AA5D900002; Tue, 11 Apr 2023 10:08:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2BF0D6B0072 for ; Tue, 11 Apr 2023 10:08:15 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D1B8280DCE for ; Tue, 11 Apr 2023 14:08:14 +0000 (UTC) X-FDA: 80669289708.20.7D4D0DB Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf24.hostedemail.com (Postfix) with ESMTP id EFBAA180020 for ; Tue, 11 Apr 2023 14:08:10 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=ZGQN5zSP; spf=pass (imf24.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.171 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=1681222091; a=rsa-sha256; cv=none; b=chWw/oSe6Ukio7Wc6jfVqlQgTuScsX9Wqz07pKLsB0RNoKQi4486ZoBPRNh2xfrOVbXd74 R3Ts0VWiJv+7WtRHY0QbBCeCT/kAxedC7axt/hNDJeWS+yQxNsnX4Evd6wummzFf9Lr5S5 /ZPjLNbA/z3/I6FIbhGoyBcBySJOV10= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=ZGQN5zSP; spf=pass (imf24.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.171 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=1681222091; 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=U/FuUBX/oF7NlHyBeA4tCFMg08z1lRlCt7snQ+IazRc=; b=bAFSLyNs4g6Yqb1Wmpa5UnUE9EL3LyT3CoknWR/DzTE9H/EpFd4PUBtM7SKO0sZ8PXjdOE iZ5hxUB3mMy1yp7L5xQmC7+puwKyfAFDydZ6Pyq53uEOMGzNEVufKPf1S2VBYhqiRROs8m qhKC303hsijWO+HyueGlHwWLRem4O9c= Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1a5266d204dso2192755ad.1 for ; Tue, 11 Apr 2023 07:08:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1681222089; x=1683814089; 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=U/FuUBX/oF7NlHyBeA4tCFMg08z1lRlCt7snQ+IazRc=; b=ZGQN5zSPpnt9Gr1BTrqkXN1evZuAqurPhKj7vfdZedWsMBx9/8buvIj9JD67dQipmx VCWCR1nyWiIVGts1LB3aLAVr3Ztl0vD9HBB1VD+FQRXySUy5NXLUokW56RYI33TBmtuo XHUf5MoBdM60D6qfs2MeHfgxm6dtlJA1Xr74wxJl0IFBEe0qdOr08v3QZ2tCQvjL7w3D fC+iKD6AerXomXzioNocXZKkim1biNzIYLqt+c7BWrbjKykiaoBMnjhmIK8ypzjKyWLc X8ZdMCmVxIB5hCGQtFpOBStEmIynJBo2f1oPcqxi++RHHTk1HeXBonkg5ST/oGb4rRmg II4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681222089; x=1683814089; 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=U/FuUBX/oF7NlHyBeA4tCFMg08z1lRlCt7snQ+IazRc=; b=hYJZ0X08eoyMbBXC1LCkrdZfmdRiyMw72e5ipashGjT0WvsB0qXyB7JYxfiG5TMVD+ DolKbhDCOez0GCRzyL70shYrz1IRh9ctZEBAD1LEkCEI69pDC5xXke3pNR6xzPI7tXsU lVSZUSYXo8IJXOdFws5TyOoBed/vNS9RCORWrRtHekk7GMSDyneUqBHOwkfaDyceoLYl 9C69ED3RNNxoBmhK6QnGiuXEmo6JqwBQY38dJ12nZxlqsNIGxfAzj/rsYpBvT5PHnMps mWPtRSi8MMW6C47tirvDt0Gx2pdgDSfQLyoFBjR553gCLDVKzfyW7mo1OOPTRUQokmxg hYQQ== X-Gm-Message-State: AAQBX9f7TZnN4U5d6TmGe/jMj9JF1rIZDqLLvA8EqCf7vFg2A3ZwaduO ZuB8D4q7o/rzuSh0qU2nu8Y+GQ== X-Google-Smtp-Source: AKy350Y0ucw/4ZrTHcZLDUPrDQNrdscqkfy1vGI2p/5yLdQsTXgObQ0lOKINHgGJ5Lb77YesOypQDQ== X-Received: by 2002:a17:902:fb4f:b0:1a5:aca9:50c5 with SMTP id lf15-20020a170902fb4f00b001a5aca950c5mr8257942plb.6.1681222089487; Tue, 11 Apr 2023 07:08:09 -0700 (PDT) Received: from [10.200.10.123] ([139.177.225.225]) by smtp.gmail.com with ESMTPSA id s4-20020a170902988400b0019cd1ee1523sm9758946plp.30.2023.04.11.07.08.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Apr 2023 07:08:09 -0700 (PDT) Message-ID: Date: Tue, 11 Apr 2023 22:08:01 +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: EFBAA180020 X-Rspamd-Server: rspam01 X-Stat-Signature: 9tkcqbkierbf917p8bbtrx61tuk4hgnh X-HE-Tag: 1681222090-658568 X-HE-Meta: U2FsdGVkX18u3175anUXjUedNGtydgFzOgIK5WEt554C2gO2ZSQR3eAwU3LJSE9PMcTGG7wk4Zbck+LA2cmqKVJCNVkD8aEqlNhRvUJ7KgFZRyAbL66v1+LnSnwJW67ADFKFfd47wtvDBmITv/Y1MQUjgx5sEJXWiZLunnL7dh6o6pbBpWAG1h3BAyaprw2XcopV3Otw1FCa4ZIvjgJBTYE7IXz1UcKl4WVTdOISCO5H8iivJEPC4RLJe6K52ZR0zI69RTZs83du3A7Fl5L8Sixl0xt7urOZ23lRqva/qaRnSIdEgRADYU1/bJ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75HViyioyERAVM6kOo2AGGZF08gqM0ti2nYLsYWOyd5K7c9xtUhIebuFSCYjTgwwwknEPbW3/vlBG4RMdWE5EMru9QaIqF6L3Xary 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 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 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. 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. :) > -- Thanks, Qi