From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 0E28B13F43A for ; Tue, 28 Jan 2025 05:33:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738042403; cv=none; b=N4q4ugCTnCxGZjVOScCYiza/Pz9OR3vRMaKwpmfWsa+3PnpCJmeXmKqoWOQi8ygBlxtGhVOb/pp3C+Qf8FWcrRs5guGg5gRQOy+1k+gW1h+ImeJJoULKD1q+NkTMZFye64VHHXV/bnm06z3hImCa8c1Fb6N4L/6w8z64SlEhbWc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738042403; c=relaxed/simple; bh=vsu6cgsvHKwBowyBPOBpPBCq2EM+Gs+NrcIx6EM09Hc=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=DeV9EcDoMpAkjax+20+LnZXkqdY9aS/CaMjbKv9mhOG/aVUzhi7aRdugChwMhW9hteuHlSllBgg1kSaXHWyY/5KVIIWoF8n4Z8U3Je58vzycpwTlylBa6saI+nBAITHUBcT1LIO3DAaFOIqY794Bcb6SAtjiu2FMs+ROPTggEDk= 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=KBvGtb3F; arc=none smtp.client-ip=209.85.216.50 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="KBvGtb3F" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2efe25558ddso6926333a91.2 for ; Mon, 27 Jan 2025 21:33:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1738042400; x=1738647200; 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=sle+tYzc1Kj6tbZ7/BHbrlcS2vI3Z3FG3YJYp8onC8U=; b=KBvGtb3FFh4HFQ5IuylfmpJ52B2q+584509pIfs8U/pS2hOjCXEZKidSeqMsq9ePBT yf30aby1SlGzoXsc8R65PoMyaGRZ1xvOBo+eZYrFvv6rq9JIikm2ey881Xz2Xam2Hi4f 7MS72wkm36aBoe7eKGqrTvMfVxR+SM6EfixA+sYNTfiTcG/0Wd9yuCWf+IlnSI5oznXA KkWuytnU/pwv5oj9qdbLtNE8u2aI2wc/9ERK4IuwwArQmxHItUYxZJDavwr8FLUTC4zi +34QDvJ45Ih1oNJs2ubnAF/rEb+zehMzS4KXbRiOdQdZpFCSowMaz3ahm/psBtoiR/TV Dt2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738042400; x=1738647200; 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=sle+tYzc1Kj6tbZ7/BHbrlcS2vI3Z3FG3YJYp8onC8U=; b=rzeMN5y0AiqoZUrfG2HVRPfkhlbJpd1fF+Z5y85NCRyWeFgtbd4H8qzYQB2WeOux8L +Bd7tsRnpUXZFqKjeoZZXpT1rxZm7eXRMpyWFurHpnMhG1CwBzySxx0RMLlRnrPi+Gh/ LHROC37eRhpx7JZsyNO+G3veNUngJJAlG0uct5+lLaI7GCS1URcGAGVPoy8mtzf9l1kv ZNPvT3pi5AZEsUX5FWhz4ZHZKvbuWQNGcJ/bMelO9LkPkcF+BERKFxLrxcKSu3nGWbLf HGQrtPXNBQDT2x7HYEtHQOtrftH6zdCGefVgsAgoc1f3Y9Uvn/rd2qfuanUwJL83mhND OvIQ== X-Forwarded-Encrypted: i=1; AJvYcCUB2iezMkMRcj83ffu8CfPprFMhXfSPH1VbWrMSooAdpqumnYR6WX2/OGMxgtqnPGCGe2llLJOCnw2QuSQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzFVtosmNIzg8Un6rxkUAegmvKfihYI4vxGTS9x7bwbnlzHHRz9 ndiL3Vb82UF967ZMwN07PHIDFmsSb1m0UJhnhiSeFUSjOtKN9wtppgHFJjCo9zg= X-Gm-Gg: ASbGncuDtRCIV8Jgcv1No5t97Q4z1myptQyB0YoOTdlrpE/VqKWL1Ax1XjF4V4FGyIt ka2kyXGPiOlWI5GJcTBqHSTgNxfOulDc0UUhy1KFNNEUx5NdqtOw88TyzR6cfQPgXdt5RyJoBt2 lCUpoz1ibW54Je/T00V0kCA3T6lcbj9DdXyhcA+Gb2V7XVQundNV/GZECY9l1r6Ni7OIWglOCZm y4gsHblpzvEc6fuKO/Hf8shleLVdUThXp7ExoHCwlgcgGX8T3cG5cIEuM4Dqv4TKoyfB/9vuLwr okW+Ze1ZCIFdNvojMLK/swrIcOPNoxk= X-Google-Smtp-Source: AGHT+IGZkd74wEJ76f8m4806LJQwkYr3HqMsqTNdi/AqpJOBfIND9TCgujBv+d+IppRw8DYDaApu3g== X-Received: by 2002:a17:90b:5448:b0:2ea:5dea:eb0a with SMTP id 98e67ed59e1d1-2f782c4d75cmr60542708a91.4.1738042400318; Mon, 27 Jan 2025 21:33:20 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f7ffaf9e98sm8266247a91.38.2025.01.27.21.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 21:33:19 -0800 (PST) From: Charlie Jenkins Subject: [PATCH v4 0/4] entry: Move ret_from_fork() to C and inline syscall_exit_to_user_mode() Date: Mon, 27 Jan 2025 21:33:08 -0800 Message-Id: <20250127-riscv_optimize_entry-v4-0-868cf7702dc9@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=H4sIABRsmGcC/3XNQQ6CMBCF4auQrq0p0ylSV97DGKJl0FlISUsa0 XB3iytjZPm/ZL55iUiBKYp98RKBEkf2fQ7cFMLdzv2VJLe5BShAhQpk4OhS44eR7/ykhvoxTNL UukaNoDQYkU+HQB0/PuzxlPvGcfRh+nxJ5bIuoFElrICplEoikTXGWNe16hA4+ci92zp/F4uZ4 NvRKw5kZ+fAWLTQGlX/cfS3gyuOzk5d2U5XF0uoLz/OPM9vIpGGXEsBAAA= 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=2277; i=charlie@rivosinc.com; h=from:subject:message-id; bh=vsu6cgsvHKwBowyBPOBpPBCq2EM+Gs+NrcIx6EM09Hc=; b=owGbwMvMwCXWx5hUnlvL8Y3xtFoSQ/qMHPF7PA+2HPFSuWLm8pN9YV7aEamX16TPvjhzXHaFf dPLvSrrOkpZGMS4GGTFFFl4rjUwt97RLzsqWjYBZg4rE8gQBi5OAZjINWGG/xlTmq8y98Tnu3JM PDpzz7aGX8xCLSfWxBxJKV+muUvz4mmG/5nKU/TuzN/64MFXRbVQi1V2vg9VhU78lP8p3fVio5I wEyMA 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 --- Changes in v4: - I had messed up warning for ct_state() on rebase, correct that issue - Link to v3: https://lore.kernel.org/r/20250124-riscv_optimize_entry-v3-0-869f36b9e43b@rivosinc.com Changes in v3: - Fixup comment to properly reflect args (Alex) - Fix prototypes for loongarch (Huacai) - Link to v2: https://lore.kernel.org/r/20250123-riscv_optimize_entry-v2-0-7c259492d508@rivosinc.com Changes in v2: - Fixup compilation issues for loongarch - Fixup compilation issues with CONFIG_CONTEXT_TRACKING_USER - Link to v1: https://lore.kernel.org/r/20250122-riscv_optimize_entry-v1-0-4ee95559cfd0@rivosinc.com --- 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/asm-prototypes.h | 8 +++++ arch/loongarch/kernel/entry.S | 22 ++++++------- arch/loongarch/kernel/process.c | 33 +++++++++++++++---- 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, 119 insertions(+), 79 deletions(-) --- base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04 change-id: 20240402-riscv_optimize_entry-583843420325 -- - Charlie