Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2582401rwb; Mon, 15 Aug 2022 07:48:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR4OxLJ/avFFlhxzuhwvWTlXSCwDwi/6mgP8PlE2H01CoMgYJAvbBBsy9z+gkhPlHUFa1XDK X-Received: by 2002:a17:902:d58f:b0:16e:da09:2cae with SMTP id k15-20020a170902d58f00b0016eda092caemr17506558plh.124.1660574907724; Mon, 15 Aug 2022 07:48:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660574907; cv=none; d=google.com; s=arc-20160816; b=GcTiecD5cK9YIORGKFZX3QTDE0+4s0hy9BaB+P5/G3cJae9rs1V+P88ad9QFgYykHr n6rGrbLsQmrpwQgOIVcDO1SH58xLKr3muGUaqrJ4TgKDrMkM1PJdhoo/BbHzpQoqCep/ Zo5pM6+mcupP8MkcT/r8/3PpPR/HTHjmDFzbfjNWL1ViLuqHo2ye3MVBvbzz3HGhbusq KTjiQ1w3f6wGyLWgZz3MZScvtpdVx+kKizbJ7cH/nASOcDLTDJfIBQsyJvIyb5r24QfC cMu+3weebzv4PxIwviEfTQTwOTkCZZIsDkoputeB/M4DCFrBSA5AcmESZNpZMbOsafCB D4lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2r6NzV5K6JWHUt1ICx2UuX4Y6Ch+fw7Dtg6Kfge6QGc=; b=jC2WuVZ+wpI6NlxTX/fEjBzOaXLbkr4Jb3f2fTHEl146aOrs3h2zFRdNZ7Utyk1sTg cn2zL2vCRqCMu/oroKymdx7IhByDIlVfVIyE5MDaz7u1IwyPmvX0B7xBSCL2O2dN6Wht rSiyMwKz1buzAg1dVlOwJnjRZbWC0gPUu/OUKnUHCSK+GYpaeTcMJdxVp4xc9nu1v+oX 2FpCxittsKxIvwISSFYp4U3TJ5STtMjc/jmF0M84hr4RXxBzli30/Pbwt5ndtjqj5LZi GWOpTe0i6+RqyF2Ix598QqYD+ni82k0Ipab4L77PBMRHV+cCCsIGJh8MV41sDvIT2o8R i5VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GbLvWxDI; 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 j4-20020a170902da8400b0016da4f41949si12536027plx.550.2022.08.15.07.48.16; Mon, 15 Aug 2022 07:48:27 -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=GbLvWxDI; 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 S230020AbiHOOpf (ORCPT + 99 others); Mon, 15 Aug 2022 10:45:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiHOOpd (ORCPT ); Mon, 15 Aug 2022 10:45:33 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E7AF25D5; Mon, 15 Aug 2022 07:45:29 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id y3so9855701eda.6; Mon, 15 Aug 2022 07:45:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=2r6NzV5K6JWHUt1ICx2UuX4Y6Ch+fw7Dtg6Kfge6QGc=; b=GbLvWxDIxgFLq5piP6F2dgRYWQ7rxguDDupe74SrAo+hBy5g3C1mk2+YmJ0k+PTxMQ PL/jU34GR/M47O/iNmJg77vJxUJcZUPo0CyVNv/hL+A+XM9D9ci6LI79UjLt9Scwc/8V Ru6Bds+2ciVWKzxnWXuIHak+rf47n2Hjw+zTz9JEZTyvH11eoEiS+BbTehbWr/9x6E2Y bKatp+ABbIJ3XeAADXbpVBk5aoyFHe6Znbudn5TZapQexuNE6skwj3xkl2eZ8Asrn7Tl JcmmSsWLqGcfrSOH+YpMQQpaSZt72DWQsvafSlK7vSuw0gzoGoqdhLm91dXRnMlIHQT8 vL3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=2r6NzV5K6JWHUt1ICx2UuX4Y6Ch+fw7Dtg6Kfge6QGc=; b=rFVUZR5kwK2BSVn9mIuScrhFmsUpADFpjELiHrjLnf3vfBEBVTv5966NF4VxdA1o0G EODqsPILm6p/M8cuVEHEoBHnrQVcZwit7VfOmHp7YU24CrmCIAOr2Y//Jf+2F9fOfJo9 rHB9/9aQ0JfT833N6ECkyz9ZZISIxMzxseKk2lSIW9gKCj2BGwtJVe1Mvv17Hd2Yz5YU aBFozAuTI7tKMVDKzgihZDgyjqiOuOMTXzdVAXALdu1D4yYhI0oVA3tBE2tQYsrOnRmo /1ItVg3HeQ5X8h+qw8hNEFvv+hif/DJ9uQ1XgyiERsvj8yKarz32WtLRoZpHlsw3HZCT h0Tg== X-Gm-Message-State: ACgBeo16xEkt94tgkCnR82vB0qFE3Q8VT2eDg7fTD9K/naYtpIt5wPdI y27nmrdyG6NdEwo/jylDQESgAGhsNd6UrePKA7Q= X-Received: by 2002:a05:6402:28cb:b0:43b:c6d7:ef92 with SMTP id ef11-20020a05640228cb00b0043bc6d7ef92mr15211708edb.333.1660574728199; Mon, 15 Aug 2022 07:45:28 -0700 (PDT) MIME-Version: 1.0 References: <20220722122548.2db543ca@gandalf.local.home> <20220722174120.688768a3@gandalf.local.home> <20220813150252.5aa63650@rorschach.local.home> In-Reply-To: From: Alexei Starovoitov Date: Mon, 15 Aug 2022 07:45:16 -0700 Message-ID: Subject: Re: [RFC] ftrace: Add support to keep some functions out of ftrace To: Peter Zijlstra Cc: Jiri Olsa , Steven Rostedt , 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 Content-Type: text/plain; charset="UTF-8" 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, Aug 15, 2022 at 7:33 AM Peter Zijlstra wrote: > > On Mon, Aug 15, 2022 at 07:25:24AM -0700, Alexei Starovoitov wrote: > > On Mon, Aug 15, 2022 at 5:37 AM Peter Zijlstra wrote: > > > > > > On Mon, Aug 15, 2022 at 11:44:32AM +0200, Jiri Olsa wrote: > > > > On Mon, Aug 15, 2022 at 10:03:17AM +0200, Peter Zijlstra wrote: > > > > > On Sat, Aug 13, 2022 at 03:02:52PM -0400, Steven Rostedt wrote: > > > > > > On Fri, 12 Aug 2022 23:18:15 +0200 > > > > > > Jiri Olsa wrote: > > > > > > > > > > > > > the patch below moves the bpf function into sepatate object and switches > > > > > > > off the -mrecord-mcount for it.. so the function gets profile call > > > > > > > generated but it's not visible to ftrace > > > > > > > > > > Why ?!? > > > > > > > > there's bpf dispatcher code that updates bpf_dispatcher_xdp_func > > > > function with bpf_arch_text_poke and that can race with ftrace update > > > > if the function is traced > > > > > > I thought bpf_arch_text_poke() wasn't allowed to touch kernel code and > > > ftrace is in full control of it ? > > > > ftrace is not in "full control" of nop5 and must not be. > > It is in full control of the 'call __fentry__'. Absolute full NAK on you > trying to make it otherwise. Don't mix 'call fentry' generated by the compiler with nop5 inserted by macroses or JITs. > > Soon we will have nop5 in the middle of the function. > > ftrace must not touch it. > > How are you generating that NOP and what for? We're generating nop5-s in JITed code to further attach to. For example when one bpf prog is being replaced by another. Currently it's in the func prologue only. In the future it will be anywhere in the body.