Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2758083lqo; Tue, 14 May 2024 08:18:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW8x4NTOzLOpAxWjN1Ffi/YBm+9Dfs0l7T6jywq2Y/5q8d2CaGkAAM675RAqNLuQtLqpjxFnsYHZb5XGjuRH/qCKAy2NeQchX3FcgnLmA== X-Google-Smtp-Source: AGHT+IE2407B+vAFFWNPRAtSJc4lMGaKtyn6vaUh7LHMve/Op5e61umrTvXD8MYUPmHH/M/ND1HA X-Received: by 2002:a17:906:b2d6:b0:a59:dba0:1544 with SMTP id a640c23a62f3a-a5a2d318e22mr952312166b.31.1715699905101; Tue, 14 May 2024 08:18:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715699905; cv=pass; d=google.com; s=arc-20160816; b=NQuoa5/tCUKOn+9yChF3NZ+hsWvYxmaqRS7az4UzpOCfDQEjNg54BFgEME9lSe6Zmo 55bFsIIFCdbEFJYs6QntFoDdfSduCQWKqXt2gGf2gOk7IQtsKMDa91iX3/pR14Rt5fxK AV1vOcO4G/p3jvaX26e82lLJ4Wl23+T6DAI49k4ufe2V+LsL5gDApjxCPNLz08QLrfr0 U06KTsHNBDvNiflQMDrtt48pvCSBnd/wenGkGKu4lvX33fObQEY32ngs8ekA5e9Gpwjg iIKhylcLopjAEMr0emSDwJia9WZBLuOo0WKAWgo8qESqP5xVkQg1x+IAUfFc5SZ014QP RT5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QPg0NSP/ZWbtlwJUwF8SWG5PfOPrBasGAg0ju5SKJjM=; fh=CI1ze79JcLJUmPR5frPkHeEzXYX17cBL1gZnLskZGaY=; b=teulfiBFbI/bYhmBm5m5BJ36bziVCn1/wdLrM8l4s9xPNxSrkas77qXgGfcToRUJj7 XulkpDXpRvM1O3xMT41ykB5J4DsTJmam0Zgs1lU/2WtfHNMa2y5Z/NiIBVXweQnFGElS VcSAGDfoQvmRo6/wHyZn43VJUZF8pZvBSVJC3IaXUtyzl79QV6/+lUczIi3sJzTPRY7R b2kzEhO3a6GQ+VV/2nNqZXBTEMrP8QoA2gUaOSUCBSUVMs/TdhPu8d4uTzhCJn+b9Xlk P65egSZeYEejCNGLuhW8O8FrlUA4D0vr0wPsgeyQNYHGIRtj0JQY+zU92jPBS8OkuO1m sidg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FPC3muuu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-178845-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178845-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17ba3a43si697249866b.636.2024.05.14.08.18.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 08:18:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178845-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FPC3muuu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-178845-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178845-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id ABB841F225ED for ; Tue, 14 May 2024 15:18:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 43C2117EB90; Tue, 14 May 2024 15:18:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FPC3muuu" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 579B26D1A7; Tue, 14 May 2024 15:18:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715699896; cv=none; b=lVHrXA/BtVCiZczndKcnTGii92zkrOU+3MNdrrBffjVeMuP5OUbHuGrqIC7n4eiYTkm0AqCXPnzHMZtqLVZ5rlFq7cbUI7QhWXFshMEU0rQ7VMCTY3vI9DTrhg+HQycax9rpy3iRba++ZPb9ZdPbYsoD71ORmLWzaVbw+oA19ik= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715699896; c=relaxed/simple; bh=dz0W6lVGiQtL41DIauY2UL2LTE7YOmNwP3C2aSsJqXA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uQG2otOP2ZNboNrKQMI9Toq6590Ev+g1oAVQewSRFOhwsJrCCcYszGwC1bWqw2nlEYWbtGrqnP0RVAfa6Rwa7xYE3Wr33vjfYywK/agPz49pTj58Sv8rgr1ig58O0Q8yrx7OT1hqQZ33vS5JOGp10GG88Oh92rDPOwNGw1yXSbA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FPC3muuu; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71EDBC2BD10; Tue, 14 May 2024 15:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715699895; bh=dz0W6lVGiQtL41DIauY2UL2LTE7YOmNwP3C2aSsJqXA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FPC3muuu/Uii4ixvK0dx+At1hwVa1dOFNLHUCMgX9QRWNDOrVPh7s2NYq6qWA8FOF cgoA4rYW3i2u9fu08uNeLA2Z2AD0X5jEqqAPby+xKf7JQHDfi2s0cz/lCwTN9o4d8j oTs4iX9d+Yh1UD8i4H+A5jzu/08kHUnP5grCrPWFoF2lAi+4e78/hzSsFJz+XeEqtF Vp3CR7xbxtQ51uwOeCvh5axVN/F6h2GXW//FyzTEXGCl9OYNCnUyGlUAG2HQBdzZX0 U5WLS3Khw2J6pXLS0SkNR7J5F5t5WO/DcFYGmwu/iz4sNGvdB+ScEGuZFNGSO7qJLn La1zrgDgusg0w== Date: Tue, 14 May 2024 17:18:12 +0200 From: Frederic Weisbecker To: "Paul E. McKenney" Cc: Zqiang , neeraj.upadhyay@kernel.org, joel@joelfernandes.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rcu/nocb: Fix using smp_processor_id() in preemptible warning Message-ID: References: <20240509074046.15629-1-qiang.zhang1211@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Le Tue, May 14, 2024 at 07:54:40AM -0700, Paul E. McKenney a ?crit : > On Thu, May 09, 2024 at 03:40:46PM +0800, Zqiang wrote: > > Currently, the this_cpu_ptr(&rcu_data) in rcu_rdp_is_offloaded() is called > > before the condition "!(IS_ENABLED(CONFIG_PREEMPT_COUNT) && preemptible())" > > is checked, and occurs in preemptible task context, this will trigger the > > following warning. > > > > [ 4.106221][ T18] BUG: using smp_processor_id() in preemptible [00000000] code: rcuop/0/18 > > [ 4.107796][ T18] caller is debug_smp_processor_id (lib/smp_processor_id.c:61) > > [ 4.108547][ T18] CPU: 0 PID: 18 Comm: rcuop/0 Not tainted 6.9.0-rc2-00079-g4c66bc7cacc0 #1 > > [ 4.109667][ T18] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 > > [ 4.111064][ T18] Call Trace: > > [ 4.111064][ T18] > > [ 4.111064][ T18] dump_stack_lvl (lib/dump_stack.c:116) > > [ 4.111064][ T18] dump_stack (lib/dump_stack.c:124) > > [ 4.111064][ T18] check_preemption_disabled (arch/x86/include/asm/preempt.h:84 (discriminator 15) lib/smp_processor_id.c:53 (discriminator 15)) > > [ 4.111064][ T18] debug_smp_processor_id (lib/smp_processor_id.c:61) > > [ 4.111064][ T18] rcu_rdp_is_offloaded (kernel/rcu/tree_plugin.h:27 (discriminator 1)) > > [ 4.111064][ T18] nocb_cb_wait (kernel/rcu/tree_nocb.h:936 (discriminator 2)) > > [ 4.111064][ T18] rcu_nocb_cb_kthread (kernel/rcu/tree_nocb.h:983 (discriminator 1)) > > [ 4.111064][ T18] ? nocb_cb_wait (kernel/rcu/tree_nocb.h:976) > > [ 4.111064][ T18] kthread (kernel/kthread.c:388) > > [ 4.111064][ T18] ? kthread (kernel/kthread.c:373 (discriminator 2)) > > [ 4.111064][ T18] ? kthread_complete_and_exit (kernel/kthread.c:341) > > [ 4.111064][ T18] ret_from_fork (arch/x86/kernel/process.c:153) > > [ 4.111064][ T18] ? kthread_complete_and_exit (kernel/kthread.c:341) > > [ 4.111064][ T18] ret_from_fork_asm (arch/x86/entry/entry_64.S:256) > > [ 4.111064][ T18] > > > > This commit fix this warning by priority check the condition > > "!(IS_ENABLED(CONFIG_PREEMPT_COUNT) && preemptible())" , to > > ensure whether the this_cpu_ptr(&rcu_data) can be executed in > > rcu_rdp_is_offloaded(). > > > > Fixes: 8feeeba60711 ("rcu/nocb: Use kthread parking instead of ad-hoc implementation") > > Tested-by: kernel test robot > > Signed-off-by: Zqiang > > Hearing no objections, I have queued this wordsmithed version. As always, > please let me know if I have messed anything up. > > Thanx, Paul > > ------------------------------------------------------------------------ > > commit 5271ad1de0fbcf0bd9caebcf721670c164e5fa9c > Author: Zqiang > Date: Thu May 9 15:40:46 2024 +0800 > > rcu/nocb: Don't use smp_processor_id() in preemptible code > > Currently, rcu_rdp_is_offloaded() invokes this_cpu_ptr(&rcu_data) before > the condition "!(IS_ENABLED(CONFIG_PREEMPT_COUNT) && preemptible())" > is checked. When invoked in preemptible context in preemptible kernels, > this will trigger the following warning: > > [ 4.106221][ T18] BUG: using smp_processor_id() in preemptible [00000000] code: rcuop/0/18 > [ 4.107796][ T18] caller is debug_smp_processor_id (lib/smp_processor_id.c:61) > [ 4.108547][ T18] CPU: 0 PID: 18 Comm: rcuop/0 Not tainted 6.9.0-rc2-00079-g4c66bc7cacc0 #1 > [ 4.109667][ T18] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 > [ 4.111064][ T18] Call Trace: > [ 4.111064][ T18] > [ 4.111064][ T18] dump_stack_lvl (lib/dump_stack.c:116) > [ 4.111064][ T18] dump_stack (lib/dump_stack.c:124) > [ 4.111064][ T18] check_preemption_disabled (arch/x86/include/asm/preempt.h:84 (discriminator 15) lib/smp_processor_id.c:53 (discriminator 15)) > [ 4.111064][ T18] debug_smp_processor_id (lib/smp_processor_id.c:61) > [ 4.111064][ T18] rcu_rdp_is_offloaded (kernel/rcu/tree_plugin.h:27 (discriminator 1)) > [ 4.111064][ T18] nocb_cb_wait (kernel/rcu/tree_nocb.h:936 (discriminator 2)) > [ 4.111064][ T18] rcu_nocb_cb_kthread (kernel/rcu/tree_nocb.h:983 (discriminator 1)) > [ 4.111064][ T18] ? nocb_cb_wait (kernel/rcu/tree_nocb.h:976) > [ 4.111064][ T18] kthread (kernel/kthread.c:388) > [ 4.111064][ T18] ? kthread (kernel/kthread.c:373 (discriminator 2)) > [ 4.111064][ T18] ? kthread_complete_and_exit (kernel/kthread.c:341) > [ 4.111064][ T18] ret_from_fork (arch/x86/kernel/process.c:153) > [ 4.111064][ T18] ? kthread_complete_and_exit (kernel/kthread.c:341) > [ 4.111064][ T18] ret_from_fork_asm (arch/x86/entry/entry_64.S:256) > [ 4.111064][ T18] > > This commit therefore fixes this warning by checking the condition > "!(IS_ENABLED(CONFIG_PREEMPT_COUNT) && preemptible())" before invoking > this_cpu_ptr(), thus avoiding preemptible invocations. > > Fixes: 8feeeba60711 ("rcu/nocb: Use kthread parking instead of ad-hoc implementation") > Tested-by: kernel test robot > Signed-off-by: Zqiang > Signed-off-by: Paul E. McKenney Reviewed-by: Frederic Weisbecker