Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4150283iob; Tue, 17 May 2022 15:23:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx89Miwxl94+gTh/VcvZi3gWfdkj0uljU5yWcEalrFCJlRYdsaub4r7MliPfh9lMalkjTwH X-Received: by 2002:a05:6402:d0e:b0:413:3d99:f2d6 with SMTP id eb14-20020a0564020d0e00b004133d99f2d6mr21722317edb.189.1652826201171; Tue, 17 May 2022 15:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652826201; cv=none; d=google.com; s=arc-20160816; b=yYnAem79XFoa/1J5INa3xNmmRM0Sd+UnNFS2D5Ura29hOqMv6W6qLNjqaEH/rWQY12 LoMu3BOyRDrLGp6OvDDMdl4869yRP3UO/N3M5r7adkinTtf0+k1IFUZM/Kjl27YHXta8 /EyeNhutTG6n1LyfWxsbF3e6L4I+9xdlbJp4VhbFyaZm35AmWGnOgEpRkcW0GLAPT5MV VEEN8Rgjb6g6iO/0tcbu+nammujVYStQq3SJiHel+4b96KntimT/OSWbRypZFxUoWBnq 4/JZ04qcgLdvPG5W5kuHBlj5rbcDkshE8HYwHvf4uisKIEvRMiuto9KK4+FXifybta6y ceNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=WTGEJWoQ+KMazLH3yrW+72dqg/PgbNlHkEqCaVYjBog=; b=C8S5CgL401ty3Jl4F3wA20z7uY93eW6nRm/mXBgWiDtIL2UfVNFmRNBW8ii0grSHgg mysG6aBPj0Y1/ydtif0maSoXx0X9XSlROnSB5/CYkqMCRfIe+CfAeaICW45h4Z2WFw58 yrcWI9FeZMythOj7XWgNAex4pQHX0+VHcfAUr6lvHZoe54d9geMxS2BtscQyIfo2JaVz NyM7pxE7kmiZdCZzGqE1X4PUDYKfmVwr2RfkSEagIyTusWuwlBMIWz3ShAvQsJmqRkRH R9AvomTJDz4ipcBahX2S5nTFy/dIeZ0PRT5MQBe9wtuUVMRXtd5Aq1YvWkHAChlIahDz 0DRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=S3tFYVXP; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u25-20020a056402065900b00425d2ee6cdasi451461edx.412.2022.05.17.15.22.55; Tue, 17 May 2022 15:23:21 -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=@gmail.com header.s=20210112 header.b=S3tFYVXP; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230078AbiEQHtm (ORCPT + 99 others); Tue, 17 May 2022 03:49:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240976AbiEQHtj (ORCPT ); Tue, 17 May 2022 03:49:39 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80A5445042; Tue, 17 May 2022 00:49:38 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id r30so5799973wra.13; Tue, 17 May 2022 00:49:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WTGEJWoQ+KMazLH3yrW+72dqg/PgbNlHkEqCaVYjBog=; b=S3tFYVXPftNGoe5TTjpXm86BtSRghMjVlXdOUH2GD46ypvT1ThoEiwVTzn7hgCGpJk +nHv0D//dyxLGIkqyM81f3shdBf/VjFq0DIkE9F9u2HKyakKyu/E+jPaM3Z/3vskPz9z CGZmze3XBYZgRhfGtTfYZjC01r8YvACZ9Gb9j6c81Uy9iRMyFcqaPIcPOP5hIoGVePTW dFewKBjJ38Ksu+dAIpzjG2FomSnV8cEFnnXxyMf5qbB0BBSK2O/Dhl2GsowhnjvunWpW tx3yeC92V1dHnI4zakpxXu8sJtW4pnncqdJNE28QdzM2I2bFkORTcquXiL3OeNiVxnql tl1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WTGEJWoQ+KMazLH3yrW+72dqg/PgbNlHkEqCaVYjBog=; b=iL6buniMRSDpD2xPO5RjodaB9AYGzA0MIVtAWmdhuj82DMnJiujvz+Yp4iGpPaUQvh GvsDA75HIHSq8xnY/9cRI6DGEq5J15NRKedpWHERfe6KchdTaonPFrLTMDu42G1p5/Kv d3p9muqnUgsy0+mfhLK1pNdDMaOnSzOvJH/estgGQAdnYEAy78nwAQrov5ToIryetXFI WJxr0V7Xkp9MNRV6h9SgnpBUU6GEd3KSZl+4vdFOdeBQfb0XeCZBy4wdzZorp9ChCNsX N4EGPYBtZOdtcUq5mfBxrgn7q3Rrg4dlXyzX+O0F4LRVckzMYHKqTasKXr2FnLSSpa5X 9iTw== X-Gm-Message-State: AOAM532TTcurBjozB4OYhATmKnItdFGfhqz5jOZ32RBADQBlCulnBAFY esacUuQCoJrX0dZ3J2JeL4A= X-Received: by 2002:a5d:4988:0:b0:20d:9b8:e560 with SMTP id r8-20020a5d4988000000b0020d09b8e560mr6820985wrq.33.1652773776628; Tue, 17 May 2022 00:49:36 -0700 (PDT) Received: from krava ([193.85.244.190]) by smtp.gmail.com with ESMTPSA id m26-20020a7bce1a000000b003942a244f3fsm1200543wmc.24.2022.05.17.00.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 00:49:36 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Tue, 17 May 2022 09:49:33 +0200 To: Yonghong Song Cc: 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: References: <20220515203653.4039075-1-jolsa@kernel.org> <5b4bd044-ba88-649b-9b85-e08e175691f9@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5b4bd044-ba88-649b-9b85-e08e175691f9@fb.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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, 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 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;