From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 189E41CAA6A for ; Wed, 22 Jan 2025 22:56:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737586616; cv=none; b=mK0wRMa0fSfOKNcCbdVHjKS5AxPergrlILEXvzTxc/P8g3CXOH3EGd8w86yL/kkj2P4iMHGrgQXgQTn/P2lfS7gxPv3/dUyndCXYrN4+ni6Vmoc0ONonYvWSzEKUMISG891yczB60jdgVzDDKOp+vPWS7pGT6KaYD9Q3O584S0g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737586616; c=relaxed/simple; bh=mv7KUIbyKGHeuf7LA5c1+10gOtsNxeILI+8x5fj1ZI0=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=RGsOEQYKfafilA3duVtbG6mA+m4TRqL2T1i+DML9Bb25a44vLkxX6QxuI7BTfYEu58tNATsEzdTTz9t9njbt7Gow865848JlvZ7BogFa1Aq4/s3JG2EiYJ0iuUVSc2QEkj7PvQuKmqhH56CU/IqFQIQNrvFn3bJmEFzoSOrd0yM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=lcj0jsrP; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="lcj0jsrP" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2f42992f608so528470a91.0 for ; Wed, 22 Jan 2025 14:56:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1737586614; x=1738191414; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=cnzMlYCzKVvpxw7yPav+PLPBZlq1nGQlt5nCryj5lKM=; b=lcj0jsrPoB1tLTtKHu2965FlMqv3u9xD0dBAcDdpEL3IjaFBs2WJk8VHDriEAONKeR 3qSGZReeBB7dkmlmEwauzYjXjM7WP5xadv+sGuZF7Q49ghLE5E7CUaV2r+yMP88zQi2I ji7PYL70EQda7qhyGT1HEHluHNpjNcf4Z7Sc5bgKgMzb1mvpoptD4gmJiRZX9k5OBjz7 BL2UfSBuIzOSaygdyQOhWtalWE5eSIuI1DUskxP9RVWzKehs9ebxndJ9pfIxORwQdhld zC+0+FnTnK8qkJLSLMCQCh4XvZHxcUTltCcWeBsbSHcrpa5zKon7O7Pa3xe6e6MOsJv1 yM5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737586614; x=1738191414; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cnzMlYCzKVvpxw7yPav+PLPBZlq1nGQlt5nCryj5lKM=; b=eQ/cpWplHRZYHzFdKJYEfAF1EAUG7auek9heuu0FAHmIQ/FUDGKHHjUuOatXgFboSy 3IPNR9F9/06wWH0FVJyf+K3XXqmk+JMSrlR9nOVJDqwB6KaexK0Z+96SaZ/hW2vqkCGV hfPH3rNywvVPRIOu455rGSdYMVY66nCr/fz6eb4+AhF+LENUKAkl8wPSUeIYu/T8u8sh OCXnPSjBoYmv8vujLjYwarIg+GVP3/KWkQT+6ly49LAW1yFEO/UnrGgx53PZXWe7+NfJ YLM4nzMTVqgnpp6eiOSyoEvBvx7dzQo8x1oIXq3Wa55pSai+JBxcsKBBRRNT240oLlfr Jyaw== X-Forwarded-Encrypted: i=1; AJvYcCVzVmCepvlB39J+tYZAoAwKMJ2PepBLseqfJWA+19kFEYo8yPbeUqZiIejFbfsqxSYWRi5f8E2xczPJUGg=@vger.kernel.org X-Gm-Message-State: AOJu0YyFVbUiJYqRnY1tfnxXH1I9wz0BkHG2WLvLKtsGaxE1yuQGpIoL 4bCqESHpWRJ+GCRmC7EquBgyh7rcq69xA2+HSZvYfUWNszc/NqXWBmVmw22V95s= X-Gm-Gg: ASbGncvPfYvO1ZOu8LuR/TqJbidOFcpGZd/cskgZ2WswFMI/TOzT3X8px09reH7cpBC UbbXeSIViP/wHZ4mPPWC9W0XcDKMfDSKQWU4bhGlQR8XZrHVidA1kvtihL9ursgtimeeRyEppla GdTeSOiaTbcJa5WKw0DXIJn1XwCZzXu+broq4Oh02KoQiS3PaiMbuTM77ONPAJ6gEHWBZYC4ICK dlFBE/2eDmH+XykvkT0ygQ+vvd4p4nlHtdeEhSzHcFiR8OprZDpN3clVMnzbnmB4jZ506C++DTu fPFk1ZdemA== X-Google-Smtp-Source: AGHT+IHB0x+Ki93nVMyNmjUvHS1Hbs7yWzbtT7Kml6NUqhDpPqvjvCne2/W3tEXbP1kUcPb30M8ZEw== X-Received: by 2002:a17:90b:4b8d:b0:2ee:7a4f:9265 with SMTP id 98e67ed59e1d1-2f782c976f5mr35059946a91.15.1737586614341; Wed, 22 Jan 2025 14:56:54 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f7e6aaf3b4sm2301375a91.25.2025.01.22.14.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 14:56:53 -0800 (PST) From: Charlie Jenkins Subject: [PATCH 0/4] entry: Move ret_from_fork() to C and inline syscall_exit_to_user_mode() Date: Wed, 22 Jan 2025 14:56:19 -0800 Message-Id: <20250122-riscv_optimize_entry-v1-0-4ee95559cfd0@rivosinc.com> 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="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAJN3kWcC/x3MTQqAIBBA4avErBNsNJCuEhFhU80iizGiH7x70 vJbvPdCJGGK0BQvCJ0ceQsZVVmAX4Ywk+IxG1Cj1VajEo7+7Lf94JUf6ikccqvaGWeNRW2whpz uQhNf/7btUvoAcMITyGYAAAA= X-Change-ID: 20240402-riscv_optimize_entry-583843420325 To: Paul Walmsley , Palmer Dabbelt , Huacai Chen , WANG Xuerui , Thomas Gleixner , Peter Zijlstra , Andy Lutomirski , Alexandre Ghiti Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, Charlie Jenkins X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1633; i=charlie@rivosinc.com; h=from:subject:message-id; bh=mv7KUIbyKGHeuf7LA5c1+10gOtsNxeILI+8x5fj1ZI0=; b=owGbwMvMwCXWx5hUnlvL8Y3xtFoSQ/rE8s0TrtXqsUUK2vXc8j4W/efQ3uZL75iF2SsOVnDeT A4Sej+/o5SFQYyLQVZMkYXnWgNz6x39sqOiZRNg5rAygQxh4OIUgIlwXmT4n3/d44Sk1qzVd157 MQQsunbo4UqfpE+mU7Yu3dsV5ztzqw8jQ/snE52ShgWi7NKP1iVNc5gjHhlyo0W+/uIiZvVbP9j e8gAA X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 Similar to commit 221a164035fd ("entry: Move syscall_enter_from_user_mode() to header file"), move syscall_exit_to_user_mode() to the header file as well. Testing was done with the byte-unixbench [1] syscall benchmark (which calls getpid) and QEMU. On riscv I measured a 7.09246% improvement, on x86 a 2.98843% improvement, on loongarch a 6.07954% improvement, and on s390 a 11.1328% improvement. Since this is on QEMU, I know these numbers are not perfect, but they show a trend of general improvement across all architectures that use the generic entry code. [1] https://github.com/kdlucas/byte-unixbench Signed-off-by: Charlie Jenkins --- Charlie Jenkins (4): riscv: entry: Convert ret_from_fork() to C riscv: entry: Split ret_from_fork() into user and kernel loongarch: entry: Migrate ret_from_fork() to C entry: Inline syscall_exit_to_user_mode() arch/loongarch/include/asm/switch_to.h | 8 ++++++ arch/loongarch/kernel/entry.S | 22 +++++++-------- arch/loongarch/kernel/process.c | 36 ++++++++++++++++++++---- arch/riscv/include/asm/asm-prototypes.h | 2 ++ arch/riscv/kernel/entry.S | 20 ++++++++------ arch/riscv/kernel/process.c | 21 ++++++++++++-- include/linux/entry-common.h | 43 +++++++++++++++++++++++++++-- kernel/entry/common.c | 49 +-------------------------------- 8 files changed, 122 insertions(+), 79 deletions(-) --- base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04 change-id: 20240402-riscv_optimize_entry-583843420325 -- - Charlie