Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1504959rwb; Fri, 19 Aug 2022 05:02:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR7vk0k3a1tGcVgro+sCFue/HWVeuNzkP378bZdOoypglJIZdKGk9YIQEblWZDsGoO7Dm2t/ X-Received: by 2002:a17:90b:3ec9:b0:1f5:62d5:4157 with SMTP id rm9-20020a17090b3ec900b001f562d54157mr13370950pjb.183.1660910574876; Fri, 19 Aug 2022 05:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660910574; cv=none; d=google.com; s=arc-20160816; b=sp8d62jBkbrWST5JzbfNKY6fchpN7q+KfMM4GJvh7oK/jH3U0o/0nAFHy+19UUWgwi idB6FXq0WdipvRmcJZiWPhwX759OW3ohpRZMqp1KaqzEM9/wJfYrsyu7d7vWlaCfwnY3 GPS9qVvmVyhqQGWupRcQ0r7jlhzyyvWwzEMvx5DowHLXAU6x6u2bK7QEopDAcGSe1cGB yv0eRtIa2O0FWrl/x8DT7IvCEvRlOMQt9AN8M55xE5ip+ikLPZ1UZoP4zqVFCNGjijfT LWqeu5UqAdiT8F9/sClQk4as5ymqxIFeovXSYeihHCjjj7bEue8H9FGXomNphyAquDCf XHJg== 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=LcUynb5n3WhFbuZbjn2oHGF/Y+MnFz6wVGyUbmw+SU4=; b=V6eW5WYf9kyRcHE5hiSIODXQXRKRhISA4aRMw5+VZFriaz8inNNXTb0Iu9wNswpJK5 FqVEw5QQRkA01CAkdI8HCZ1NDXDDwDtYbW0UNmZANbf2voS5Gz8LV09s919M5C7ZvofH Ieln/VJmuWygKJ/6mdRzqxvfN03s4FZYoZv+/IS1gr8wAFCFs0Xrg/m3chzT0wm6cIt6 vdKCWsGFLNRf2nPg6jEiKQZPhPDfS55YHMiSBWBgqRGlMcf5Os1Qn8UxDkf2Rg+TV/7I hQA3Rhm+INw+WdHxs1w1/mg0lq5JSRz6obcIrR+QEJi/UQXkMeVBdjmTjcmSEX+Pzax7 UDSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DqkUN6P7; 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 j17-20020a63fc11000000b00429ee0682b5si2142896pgi.404.2022.08.19.05.02.43; Fri, 19 Aug 2022 05:02:54 -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=DqkUN6P7; 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 S1348657AbiHSLpp (ORCPT + 99 others); Fri, 19 Aug 2022 07:45:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348721AbiHSLpj (ORCPT ); Fri, 19 Aug 2022 07:45:39 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99118DB061; Fri, 19 Aug 2022 04:45:38 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id j8so8300510ejx.9; Fri, 19 Aug 2022 04:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc; bh=LcUynb5n3WhFbuZbjn2oHGF/Y+MnFz6wVGyUbmw+SU4=; b=DqkUN6P7DF41mG4HiHPhFzm2IINrpiF/9wMLAqaL4QdSjmOWp7/y6DmKmXHkD/629m t2ZD8CmIIXgfkRhfnCYVNcX/c6iFnjpMKZsD0/aPZ2shyXlpB70Z3RwDQgenMwLOVvvW mPWmqCXYCelepQLKimhHbNlQpt1mvnquCn43n5ZGgvTOul40oDSfQWetaY9B4tXm9G2U JXA60D8ob20UTbdoYNi3W+y4qspNlRlkCKnYD5L8E0FXaRPEe/BBahem1uzsFoDJGO3T JE2zd19V60xBOFa7dwCondytnl749PLFnj2mN0XJzjif9o1alPbYCwp6CWTR+y1y7EBU WVig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc; bh=LcUynb5n3WhFbuZbjn2oHGF/Y+MnFz6wVGyUbmw+SU4=; b=IVcIAslup0l896kGPgNF0Rrn1VWBJ7xPY1qXHGDi+CTna6/ZFE4DBFXVpIawkrVN1c KBOiRe8BqLBSNvcpXZZDGxOMait74A0L6Czuc3Iwa9WSVbCJSeMaj86C8/qA1dbQEWB8 /T8r/ygGxZyk28ZtfOuTCeT3emN0QYDr16EegY2bctwCn6QQEq7JFO/YxRbAYoB7PlwZ MO3vy/SPw72hMk6PnPA2ABKID8dRZNkJfQ2VxzS+drv/2GajKTXxTNTW0kRa1fFHBUaM nyOm7syFpkwOEgi6ivxWAPXtkJsLcamI6MegtdG5CyYeqLw29kn5d02FfbwoV5rV9TzJ L3xA== X-Gm-Message-State: ACgBeo3dTv1eeWp1SVZ2zmulXmPAtn9C86LsPzK2dASJNaEUwAguS2zZ PxYDX5kqF2e69Iesml68tsE= X-Received: by 2002:a17:907:6d24:b0:731:7720:bb9b with SMTP id sa36-20020a1709076d2400b007317720bb9bmr4628015ejc.717.1660909537122; Fri, 19 Aug 2022 04:45:37 -0700 (PDT) Received: from krava ([193.85.244.190]) by smtp.gmail.com with ESMTPSA id kv10-20020a17090778ca00b0073d56f5757asm357707ejc.223.2022.08.19.04.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 04:45:36 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Fri, 19 Aug 2022 13:45:34 +0200 To: Jiri Olsa Cc: Alexei Starovoitov , Steven Rostedt , Peter Zijlstra , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Ingo Molnar , bpf , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , LKML , Josh Poimboeuf Subject: Re: [RFC] ftrace: Add support to keep some functions out of ftrace Message-ID: References: <20220818165024.433f56fd@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Aug 18, 2022 at 11:32:55PM +0200, Jiri Olsa wrote: > On Thu, Aug 18, 2022 at 02:00:21PM -0700, Alexei Starovoitov wrote: > > On Thu, Aug 18, 2022 at 1:50 PM Steven Rostedt wrote: > > > > > > On Thu, 18 Aug 2022 22:27:07 +0200 > > > Jiri Olsa wrote: > > > > > > > ok, so the problem with __attribute__((patchable_function_entry(5))) is that > > > > it puts function address into __patchable_function_entries section, which is > > > > one of ftrace locations source: > > > > > > > > #define MCOUNT_REC() . = ALIGN(8); \ > > > > __start_mcount_loc = .; \ > > > > KEEP(*(__mcount_loc)) \ > > > > KEEP(*(__patchable_function_entries)) \ > > > > __stop_mcount_loc = .; \ > > > > ... > > > > > > > > > > > > it looks like __patchable_function_entries is used for other than x86 archs, > > > > so we perhaps we could have x86 specific MCOUNT_REC macro just with > > > > __mcount_loc section? > > > > > > So something like this: > > > > > > #ifdef CONFIG_X86 > > > # define NON_MCOUNT_PATCHABLE KEEP(*(__patchable_function_entries)) > > > # define MCOUNT_PATCHABLE > > > #else > > > # define NON_MCOUNT_PATCHABLE > > > # define MCOUNT_PATCHABLE KEEP(*(__patchable_function_entries)) > > > #endif > > > > > > #define MCOUNT_REC() . = ALIGN(8); \ > > > __start_mcount_loc = .; \ > > > KEEP(*(__mcount_loc)) \ > > > MCOUNT_PATCHABLE \ > > > __stop_mcount_loc = .; \ > > > NON_MCOUNT_PATCHABLE \ > > > ... > > > > > > ?? > > > > That's what more or less Peter's patch is doing: > > Here it is again for reference: > > https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/commit/?id=8d075bdf11193f1d276bf19fa56b4b8dfe24df9e > > ah nice, and discards the __patchable_function_entries section, great > tested change below with Peter's change above and it seems to work, once it get merged I'll send full patch thanks, jirka --- diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 39bd36359c1e..39b6807058e9 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -924,6 +924,8 @@ int arch_prepare_bpf_dispatcher(void *image, s64 *funcs, int num_funcs); } #define DEFINE_BPF_DISPATCHER(name) \ + __attribute__((__no_instrument_function__)) \ + __attribute__((patchable_function_entry(5))) \ noinline __nocfi unsigned int bpf_dispatcher_##name##_func( \ const void *ctx, \ const struct bpf_insn *insnsi, \