Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1139063iob; Wed, 18 May 2022 23:29:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuvuu0uxli3jLnxdq5HuOz8uO6aaiifYMoygV8RmsQ4VnVL2lfzhuikCiMhMnN9BKFauFN X-Received: by 2002:a17:907:96ab:b0:6f4:e973:7eba with SMTP id hd43-20020a17090796ab00b006f4e9737ebamr2825398ejc.593.1652941745081; Wed, 18 May 2022 23:29:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652941745; cv=none; d=google.com; s=arc-20160816; b=ZAlCJgrRqUkmo+FYzmf80B8p703Q06/slLZtMbz56LB9mH5C2OpmDQF0jOiy3o60Dp 6nRFa7npcXupKsCAI6FqXvlXMRKcsKTFD5TIeu4Tz4pQ9IU7s279pAxTEJD/A5dn/pJM BbEtYGx4iKgLjP6oWtQ/MSruVG27b6dgkHPgCipU4UCGCayFA5F85+6TcUT+sQ49U8SV BrjBKkGdPoGToBRQsrmaz50LXUQy2bsVuqQ4mQP9TsjpzxTZ1EwNeH0Kjjex7pAEpQPb ELTU8zkaTnIUG2TQxNNCzgzkgJXYPUtGq79zebVkRn25fZozk5x+RbjhbISPXKlH4+2Z xVJw== 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=g+I8CAvujQQjyl8FTA/Tpc6oVakaz6zNYARLQrzMSqs=; b=zxFTfv4QtlXS7kVE08UwNQZ0F6/zLC8vTbhgD0iJW4kX5bc+F0Dh4wbWFMHlxQMIki 9gWNhWgTxENeAPCoLgJJc4XDotNe3gUguAlVROMv0MO0Jq/EtWGMARrb9Iuikwue3xZW h5cbXiYy8zXRJM1+nVf9yZ/JMvzU3QhFNMAK+L0lPXnxpcyjW26eDEKpYY7cqJYBRRgH 0239M5aEByzrLmARkU2YmoDbMFBE/cuu65oTG6IYOz+iLDhFOCclLoZXeDv9bIdhtvcI UXMrTBgbxlnCHkguRT+pP6bVi9jHSIxIJNLK41DoGjsLBv5aDI3pr1HsAgZbqpbHL0F4 SQyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZDyT9+Vw; 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 t20-20020a1709060c5400b006f3ed35a97dsi4160672ejf.63.2022.05.18.23.28.37; Wed, 18 May 2022 23:29:05 -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=ZDyT9+Vw; 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 S231132AbiESAAb (ORCPT + 99 others); Wed, 18 May 2022 20:00:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbiESAA3 (ORCPT ); Wed, 18 May 2022 20:00:29 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BECBA443; Wed, 18 May 2022 17:00:28 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3E6BDB821A0; Thu, 19 May 2022 00:00:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D35ADC385A9; Thu, 19 May 2022 00:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652918426; bh=UJDjyjdzJqFlsW+gZGyIlrnGpTTEXVykogO9NpO8GSg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ZDyT9+VweRaKpvQzDQcdDwZvvGOP9AJ/iYyLTzBQYbYX4thh2d9uTI/Z+SLGY5L/n qsPsewTWZI9TvWUgzSL7Ev5t2s12Bc/c8P4VbHBNgf2PIfrprC710OCCSLk0e/FMxF IAWC/4Y+q85nKQlyLA5/8j3aXJUrFg6jduAQUAVT62cEf3JtsxgZMKXyaP3SHu/az8 P3x/MTOrPi9BUlcZjmwS78UQoK17ALBH47vL1mUwTSx0trXghcJrqmqe0zzetF07AT jzB2uavtwPyMhP8VEMHT2u9E1qfonCneVuFnJNZNRVVsWd6+9MoJpAL27ahfyLn8Xn hndLL75AC6BFQ== Date: Thu, 19 May 2022 09:00:20 +0900 From: Masami Hiramatsu (Google) To: Jiri Olsa Cc: Yonghong Song , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Masami Hiramatsu , "Paul E. McKenney" , netdev@vger.kernel.org, bpf@vger.kernel.org, lkml , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , Steven Rostedt Subject: Re: [PATCH bpf-next 1/2] cpuidle/rcu: Making arch_cpu_idle and rcu_idle_exit noinstr Message-Id: <20220519090020.828c697fcf4767722d02bc1a@kernel.org> In-Reply-To: References: <20220515203653.4039075-1-jolsa@kernel.org> <5b4bd044-ba88-649b-9b85-e08e175691f9@fb.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; 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=-9.5 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 Tue, 17 May 2022 09:49:33 +0200 Jiri Olsa wrote: > On Mon, May 16, 2022 at 07:54:37PM -0700, Yonghong Song wrote: > > > > > > On 5/15/22 1:36 PM, Jiri Olsa wrote: > > > Making arch_cpu_idle and rcu_idle_exit noinstr. Both functions run > > > in rcu 'not watching' context and if there's tracer attached to > > > them, which uses rcu (e.g. kprobe multi interface) it will hit RCU > > > warning like: > > > > > > [ 3.017540] WARNING: suspicious RCU usage > > > ... > > > [ 3.018363] kprobe_multi_link_handler+0x68/0x1c0 > > > [ 3.018364] ? kprobe_multi_link_handler+0x3e/0x1c0 > > > [ 3.018366] ? arch_cpu_idle_dead+0x10/0x10 > > > [ 3.018367] ? arch_cpu_idle_dead+0x10/0x10 > > > [ 3.018371] fprobe_handler.part.0+0xab/0x150 > > > [ 3.018374] 0xffffffffa00080c8 > > > [ 3.018393] ? arch_cpu_idle+0x5/0x10 > > > [ 3.018398] arch_cpu_idle+0x5/0x10 > > > [ 3.018399] default_idle_call+0x59/0x90 > > > [ 3.018401] do_idle+0x1c3/0x1d0 > > > > > > The call path is following: > > > > > > default_idle_call > > > rcu_idle_enter > > > arch_cpu_idle > > > rcu_idle_exit > > > > > > The arch_cpu_idle and rcu_idle_exit are the only ones from above > > > path that are traceble and cause this problem on my setup. > > > > > > Signed-off-by: Jiri Olsa > > > --- > > > arch/x86/kernel/process.c | 2 +- > > > kernel/rcu/tree.c | 2 +- > > > 2 files changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c > > > index b370767f5b19..1345cb0124a6 100644 > > > --- a/arch/x86/kernel/process.c > > > +++ b/arch/x86/kernel/process.c > > > @@ -720,7 +720,7 @@ void arch_cpu_idle_dead(void) > > > /* > > > * Called from the generic idle code. > > > */ > > > -void arch_cpu_idle(void) > > > +void noinstr arch_cpu_idle(void) > > > > noinstr includes a lot of attributes: > > > > #define noinstr \ > > noinline notrace __attribute((__section__(".noinstr.text"))) \ > > __no_kcsan __no_sanitize_address __no_profile __no_sanitize_coverage > > > > should we use notrace here? > > hm right, so notrace should be enough for our case (kprobe_multi) > which is based on ftrace/fprobe jump > > noinstr (among other things) adds the function also the kprobes > blacklist, which will prevent standard kprobes to attach > > ASAICS standard kprobes use rcu in probe path as well, like in > opt_pre_handler function > > so I think we should go with noinstr Yes, I agree that noinstr is preferrable for these functions. Thank you! > > jirka > > > > > > { > > > x86_idle(); > > > } > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > > index a4b8189455d5..20d529722f51 100644 > > > --- a/kernel/rcu/tree.c > > > +++ b/kernel/rcu/tree.c > > > @@ -896,7 +896,7 @@ static void noinstr rcu_eqs_exit(bool user) > > > * If you add or remove a call to rcu_idle_exit(), be sure to test with > > > * CONFIG_RCU_EQS_DEBUG=y. > > > */ > > > -void rcu_idle_exit(void) > > > +void noinstr rcu_idle_exit(void) > > > { > > > unsigned long flags; -- Masami Hiramatsu