Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1503491lqt; Sat, 8 Jun 2024 00:27:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJUP9EP/1VIUs8b82pW1bBrWuawztD4qMam/Zcg6Qrip9Fv7Moj9rrxPuMeMYAQ2OBYR1RyKPe6DM8LvodNRKoE8Gc7SWY/sngsSIjow== X-Google-Smtp-Source: AGHT+IGEQxddQK9RP6mnfMna9grHwFj0HcE3CUysAX7uvE085D+rw82CCnsr87jik/Uibe8oywEO X-Received: by 2002:a05:6e02:1fc9:b0:36b:3af2:2349 with SMTP id e9e14a558f8ab-37580349e10mr50127435ab.15.1717831621331; Sat, 08 Jun 2024 00:27:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717831621; cv=pass; d=google.com; s=arc-20160816; b=If0kbW+uoLxCREazlOXIdc23EanecU2L7oY66/TwAz6zc9QZj//OaUyWUa4pXQjE6z 9bx/vQryxS946qCwkG6qfeLwO8ujqTFCnC6YCHNWU6mnyDS/ZtcXKQaTbc9+UAyI7YFC RUANlhDO+rFGJQ8Y8zhKYyLy7LD33TDO2k5o7oyO0YfVSKfWXotsPef2FKRrNItxLvYW 8sJHQuY2bzKYnARcbENZDpyOeIhQPoHMBWOPOssx7+8YCRd3KWJuAUepCFHADuClk6FD zCxjcVjafuMSlSqq5eluW+4UH0mIDsmKeuXiUaeWI7rvShtPLxSfKk9W2zZyqq+UyDNo bUEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:sender:dkim-signature; bh=ni5fFFnVcG2iwTXfOd+vGNAwxVMpjNHfjKy+OgAL7Qk=; fh=8nJWSEDP0p9ApJPVECfABc+Jm7/Gc4v8WJ6HeRukjOs=; b=KgQSlVouDsVZbfHUfw0OdlOdFLLO5ZnZ6UtHfEGi6fYrfPAwNo0Kl/E6IUXIwhU2cq nsc5UsK4aPETagloeUMEo9Y9Htr3lq5Hzzw8T4qxT8GYV+Gyq1SD4gTDAXTGPPPOKlQA kQjckUGuGS33DT8tPYI/jRxCC64epfx/YQvl83ZhDEdfT+k1qG1JjJiaLDDWHPm3ES48 CCLGF5dXuegUHlGkTctmw2f/yR1zZjfd+Adgl8KrXEz1BPw0deCyhlT2gWTXkhKWnPS6 j7pMpJxwhJpdZ43CH+jnc94sz+FB/qaEzL28xEGEaXlS3cqM8UXLvtXFuZU5NWTrYYC6 PWhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JzdvK6E8; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-206922-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206922-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6e338d5a9d4si1335666a12.206.2024.06.08.00.27.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 00:27:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206922-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JzdvK6E8; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-206922-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206922-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EB563283958 for ; Sat, 8 Jun 2024 07:26:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F02EB176AD1; Sat, 8 Jun 2024 07:26:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JzdvK6E8" Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 54530433AD for ; Sat, 8 Jun 2024 07:26:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717831603; cv=none; b=QNiywXb0Ab97jIMJDntXjN1SzyYW1a8mFWWSKiDQPB7pKn2qFkarCLKxpUJ5TF9o1maOBH5/BUbYURUi0Z766mAFMphqlBX7u1gM42ln64GJaRnV4DdJtCJacwl4Db0hN5LT2+E+Bz/dyKRsJRGFYl0XHy1fXz/+IhOACtwfmas= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717831603; c=relaxed/simple; bh=Oj4lS1B4upVgat/8NPIU2m9kS6m/FhPnfRYzR4Ki0yI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XkKciUm5r4vhpP7ezC7SIjIBd9z5DIE/YjAT0uSVVKfSDSJtAnR3eCob5P33Qre/Ac06BTljtVrgL2c25Wqq+WWqOmo6/dp116u+ETefmVfgWNJLdqV/bOuQK7siYFL+pWOQ+iZhtMNG+gapT/dwRJJ1paowsLcKap1HVmpWDD0= 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=JzdvK6E8; arc=none smtp.client-ip=209.85.167.51 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-lf1-f51.google.com with SMTP id 2adb3069b0e04-52c82101407so126150e87.3 for ; Sat, 08 Jun 2024 00:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717831599; x=1718436399; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=ni5fFFnVcG2iwTXfOd+vGNAwxVMpjNHfjKy+OgAL7Qk=; b=JzdvK6E8JxI7a6+P8CdjuT1G7co4gwFaeK7754cCipecaSsp93MQM9xFjyDlimjxlz INR2xK+7Qu6mneyvMlrv4OhF0T5XOPsTaO0ESmkQDygs/Uc4lgV2ofrrs0t6dwM24rG1 W1329YNFWE2naNa+4UHqUhzwgKGAULp1Is8lc5p+NEF9e1I/6yjTOdTxmEMKZLuZNmFr 9YRC9rqUMxY6gloRFnIXhTT2bLRCscH2WpYBmQE5TlSneBNooZ12GMij3eB4UYEUqVPI UHnBJGz6Rac7UCgEZBiGJpQrraR4K8rrFl6J4EjNX3zYhNHqo/nn48R3mhPPDB94KKxD A6Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717831599; x=1718436399; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ni5fFFnVcG2iwTXfOd+vGNAwxVMpjNHfjKy+OgAL7Qk=; b=MCXGpay+SfLlMG2b4E/mtob3UyYO8+bIQ4UOarPjl2br9DjJvgBJ+BB3sZyM2oNK1H gjK+DfVB9gaZ2TrKTIjZ9vThWMRyYJnzC36heKC6z6LL0yF+vuQ/xK3dx4phZKZzyRM6 G1e167rUpC57Dc/y7XYNcUaqZPaeA8rxBh9kpkULEJT+yTTgyZ4FQ9tRQu72E1riRwB8 8P+8W083kA8LPFaewNy6mkRjOb5A79rysdeR3gsy1nXeMQNViB2SdlS7niywRfwaibQy sshx3Cvsg0hks+8rCySlIkNd1a3TjBWXAnhw2B/0y6qohftx3wOrcKZOQL2iCmSJlvQi YVfg== X-Gm-Message-State: AOJu0YxlKAXNukmH39R2rPhQlyPnGEG0TkA20qHe+y0FwDoYMEptTE+j 9oWM8O9XXAWwpxfHK4elILzknoG6cdlwHcY8NCZBYjDC8gTdG2yw X-Received: by 2002:ac2:4102:0:b0:52b:79d6:7c08 with SMTP id 2adb3069b0e04-52bb9f78667mr3324764e87.18.1717831599191; Sat, 08 Jun 2024 00:26:39 -0700 (PDT) Received: from gmail.com (1F2EF20A.nat.pool.telekom.hu. [31.46.242.10]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6e2e1d4cb8sm174605166b.5.2024.06.08.00.26.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 00:26:38 -0700 (PDT) Sender: Ingo Molnar Date: Sat, 8 Jun 2024 09:26:36 +0200 From: Ingo Molnar To: Oleg Nesterov Cc: linux-kernel@vger.kernel.org, Andy Lutomirski , Andrew Morton , Dave Hansen , Peter Zijlstra , Borislav Petkov , "H . Peter Anvin" , Linus Torvalds , Thomas Gleixner , Uros Bizjak Subject: Re: [PATCH 2/3] x86/fpu: Remove the thread::fpu pointer Message-ID: References: <20240605083557.2051480-1-mingo@kernel.org> <20240605083557.2051480-3-mingo@kernel.org> <20240605133805.GB25006@redhat.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=us-ascii Content-Disposition: inline In-Reply-To: * Ingo Molnar wrote: > > * Ingo Molnar wrote: > > > > > * Oleg Nesterov wrote: > > > > > On 06/05, Ingo Molnar wrote: > > > > > > > > @@ -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 *dst_fpu = (void *)dst + sizeof(*dst); > > > > - struct fpu *src_fpu = current->thread.fpu; > > > > + struct fpu *src_fpu = x86_task_fpu(current); > > > > > > I think this patch can also change > > > > > > struct fpu *dst_fpu = (void *)dst + sizeof(*dst); > > > > > > above to use x86_task_fpu(dst). > > > > Yeah, so I'd prefer to keep it open coded, because of the comment and the > > debug check makes a lot more sense if the pointer calculation is visible: > > On a second thought I changed it to your suggested variant: > > struct fpu *src_fpu = x86_task_fpu(current); > struct fpu *dst_fpu = x86_task_fpu(dst); > > because you are right, it's in fact easier to read this way. On a third thought, while more readable, this doesn't work in practice with the current scheme, because x86_task_fpu() gets called on kthreads in fpu_clone(), which trips up the new debugging code. We could resolve it by special-casing PF_KTHREAD here too, but that weakens the whole readability argument. I'll leave it as-is for now. Thanks, Ingo