From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7F5619CC28 for ; Sat, 20 Dec 2025 20:41:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766263274; cv=none; b=qpqS7c6Nokqte45IgDbYlvb5z5QC/cpfnxWvsz6WXBzwrZapUd6efvdBSqFqS9snNGvC3R3Epyx8yXeWU3tAAytbBtL0Zume7y7352GQ9/j194TBM0Ef9XSlLPOfhQo/ZNj/cEYS1Wg7YJiVxzm1iiqMThSJ84Urw2XDPWpEaDw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766263274; c=relaxed/simple; bh=pAUEXPZKNALpge4nw7JeLc1gtEzSPUrerDunca6a+xk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OFaEA1tWNcn+XdgTPkKM0pGb7z1kvTTdpfC63jxYfElxKQq4Y0WCmN7qK1BSv6TAYR4D/DswMqFxJnqnbmxjDR3HCv6+O4yiH7uzs9fufmEY+xqs9bwWl8BAIs6Qu1g+sGAYF+ghkBt5SCX1PsUhohzFdfuuHmSLc2YucTwXh9k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=BbWqPxG6; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="BbWqPxG6" 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=TTlPrnwX8drKNI8PraSUa5QjBDcvyB916oowJ8a9Njo=; b=BbWqPxG6a/5gX2D1aHgH81aPXY kVMz9p0LtQUgS50SnIhMMse/K9L6f3LpeqzuoSFyyEK9r9+5eBR2phSIT6ZC8GI3l3T6Elm38G4c6 uMpUUb3bYApxPoYkxpeq1vC2QQgO51EY+R4q6crz7S4ppwfeQni+r7VSo2ckKAp6B7qFuWLs6G1pz kl8hJwVnzbAkidkQrCuFtCKRfI2p9NI2a5uD+DfwtwAgKcQjgfR7N9AITMKREFbmQnNPdqVTWZsP3 Txc4zYv0SATUFWjec0+2N8bhWqlQ6d0gYxSkC0H2dfNjm5QRdPIs4hEsrKgNMpysB3+wN3aCyFceU 4l1gDOpQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vX2tf-0000000CoDf-1LSu; Sat, 20 Dec 2025 19:45:47 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id A8A6930057E; Sat, 20 Dec 2025 21:40:59 +0100 (CET) Date: Sat, 20 Dec 2025 21:40:59 +0100 From: Peter Zijlstra To: Brian Gerst Cc: ellyndra , linux-kernel@vger.kernel.org, luto@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com Subject: Re: [PATCH v2] x86/syscall: make sys_call helpers static Message-ID: <20251220204059.GA272712@noisy.programming.kicks-ass.net> References: <20251218145714.70220-1-ellyesparza8@gmail.com> <20251220141037.GT3707891@noisy.programming.kicks-ass.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Sat, Dec 20, 2025 at 09:32:27AM -0500, Brian Gerst wrote: > > Ofcourse. But I'm not sure I understand your concern. Both > > x{64,32}_sys_call() only have a single caller, inlining them avoids the > > whole call, tail or otherwise, how is that a bad thing? > > > > text data bss dec hex filename > 13194 128 0 13322 340a > arch/x86/entry/syscall_64.o > 10239 136 0 10375 2887 > arch/x86/entry/syscall_64.o.orig > > That's a 3k increase in text size when it's inlined. Oh, you're talking about the calls in the switch; when that's inlined it ends up generating a pile of doo. The below should do. --- diff --git a/arch/x86/entry/syscall_32.c b/arch/x86/entry/syscall_32.c index a67a644d0cfe..47ef0a10e42e 100644 --- a/arch/x86/entry/syscall_32.c +++ b/arch/x86/entry/syscall_32.c @@ -41,12 +41,14 @@ const sys_call_ptr_t sys_call_table[] = { #endif #define __SYSCALL(nr, sym) case nr: return __ia32_##sym(regs); -long ia32_sys_call(const struct pt_regs *regs, unsigned int nr) +static noinstr long ia32_sys_call(const struct pt_regs *regs, unsigned int nr) { + instrumentation_begin(); switch (nr) { #include default: return __ia32_sys_ni_syscall(regs); } + instrumentation_end(); } static __always_inline int syscall_32_enter(struct pt_regs *regs) diff --git a/arch/x86/entry/syscall_64.c b/arch/x86/entry/syscall_64.c index b6e68ea98b83..0f26f3f60b4a 100644 --- a/arch/x86/entry/syscall_64.c +++ b/arch/x86/entry/syscall_64.c @@ -32,23 +32,33 @@ const sys_call_ptr_t sys_call_table[] = { #undef __SYSCALL #define __SYSCALL(nr, sym) case nr: return __x64_##sym(regs); -long x64_sys_call(const struct pt_regs *regs, unsigned int nr) +/* + * Explicitly noinline such that the whole switch table ends up generating + * tail-calls. When inlined into do_syscall_x64() it will + */ +static noinstr long x64_sys_call(const struct pt_regs *regs, unsigned int nr) { + instrumentation_begin(); switch (nr) { #include default: return __x64_sys_ni_syscall(regs); } + instrumentation_end(); } -#ifdef CONFIG_X86_X32_ABI -long x32_sys_call(const struct pt_regs *regs, unsigned int nr) +static noinstr long x32_sys_call(const struct pt_regs *regs, unsigned int nr) { + instrumentation_begin(); +#ifdef CONFIG_X86_X32_ABI switch (nr) { #include default: return __x64_sys_ni_syscall(regs); } -} +#else + return __x64_sys_ni_syscall(regs); #endif + instrumentation_end(); +} static __always_inline bool do_syscall_x64(struct pt_regs *regs, int nr) { diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h index c10dbb74cd00..59a406074dc0 100644 --- a/arch/x86/include/asm/syscall.h +++ b/arch/x86/include/asm/syscall.h @@ -20,14 +20,6 @@ typedef long (*sys_call_ptr_t)(const struct pt_regs *); extern const sys_call_ptr_t sys_call_table[]; -/* - * These may not exist, but still put the prototypes in so we - * can use IS_ENABLED(). - */ -extern long ia32_sys_call(const struct pt_regs *, unsigned int nr); -extern long x32_sys_call(const struct pt_regs *, unsigned int nr); -extern long x64_sys_call(const struct pt_regs *, unsigned int nr); - /* * Only the low 32 bits of orig_ax are meaningful, so we return int. * This importantly ignores the high bits on 64-bit, so comparisons