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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DD25D21269 for ; Thu, 17 Oct 2024 09:35:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B3CE6B0083; Thu, 17 Oct 2024 05:35:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 263DE6B0088; Thu, 17 Oct 2024 05:35:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 105D76B0089; Thu, 17 Oct 2024 05:35:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E704C6B0083 for ; Thu, 17 Oct 2024 05:35:52 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A1C62AC5BE for ; Thu, 17 Oct 2024 09:35:30 +0000 (UTC) X-FDA: 82682586756.20.9F0AFEA Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf01.hostedemail.com (Postfix) with ESMTP id B916A4000E for ; Thu, 17 Oct 2024 09:35:40 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=XiFI8B0o; dmarc=none; spf=none (imf01.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729157632; a=rsa-sha256; cv=none; b=517FpC3iX8CYsZ9Tj5qKpNgNvv4HVVe9pyQjElrfZHprkvM/Nvf8v99pYkmxSufnFrKz8R bvelxns6/nk+eU4LQJdxGTyxkFGsAdnGOVy3EsEy6/K6spzcyZwBSbO4bWf2qzmhOSZOhX kpL+zcLbCDfaHnLlEzxk1eJ+8/mXYtY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=XiFI8B0o; dmarc=none; spf=none (imf01.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729157632; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VVu7cX1SI2+XfnYlKmwbrDG3+CJWOAmt2jAl9wbUo9k=; b=Lv2zIasfciqyWUrUjmaR0vIduE1qJ6MdcZGvRZy1btbDWg5dcm8WXmiy3MKsMiRA4tS84l Amp1/Jo+t/icNZuYBaMBHk46LERzN+v9kTslGWWZoUFRLZSTmNfwU+vVl+93TKwyU2a0si 0q+cveJNJJBCjIUq2HEHQSjgylukKsQ= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=VVu7cX1SI2+XfnYlKmwbrDG3+CJWOAmt2jAl9wbUo9k=; b=XiFI8B0ovduSIe40JjuY242meO 1tWdoXPB8Y4u6FvdJlkOh0pr/b+ptTLEARYM4Fz0YcPpgeZ6S8vIFL3pv7C67je495kkW38x9jgPx kZcvMosNEICP21MaeTfL4OcNrqj3D/g6hBzGdP9sE2b36zBWvYJp4QWDybwMxKdlcL3ZpeYi7ki7+ suQtk2YIywEtSE8+GUQPkWxddDo9J2uY+LZoII7Oa4V1WDt8U55u9QC4d2zaOtcNPZVh6JsT6n2VV yz3mabQVBKOF3bVpb3D/1s3d5tFfjBLa1mZAU7RdfOnmovvB/POi51RCfYsgOa7ik7FCs2q+EK5D6 fjlJqizw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1t1Mua-000000075pE-1Ofh; Thu, 17 Oct 2024 09:35:17 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id EF73A3005AF; Thu, 17 Oct 2024 11:35:15 +0200 (CEST) Date: Thu, 17 Oct 2024 11:35:15 +0200 From: Peter Zijlstra To: Steven Rostedt Cc: Mike Rapoport , Andrew Morton , Luis Chamberlain , Andreas Larsson , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Brian Cain , Catalin Marinas , Christoph Hellwig , Christophe Leroy , Dave Hansen , Dinh Nguyen , Geert Uytterhoeven , Guo Ren , Helge Deller , Huacai Chen , Ingo Molnar , Johannes Berg , John Paul Adrian Glaubitz , Kent Overstreet , "Liam R. Howlett" , Mark Rutland , Masami Hiramatsu , Matt Turner , Max Filippov , Michael Ellerman , Michal Simek , Oleg Nesterov , Palmer Dabbelt , Richard Weinberger , Russell King , Song Liu , Stafford Horne , Suren Baghdasaryan , Thomas Bogendoerfer , Thomas Gleixner , Uladzislau Rezki , Vineet Gupta , Will Deacon , bpf@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-trace-kernel@vger.kernel.org, linux-um@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v6 6/8] x86/module: prepare module loading for ROX allocations of text Message-ID: <20241017093515.GU16066@noisy.programming.kicks-ass.net> References: <20241016122424.1655560-1-rppt@kernel.org> <20241016122424.1655560-7-rppt@kernel.org> <20241016170128.7afeb8b0@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241016170128.7afeb8b0@gandalf.local.home> X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B916A4000E X-Stat-Signature: co8seb7hco8mf93ocnwwowzoobb53ds9 X-Rspam-User: X-HE-Tag: 1729157740-475829 X-HE-Meta: U2FsdGVkX19Wm9dzu8NH+IGfq1odw57Ry2EyXd7ze5B1OHkDm4oSPnECmjkc+P2oTQpcBBu9wMMGUHkOCM6GBVtFp/Hb9gNwGyNFzquLdrGLCHZGxkBdJa4AjLzJ4ETPfQYOHDDuymw2wfDrYTCAY6ID6tx+Ww4LiXEBbNFu3jTe79udJDPpHCOIGDm9vG5Od68vWzkHJv7qBbikrH6IkLiVhmw2o0hzP2VLXpDq9tMh+RtUqq313PfRrpkZPluYn3IP839jke3hYkPytEBtLbpoGlnuYpI5Bxa1ec45X5mH2AnEviF8hFOZYEGI97w6jNyVzgcyJwoxTbrvLaHNUd19A9r9EuErIguUXob0kWFFh562+GQ0bCinz5XTjGCqLgaDLnmY/t1jo6M2mbMGsgpH/NmsYeUUv2ddO7sNdJIexWKg52T5goiud6evj533jfkU1/UrCJ4wYy5dF2/o0S5MHXoCeBGk79i38k3y+Z8ydqaQ9cjhJeHkSnn6W+qB8FQAiNHZc3Bs5sS2gAX696bFrm/7NtHKY8Mb2WDiF2mor1n/ZuP1VrGvm8tEWKaHbVV7965ycCnRGiZIciwkdcRatY56YHNQRt2Y6sPu/BZIFsO5yeo5bbhjR6A7jQLSNOIGJDSb3l+WMET1to6azUmfsUSJ2DJdshARF9XUFYabqhod5/Z17s2xiCzUUAEYFYAuKP/2qT5PnNXKtM2yNhYlVuRlHmbdMWCMeM4qn49xmVwso2h9G8AWdLyRuGxqxEnIoEU31MlhmHTUVWj2yTBfYZGo+jpqJ1ioawpSfdfnu5pICfr2fpEsHK2XZIRPhRAtbUzo6Ijbm94FvN1V6F63tF5KKvATp14k1+R1g81uitowP/36lMHKprQojjx/r5lcmxpXa+7EF/1tXpWwLkgYGXgdYDT9ktPKm9H5NqIbuEZ7Eh476SVgRySfsoGUKzvXBA63iESTEdwpEfs PMUm/NGF Q1Oy4vzsYV/1nNrNgunJCdMKWX1EkQzzQcv9n4ITcDVLtCkctjpv6AHlOMJGwlm2f8R2Y5I9Ei/QIzoToPZVs0meae4rJexA+gt6Ty90mX5Cjz+XBpVo3c/F5SevnK/C0Xo/vKZz2oZ0I3TVbqW3Ic8dyaFU5LZjQJfx7IkLbSBs/XqCzxMBrq9T2bNRdCSwyNa82B6NmJgEI8f6B2pCO8zVCzQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Oct 16, 2024 at 05:01:28PM -0400, Steven Rostedt wrote: > On Wed, 16 Oct 2024 15:24:22 +0300 > Mike Rapoport wrote: > > > diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c > > index 8da0e66ca22d..b498897b213c 100644 > > --- a/arch/x86/kernel/ftrace.c > > +++ b/arch/x86/kernel/ftrace.c > > @@ -118,10 +118,13 @@ ftrace_modify_code_direct(unsigned long ip, const char *old_code, > > return ret; > > > > /* replace the text with the new text */ > > - if (ftrace_poke_late) > > + if (ftrace_poke_late) { > > text_poke_queue((void *)ip, new_code, MCOUNT_INSN_SIZE, NULL); > > - else > > - text_poke_early((void *)ip, new_code, MCOUNT_INSN_SIZE); > > + } else { > > + mutex_lock(&text_mutex); > > + text_poke((void *)ip, new_code, MCOUNT_INSN_SIZE); > > + mutex_unlock(&text_mutex); > > + } > > return 0; > > } > > So this slows down the boot by over 30ms. That may not sound like much, but > we care very much about boot times. This code is serialized with boot and > runs whenever ftrace is configured in the kernel. The way I measured this, > was that I added: > > If this is only needed for module load, can we at least still use the > text_poke_early() at boot up? Right, so I don't understand why this is needed at all. ftrace_module_init() runs before complete_formation() which normally switches to ROX, as such ftrace should be able to continue to do direct modifications here. Which reminds me, at some point I did patches adding a MODULE_STATE_UNFORMED callback in order for static_call / jump_label to be able to avoid the expensive patching on module load as well (arguably ftrace should be using that too, instead of a custom callback).