Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp252736rwd; Wed, 24 May 2023 17:45:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5m1SmJC37t5XNd/j1B92jBs5YpT6C9wJKcBxFpxnVotLWai5ez2hLb4+uWYs5BllrdLr91 X-Received: by 2002:a17:90b:4a11:b0:255:874d:8262 with SMTP id kk17-20020a17090b4a1100b00255874d8262mr9576850pjb.21.1684975520138; Wed, 24 May 2023 17:45:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684975520; cv=none; d=google.com; s=arc-20160816; b=MzjUPsn+UVsqgSxPVR/OTnKnKNo0xErCX0HTK0s5dGluy8nSkkzfRkXM9BofCAtwAl XKk+6p07VrjvSzRGkomy+PDG4x4YVQ9o+e6BzDV8yWq98H1Pauspb8PqUNiIpXk1YgEG MhxaRzE4S70hmZ5NseVkUHDeVRSeXSSO0GYXCTmKfSTymvMBqVUEeBORuQhW+BneEo/9 aTOUfj3BCnIbnANRJgKgj4AVtTgBpDStdXDc7IgzShTBlDbU62gXiKGT0LNYmKgs6oBO bweqfDMPEya1YpfXhreNTTPTAwt5y9+FCojyOkW6RBETkVyTfhj/VWel0fvqgOT3scvD OerQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=xAR750cVmWFsseE4dpZpC+gTizNbuk689vLbGrWjar8=; b=xEs8NyepSZJIjgI3Sv8uDdabwP6OkTp5sCq3F8SJiikHZW28rGKKRXnfTk3GjobXgy wZu6YU/ZOqkwAjYIQ20eUXehxHOG8PYPXkfxFokH2chRu5pZig/64iejE/+yxVTMXQwz jeCiSkoarUkd06ZN0UoZ5cvH2OARiJf79bWkh8dTySmttXfkblazyLUYfTxJ583+LSyu RfmFoHPzsUV+5hlUDZpfQQQDTicCiVUEeYKluVNXXqMZDOBG9OcNlfCBiSET/yTnLCVr gPZZVSnq6mGuU+VndLtb+8EBlHeT881+qmwj6EfBaxMSEDveNTHp3/AObpnXzL9/Aidz 61bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Py9qIiJz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k136-20020a636f8e000000b0052c575f1d8dsi1609671pgc.260.2023.05.24.17.44.42; Wed, 24 May 2023 17:45:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Py9qIiJz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232060AbjEYAN3 (ORCPT + 99 others); Wed, 24 May 2023 20:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbjEYAN2 (ORCPT ); Wed, 24 May 2023 20:13:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51606B3; Wed, 24 May 2023 17:13:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E243064085; Thu, 25 May 2023 00:13:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A514CC433EF; Thu, 25 May 2023 00:13:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684973606; bh=+sO/602AFB9zwrX7ybT2/4+Yeh6TWX6oBP4DUinmm54=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Py9qIiJzIpSMi4z4T9kyJPBchACoaSp3A7iYr1VpVzwqexoMOOdxYJ5zL5OeHBBrh JVYdNd2LlDfnVEOz+yR57rv1siSYYZknxy22r88FLLkcgMBn0rEJjkAM5AlenUyY9n YSpq5vCayYJ/0IQwEkZXafQkhLjDa0blKzDdRxBSfGwbZIc84fEYyDSmphBVwmUFGT +y5NOqyQwe3zB0EgVVKwN7jPInjmlyEVw5ydeTGxS3+CI96EtESizgB+hgSY8JQHtW zPTA2C8zsTuXitNWWQuW8MUze0j3t+GebrL5qJQEGqbtJabRmlA6V9aAHxlojW8k9R GI54H+pI+M0Zg== Date: Thu, 25 May 2023 08:13:18 +0800 From: Masami Hiramatsu (Google) To: paulmck@kernel.org Cc: Ze Gao , Jiri Olsa , Yonghong Song , Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Hao Luo , John Fastabend , KP Singh , Martin KaFai Lau , Song Liu , Stanislav Fomichev , Steven Rostedt , Yonghong Song , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, kafai@fb.com, kpsingh@chromium.org, netdev@vger.kernel.org, songliubraving@fb.com, Ze Gao Subject: Re: Message-Id: <20230525081318.b4984f7d5f3e89f70368fe71@kernel.org> In-Reply-To: <9dc981d5-e385-4468-9b51-64a10476c86d@paulmck-laptop> References: <20220515203653.4039075-1-jolsa@kernel.org> <20230520094722.5393-1-zegao@tencent.com> <20230523133019.ce19932f89585eb10d092896@kernel.org> <9dc981d5-e385-4468-9b51-64a10476c86d@paulmck-laptop> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 22 May 2023 23:59:28 -0700 "Paul E. McKenney" wrote: > On Tue, May 23, 2023 at 01:30:19PM +0800, Masami Hiramatsu wrote: > > On Mon, 22 May 2023 10:07:42 +0800 > > Ze Gao wrote: > > > > > Oops, I missed that. Thanks for pointing that out, which I thought is > > > conditional use of rcu_is_watching before. > > > > > > One last point, I think we should double check on this > > > "fentry does not filter with !rcu_is_watching" > > > as quoted from Yonghong and argue whether it needs > > > the same check for fentry as well. > > > > rcu_is_watching() comment says; > > > > * if the current CPU is not in its idle loop or is in an interrupt or > > * NMI handler, return true. > > > > Thus it returns *fault* if the current CPU is in the idle loop and not > > any interrupt(including NMI) context. This means if any tracable function > > is called from idle loop, it can be !rcu_is_watching(). I meant, this is > > 'context' based check, thus fentry can not filter out that some commonly > > used functions is called from that context but it can be detected. > > It really does return false (rather than faulting?) if the current CPU > is deep within the idle loop. > > In addition, the recent x86/entry rework (thank you Peter and > Thomas!) mean that the "idle loop" is quite restricted, as can be > seen by the invocations of ct_cpuidle_enter() and ct_cpuidle_exit(). > For example, in default_idle_call(), these are immediately before and > after the call to arch_cpu_idle(). Thanks! I also found that the default_idle_call() is enough small and it seems not happening on fentry because there are no commonly used functions on that path. > > Would the following help? Or am I missing your point? Yes, thank you for the update! > > Thanx, Paul > > ------------------------------------------------------------------------ > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 1449cb69a0e0..fae9b4e29c93 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -679,10 +679,14 @@ static void rcu_disable_urgency_upon_qs(struct rcu_data *rdp) > /** > * rcu_is_watching - see if RCU thinks that the current CPU is not idle > * > - * Return true if RCU is watching the running CPU, which means that this > - * CPU can safely enter RCU read-side critical sections. In other words, > - * if the current CPU is not in its idle loop or is in an interrupt or > - * NMI handler, return true. > + * Return @true if RCU is watching the running CPU and @false otherwise. > + * An @true return means that this CPU can safely enter RCU read-side > + * critical sections. > + * > + * More specifically, if the current CPU is not deep within its idle > + * loop, return @true. Note that rcu_is_watching() will return @true if > + * invoked from an interrupt or NMI handler, even if that interrupt or > + * NMI interrupted the CPU while it was deep within its idle loop. > * > * Make notrace because it can be called by the internal functions of > * ftrace, and making this notrace removes unnecessary recursion calls. -- Masami Hiramatsu (Google)