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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CF0AC433F5 for ; Fri, 24 Sep 2021 03:36:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 369CC60232 for ; Fri, 24 Sep 2021 03:36:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244029AbhIXDi3 (ORCPT ); Thu, 23 Sep 2021 23:38:29 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:39977 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243927AbhIXDi2 (ORCPT ); Thu, 23 Sep 2021 23:38:28 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R601e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=yun.wang@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0UpOFzWH_1632454613; Received: from testdeMacBook-Pro.local(mailfrom:yun.wang@linux.alibaba.com fp:SMTPD_---0UpOFzWH_1632454613) by smtp.aliyun-inc.com(127.0.0.1); Fri, 24 Sep 2021 11:36:54 +0800 Subject: Re: [RFC PATCH] trace: prevent preemption in perf_ftrace_function_call() To: Steven Rostedt Cc: Ingo Molnar , open list References: <2470f39b-aed1-4e19-9982-206007eb0c6a@linux.alibaba.com> <20210923093359.30da8ba6@gandalf.local.home> <7f4dfb4a-d271-b3c5-f603-06cc789ba9e9@linux.alibaba.com> <20210923232619.50103473@oasis.local.home> From: =?UTF-8?B?546L6LSH?= Message-ID: Date: Fri, 24 Sep 2021 11:36:53 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210923232619.50103473@oasis.local.home> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/9/24 上午11:26, Steven Rostedt wrote: > On Fri, 24 Sep 2021 10:08:10 +0800 > ηŽ‹θ΄‡ wrote: > >> I found the rcu tree implementation of rcu_is_watching() will check >> this_cpu_ptr(&rcu_data.dynticks), and after that enable the preemption. >> >> If preemption happened after that and before we disable here, there are >> still possibility that the CPU changed and make the dynticks checking >> invalid, isn't it? > > If it can be scheduled, then RCU is definitely watching ;-) > > The rcu_is_watching() is a safe guard for places that are in between > context switches. Not task context switches, but transitioning between > kernel and user space, or going into or out of idle, or transitioning > in and out of an interrupt. There are small critical sections that RCU > is not watching, and we are actually working on making those locations > disable instrumentation (like tracing), where rcu_is_watching() will no > longer be needed. Thanks for the explain :-) Context available for scheduling should not in these situations, will move down the 'disable' in v2. Regards, Michael Wang > > -- Steve >