Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1505192lqt; Sat, 8 Jun 2024 00:33:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVRbrvL88krVkRidaOs1/M+NAMB/TiUdDLhuWbW3Thd9mgzhvx8Dr+DcigTEk/lCUZJwhrPZl4pxjzlZc6NnJ4ddbCJuQ2qF+EVhCrGGA== X-Google-Smtp-Source: AGHT+IHHaZlyRhweLcWysH/Y79LD7N7rxQDQ62s+MZvWVDz9/aJJbC/JGYQnJq7RDItlVaXqE974 X-Received: by 2002:a17:906:1b19:b0:a6e:f6d2:5012 with SMTP id a640c23a62f3a-a6ef6d26d99mr136710366b.2.1717831988133; Sat, 08 Jun 2024 00:33:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717831988; cv=pass; d=google.com; s=arc-20160816; b=m73iKax+Pr8GgLIsEKC78d2hDivhHT9c0Uq8bFg7XVuTrse7M10u2n7CYI4/GKxPm9 rrQVluHWVW8k4zfZPiL6mmXm7YDzwurkqtgqWSqO2+X5avT0/2wwJza2kOvsEMXfMXmI FOeEIAXGXOnuLr/HhBQJAHDRqsH+S80LpDJvgJXJFoUZSGtstTv1ezyMJJihe+LjOJr9 1aEBFWSxEte6WjFKTx194pr0rXFII170kVxMr3gHrEfdnPQjz/KmU+x8+kUnYWR1HPC2 zmYUDiXeErRorjC+rEbvf7QUrqYsLKzC54vWDglYYEowN89h5oSGYwjGO7l5RD0SlIvx NpcQ== 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=I52Ss9P+t77Fk6nJffqozhx7Mo6O/vHA5ocISHNQDuE=; fh=ZrHbDSiANSBCmvivbV48JgZ35KGtehFV6ZNj4vR8U9I=; b=tgnkNNvgxJV84PmHvLTg+p3RMSPQqKV81ruegfVjKpsYFsFqkjIqWoIw49NMsA71Hw 61nNwfKBWVFHee1tCxaIpLiK/lave1n4LHCk3MoGZZypyIU44HZe46oP983FD7gLtnQh tsszxzYF+JAtOEV8BZYPuarqoyKjKqqUSH+z6TRzGMNfaAanV/KJ4IPY8nARBHgJemGr R6l0OXrQe+bV00Fp0DiVjsKrLAgViUAYu/qYX7CZGM4HiMLXGwih5NTE6gYguxGW6ywr PvciYuOVo43RqBPNL453l/3K9ZjFq8ImoTiBewjuU6lEhh73KM6X2VvpAX4p6+UeDbil QMoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FPTX3ulz; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-206928-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206928-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 a640c23a62f3a-a6e8967781fsi121430566b.1031.2024.06.08.00.33.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 00:33:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206928-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=FPTX3ulz; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-206928-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206928-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 D29F61F21CF4 for ; Sat, 8 Jun 2024 07:33:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B708517837A; Sat, 8 Jun 2024 07:32:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FPTX3ulz" Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 1D17417BAF for ; Sat, 8 Jun 2024 07:32:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717831944; cv=none; b=mVvd4VJ0YfZGqF2oSi9JWsCo+XdEqLg3ZSjQYfckj8ywMRAWf+oKqIY1XfZ3P1s9uan5KEKVA2uw0PhIwSVlGDJ8238KmAX+Nf/CDZqiHQefLvQsJS7J6YSZe1XcGkjR2J5bDoPZIRNNthXWdd8dvNjx0nv6PSlF+cvXxItNn5Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717831944; c=relaxed/simple; bh=NPbHCS9f0nBSWkbqacoINu9Sm2IaRds7yMCrldRHK78=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TqbAzAo3KSj8SKZZXkAStCtwMHWkLpexrr+PuaJZTOiNDQyxulaVHPLFw6BeWOrtaY1r5yMZ9AjJT+TwaaAu3qt5AHg3SgkXHndmdej4Od22LRdS0ygiClwHepFMxvfSMgOoT8A6nAq4B0Q60dUAGGSI6iJtUGgpUeWbD+9oGtw= 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=FPTX3ulz; arc=none smtp.client-ip=209.85.218.54 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-f54.google.com with SMTP id a640c23a62f3a-a6ef793f4b8so93920966b.1 for ; Sat, 08 Jun 2024 00:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717831941; x=1718436741; 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=I52Ss9P+t77Fk6nJffqozhx7Mo6O/vHA5ocISHNQDuE=; b=FPTX3ulzLXEH0vccOZPRePseJ+bmg8Y94Aeu343KkpQT7sYKYLrLZ/vhWe1l7cCGWZ esFd4z8y4LhcHr40ZtxGykU/ryJLPMa1h3dIY/Q9EOw0hL6IpBrPNnJZACOWY1nQtAVz 78Jrxfv87PPH/R/FQp3IYYe8ATTGCtNfXf0ClI9NHMymKUnND9y2blD51mg1nvq/9N9Q GmCMiRkCfCciggBav7Jf1J6WuR15NOVUHYzVASo4Bxig6Sr31ugBs1IrGWRBm17S8muH rwc5B5yRMGTD9U2N7GNfGJQWIjTzqFGNAEDrP2GWEvQcQCaV+Q+Yc5xxXMx1J+uYNOgF I4pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717831941; x=1718436741; 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=I52Ss9P+t77Fk6nJffqozhx7Mo6O/vHA5ocISHNQDuE=; b=OLttAxol89QNv/bxJ0NZLdPARe/BYBb4PVVfIxVpaQDnpf/Ggz9J3c+XcAxZW0q06U 0ay9IfOg2QNlkJtMT7qtSOF8ZQ0DrMRcANOiSlwYbrP4sJd9fRNT83vvVQ5l+LDfVbVy j/q8q/xTyWy1y2XrjaAobuuARv3izAbex3N+DQnEQ/jsyX34RknqoEP41dasGdqZSzfR ggtl1+UixKyOpJLAWKwk30WfE9tncUtDNHjhtPZ4pij6BHaEujQaWkCtvgKPIlAF2NjK sPLKRWBthGhGpq63Va0qguLehZ98JgiRYHdAMfIlKrfh5ut3P4yCGW1/D7Hg9ZXJAdRQ 1xAg== X-Gm-Message-State: AOJu0YxHKhBA21uTSMoaEmJMAyGJeum4XpHddgfzGj9ktdPFC23pgxSn jNcPcVxjn8aH4ATaLnxZ2yqvJqevpgkRYVe/UfmygVe2E9DYK0NvwDU01ARH X-Received: by 2002:a17:906:3556:b0:a6e:f763:1c88 with SMTP id a640c23a62f3a-a6ef7631ce7mr131809966b.37.1717831940959; Sat, 08 Jun 2024 00:32:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 00:32:20 -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 5/9] x86/fpu: Push 'fpu' pointer calculation into the fpu__drop() call Date: Sat, 8 Jun 2024 09:31:30 +0200 Message-ID: <20240608073134.264210-6-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 This encapsulates the fpu__drop() functionality better, and it will also enable other changes that want to check a task for PF_KTHREAD before calling x86_task_fpu(). Signed-off-by: Ingo Molnar --- arch/x86/include/asm/fpu/sched.h | 2 +- arch/x86/kernel/fpu/core.c | 4 +++- arch/x86/kernel/process.c | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/fpu/sched.h b/arch/x86/include/asm/fpu/sched.h index 1feaa68b7567..5fd12634bcc4 100644 --- a/arch/x86/include/asm/fpu/sched.h +++ b/arch/x86/include/asm/fpu/sched.h @@ -10,7 +10,7 @@ #include extern void save_fpregs_to_fpstate(struct fpu *fpu); -extern void fpu__drop(struct fpu *fpu); +extern void fpu__drop(struct task_struct *tsk); extern int fpu_clone(struct task_struct *dst, unsigned long clone_flags, bool minimal, unsigned long shstk_addr); extern void fpu_flush_thread(void); diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 167a9c7ed6d3..c85667c0695d 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -672,8 +672,10 @@ int fpu_clone(struct task_struct *dst, unsigned long clone_flags, bool minimal, * a state-restore is coming: either an explicit one, * or a reschedule. */ -void fpu__drop(struct fpu *fpu) +void fpu__drop(struct task_struct *tsk) { + struct fpu *fpu = x86_task_fpu(tsk); + preempt_disable(); if (fpu == x86_task_fpu(current)) { diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 4184c085627e..0a24997c8cc6 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -114,7 +114,6 @@ void arch_release_task_struct(struct task_struct *tsk) void exit_thread(struct task_struct *tsk) { struct thread_struct *t = &tsk->thread; - struct fpu *fpu = x86_task_fpu(tsk); if (test_thread_flag(TIF_IO_BITMAP)) io_bitmap_exit(tsk); @@ -122,7 +121,7 @@ void exit_thread(struct task_struct *tsk) free_vm86(t); shstk_free(tsk); - fpu__drop(fpu); + fpu__drop(tsk); } static int set_new_tls(struct task_struct *p, unsigned long tls) -- 2.43.0