Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1505120lqt; Sat, 8 Jun 2024 00:32:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbs43GaFtOvhFxuMfF8YsnnRYCTzZarue/bBdORKWE3ao+NK19xtMCwymfISIh/CVlfKJ2TKnqLbn0PmaPp4LdbHuX5igFaKC0956i+Q== X-Google-Smtp-Source: AGHT+IGzHecvnoCkoi36sVUN2F3xYtzdLb6Lu5CQ8218WslN1y/m0UENGOX/yhB5XmdHdP5IfkZo X-Received: by 2002:a50:999d:0:b0:57c:6ae2:abda with SMTP id 4fb4d7f45d1cf-57c6ae2ac5emr862249a12.5.1717831974279; Sat, 08 Jun 2024 00:32:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717831974; cv=pass; d=google.com; s=arc-20160816; b=wJvlZOTeDgAJ7d1MTOQTNyM/9xx+HU+BfJJ/PAZiDLBNySaImmm4pHNjsYVbeHozPW 515jhuutBEON/v0nl0DLpz7sl7dcBPPqrzOn0QRQwZSvqeAN8ChASb362L+xiMqji7aa 6vRPq4YNIHk1eC/6HTqSRFT8oLIpKA3RiPPU65KuaA6QObFyR6GAAsU3ivOyziTQe6qb ItvjUXxGUBSI8WD22hjhFbiZgl+3np2Pq4sOPNSLWLM4PPvOcVJ7FOXvVLdiN+PHA1/a XkShPdPwrGbZQiHe6vg7E2urWGUbx0IPvvfBR2qKHelCChjd/5N+MtKvBRtrKA0fSXJu OiMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:sender:dkim-signature; bh=TkNzPEoAERYPXrD8RfGzPSQCNStah0bla1ynxf0VLJE=; fh=ZrHbDSiANSBCmvivbV48JgZ35KGtehFV6ZNj4vR8U9I=; b=uTexKLZOpymBohBz2oKxCPU8kCDRz0VvPxYxXMvO+3t62zJMC+wHqE08P7xECw/+jr 4R5uMDLnR0wJdJqTCaDTQFrxocTtNUfKr221GRQXyU20V+/WC4MMm5uX2xeFY49ymWpZ BwY5s/rg21Br6Zydc1/Ium/jszBtLJ7s83szoitiD3Kak5S7lvbSFx9AH8bVIbaHFtZC I+3JO/1RdUooqoNtsrE679lTbztk/Efx14bo2TdHS2JeNHWRBmed0JPJXMNswmilabgY MUql1BJX3g3Cyrad+V/xjitaQA41olMsK33Eye3yuqG7gyFUABxZkEKAkQhugJEKAF/C aDBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dIoQz9rv; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-206927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206927-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae1fbc33si2562951a12.330.2024.06.08.00.32.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 00:32:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dIoQz9rv; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-206927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206927-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C24921F213B5 for ; Sat, 8 Jun 2024 07:32:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2492F1779B8; Sat, 8 Jun 2024 07:32:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dIoQz9rv" Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 5970E176FB0 for ; Sat, 8 Jun 2024 07:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717831943; cv=none; b=aUuZzClYrpDwWs5ZVQbmeu/WyLM1QWM7uXJEj9wBPUlHUipTSFKkBUWLDiYbPkuu2DIx1WgaAyl7MWIOkO2vpW0ca1tp4uKX7lo1r395lAZGHMUGtG3S53wl93tZLv0cq/gTmuGkSSKgc2A7vk1Br/E72UMnYMjurSdXvFKOHYg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717831943; c=relaxed/simple; bh=F+af4rxe7d7IoVbuM2DptpY8oZNWyOTUT9YFS5HcTCs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SchDhjl7QvMJ8xuAvO7lBraDsnqzT69uC+Y/ZuP+mUm4V7PJfsMEW7LXryFhCOX+zcJRZeGhZsdXFk3c9rwugA9/56BnsFNWLsEQ2EASbxPkw4+VHMIKvAFH/XALs5iKpglcC3ZVnrDNptR+QhwhvIWtzYgB5NzcgEVnnfNQtns= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dIoQz9rv; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a6c7ae658d0so371978266b.0 for ; Sat, 08 Jun 2024 00:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717831939; x=1718436739; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=TkNzPEoAERYPXrD8RfGzPSQCNStah0bla1ynxf0VLJE=; b=dIoQz9rvdHNED8+6xYzD0lDTNamReGNlKL1fqdkdFSmfJ2S0PvPG+aXu2oUTcvsf5m O2Cd7dKVI63j07u86EpGbPCGqzEk2/aiqbwryGT/rcDzJ7oBhjjwMhtf98NrGn/sDZew 8bfj1BZ9ChjnAfRvM41+q6GB6dEvw5P9DzlVuAky3JayT0gC8T6ghgVeDysjZ6kcn3SK NZMLbbZhZUv/iX7vqxSZ/Y/iYQGDD2lrIhTQbvsBlQ9H5afiSFVeGg6q56p9QshFzOf7 ezhth42jOlbOIh8JQw+OGtax5w90KRJITAenStzZT9KZNimmcSDxg5Q8gxLov0po6H8w cIPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717831939; x=1718436739; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TkNzPEoAERYPXrD8RfGzPSQCNStah0bla1ynxf0VLJE=; b=e50FCtmhoeeijHVWiP1X23+pcBmknvuvzQ73W+/IvWLQuK7DCpBX5hQ9gygGu9RyWP gq8+/sgcjptNObaquTfrkrFYE1h3QTOk9nQXAEvU4MNpQc1TCzUi3RIpWFlCmg4ILA4H o+CDImn6u3xWq53hoocQAzD/RE73dCtpMqGXEJdupQSLjauzV+dNXNGqeqwvBxgcuj1z JNm2Sm1PWK7/ahioiOYvkiIOA0XOJa82BU3jE35ystL8RZjwDE8pnKCTL0+2V8mEFjzV mxO1eRsVLfwaLFJO1ifCdb3gz4fvP/miOgV/cetlsQTd4ssRRRuDSMBnaBsiOYh22JmU TQqQ== X-Gm-Message-State: AOJu0YxU8Jt9vhuTOvc3KXwcD9qOMP/rFvhfSc3ALenL0oh6rMc3syps Lnrruxs0rh9gnmSSjMSX5xDqwhXIShfAs1LWRRurbj1uZP0vRYZxQ4d+ypOJ X-Received: by 2002:a17:906:49a:b0:a69:10b9:d7ea with SMTP id a640c23a62f3a-a6cd7891a31mr352696266b.41.1717831939387; Sat, 08 Jun 2024 00:32:19 -0700 (PDT) Received: from kepler.. (1F2EF20A.nat.pool.telekom.hu. [31.46.242.10]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6efe5262cdsm61350466b.117.2024.06.08.00.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 00:32:19 -0700 (PDT) Sender: Ingo Molnar From: Ingo Molnar To: linux-kernel@vger.kernel.org Cc: Andy Lutomirski , Andrew Morton , Dave Hansen , Peter Zijlstra , Borislav Petkov , Brian Gerst , "H . Peter Anvin" , Linus Torvalds , Oleg Nesterov , Thomas Gleixner , Uros Bizjak Subject: [PATCH 4/9] x86/fpu: Remove the thread::fpu pointer Date: Sat, 8 Jun 2024 09:31:29 +0200 Message-ID: <20240608073134.264210-5-mingo@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240608073134.264210-1-mingo@kernel.org> References: <20240608073134.264210-1-mingo@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit As suggested by Oleg, remove the thread::fpu pointer, as we can calculate it via x86_task_fpu() at compile-time. This improves code generation a bit: kepler:~/tip> size vmlinux.before vmlinux.after text data bss dec hex filename 26475405 10435342 1740804 38651551 24dc69f vmlinux.before 26475339 10959630 1216516 38651485 24dc65d vmlinux.after Suggested-by: Oleg Nesterov Signed-off-by: Ingo Molnar Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Dave Hansen Cc: Thomas Gleixner Cc: Uros Bizjak Link: https://lore.kernel.org/r/20240605083557.2051480-3-mingo@kernel.org --- arch/x86/include/asm/processor.h | 5 +---- arch/x86/kernel/fpu/core.c | 4 +--- arch/x86/kernel/fpu/init.c | 1 - arch/x86/kernel/process.c | 2 -- arch/x86/kernel/vmlinux.lds.S | 4 ++++ 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 64509c7f26c8..3de609aad0af 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -502,12 +502,9 @@ struct thread_struct { struct thread_shstk shstk; #endif - - /* Floating point and extended processor state */ - struct fpu *fpu; }; -#define x86_task_fpu(task) ((task)->thread.fpu) +#define x86_task_fpu(task) ((struct fpu *)((void *)(task) + sizeof(*(task)))) /* * X86 doesn't need any embedded-FPU-struct quirks: diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index f0c4367804b3..167a9c7ed6d3 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -591,13 +591,11 @@ int fpu_clone(struct task_struct *dst, unsigned long clone_flags, bool minimal, * This is safe because task_struct size is a multiple of cacheline size. */ struct fpu *src_fpu = x86_task_fpu(current); - struct fpu *dst_fpu = (void *)dst + sizeof(*dst); + struct fpu *dst_fpu = x86_task_fpu(dst); BUILD_BUG_ON(sizeof(*dst) % SMP_CACHE_BYTES != 0); BUG_ON(!src_fpu); - dst->thread.fpu = dst_fpu; - /* The new task's FPU state cannot be valid in the hardware. */ dst_fpu->last_cpu = -1; diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c index 4e8d37b5a90b..794682b52373 100644 --- a/arch/x86/kernel/fpu/init.c +++ b/arch/x86/kernel/fpu/init.c @@ -78,7 +78,6 @@ static void __init fpu__init_system_early_generic(void) int this_cpu = smp_processor_id(); fpstate_reset(&x86_init_fpu); - current->thread.fpu = &x86_init_fpu; per_cpu(fpu_fpregs_owner_ctx, this_cpu) = &x86_init_fpu; x86_init_fpu.last_cpu = this_cpu; diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 5bb73bc0e31a..4184c085627e 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -96,8 +96,6 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) #ifdef CONFIG_VM86 dst->thread.vm86 = NULL; #endif - /* Drop the copied pointer to current's fpstate */ - dst->thread.fpu = NULL; return 0; } diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 3509afc6a672..226244a894da 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -170,6 +170,10 @@ SECTIONS /* equivalent to task_pt_regs(&init_task) */ __top_init_kernel_stack = __end_init_stack - TOP_OF_KERNEL_STACK_PADDING - PTREGS_SIZE; + __x86_init_fpu_begin = .; + . = __x86_init_fpu_begin + 128*PAGE_SIZE; + __x86_init_fpu_end = .; + #ifdef CONFIG_X86_32 /* 32 bit has nosave before _edata */ NOSAVE_DATA -- 2.43.0