Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp261664lqp; Mon, 10 Jun 2024 03:25:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW/So+bxc39J41TOKNNPSghpQz5vZDqH5RnBuUkmDb8cD2xoE1A1RwoOisLpqRjVHDPY7/bo8MHnl25CaSjxHMryi00rn4eE2eHbjDd1Q== X-Google-Smtp-Source: AGHT+IGOJ8dpYU+StQ1YrxfJObQNZthbErrdtOY81AeQhZtea9xA9nM9aHGOg+/ibQKCEn7ARbnJ X-Received: by 2002:a05:6402:4308:b0:57c:716b:a438 with SMTP id 4fb4d7f45d1cf-57c716ba6c7mr4018794a12.6.1718015123848; Mon, 10 Jun 2024 03:25:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718015123; cv=pass; d=google.com; s=arc-20160816; b=cL6a0XCMcucnit59O/0Gx9UqoiaImiVX4Ng+Dg+yhE5O9DxwJWyni3fKIF6Da8m7/R LLiCnlcyAw7rLoRqH6HmMFKZAuhWRihCidGZWk9vmIHuuSi87WECg5YcQKk2LwnEiMMF +nhJKrXzSe+lV9DIOpIQ/KPQ09Qfgid84tkGHhHDAKnBwmKSgZjCQfoxYFZoIfNyUjK2 qPeruN/+YL/RGQ4UPHc+Joxxz9MO+rLTykEI6N23EJ4TJnUdEfZR/jbFulp3IWx/6on3 d6vcP6rQXHtSNMnQtT1s4QPQxjM2rgREC0t9nH4xmjdxAwWrpqMU0zPhnJAGxvG36raJ 0h9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=6SjRN+Ta23NhBrV4wAjIcv/ybzI9M6kM5ZjqQZnSysQ=; fh=eCQl64WUT4R134z/8eMDF8V1pHs0uOjTiXcNBI1HUSM=; b=FZhiWE8kTJT6PpQq4/QUmL8wSKWyDijxrrhAjt1EqCrr0M1oJ9Rhyoo7lzEnRvSd00 A+AqS4gJD5iBvsDmLo4KtL4takGIKbvV5e3nXRVRnPrlyX3S7wgVSW/XLL/e9zY5V2fn xqJqC0ikFLwXLi4AOg8vsd/4DgJ0RF6l/UrTmFBBV6tV+hLxFErUKDSQ6ETCAn02XdIJ n8teY4uCe82yG1hCq4huEii5ERGxWGPxteUpPYpoqsMN0N8rgzGO4NMui5oHuEvk/YR9 I3Pvv7R1hXxMAi6sr8vsnIyQ5XfIDbFHGOoTxQ0vvcKTTPaGUFxVZdf4jJVeHmVa79Rk Gblg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N5Wucjtg; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-207985-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207985-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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-57c61a47d15si2766014a12.342.2024.06.10.03.25.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 03:25:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207985-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=@redhat.com header.s=mimecast20190719 header.b=N5Wucjtg; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-207985-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207985-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 302C01F254EF for ; Mon, 10 Jun 2024 10:03:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D754A762CD; Mon, 10 Jun 2024 10:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N5Wucjtg" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8365A282EA for ; Mon, 10 Jun 2024 10:03:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718013802; cv=none; b=bUcPyY8seAfT1iH54ClTsBbVfTDbKyzS9y9oA0TNWNClHbkWVyoK9gMF6WWOyEKBdlC34i076q4dE5TzODQboGA8ARLulA0cqoYRsOJS+Vp6B7wfj20hb4cC36gQ2f20ERD/YKTid/RHqJsHrVDveQNE7rc0IbakMdn4XgL2rGo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718013802; c=relaxed/simple; bh=O4eiKS04y/mJNA2a+wGR3xNIR6Msr41jQF9cKUECQDg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FpPXXimwYHyRjflywGPBQcqwOLyi5tnw7/H+ZY8IOlqjXoJ+eHTmHHMzmE8CiWCQk9MscLiZoSVKqdAw1BHxFSi2U1krjYQffEHnMsChI6B/BXEgUicEgBA60NrgrDesTqaYAcd3n5j4hHFbDxWsLu6YaQ5LzHComoOk7hp6Sgs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=N5Wucjtg; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718013799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6SjRN+Ta23NhBrV4wAjIcv/ybzI9M6kM5ZjqQZnSysQ=; b=N5Wucjtg/FSp0rFXAcz/YYuxdjkMi0lKS69fpfYHXoEMedR6X7mXDT2XRxPaQKbS3Q1Aor wZj1QaS8DEECvNpkfWjiqyTHGZKoqFzOiDyy7pIc0pjOzU2iVUqxMbtWo25cUkfuFFDOwT cqGDmt3rorHToU0y8Ih/+M/nI0S4QdI= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-600-UHajX1EVNbi7Hpo5cs4OoQ-1; Mon, 10 Jun 2024 06:03:12 -0400 X-MC-Unique: UHajX1EVNbi7Hpo5cs4OoQ-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5D7E41954213; Mon, 10 Jun 2024 10:03:10 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.225.117]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 764EC1956089; Mon, 10 Jun 2024 10:03:05 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 10 Jun 2024 12:01:40 +0200 (CEST) Date: Mon, 10 Jun 2024 12:01:34 +0200 From: Oleg Nesterov To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Andy Lutomirski , Andrew Morton , Dave Hansen , Peter Zijlstra , Borislav Petkov , Brian Gerst , "H . Peter Anvin" , Linus Torvalds , Thomas Gleixner , Uros Bizjak Subject: Re: [PATCH 6/9] x86/fpu: Make sure x86_task_fpu() doesn't get called for PF_KTHREAD tasks during exit Message-ID: <20240610100133.GA20640@redhat.com> References: <20240608073134.264210-1-mingo@kernel.org> <20240608073134.264210-7-mingo@kernel.org> 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: <20240608073134.264210-7-mingo@kernel.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 The whole series looks good to me, and afaics 7/9 allows more cleanups / improvements. But let me ask a stupid question about fpu__drop(), I know nothing about fpu asm. fpu__drop() does /* Ignore delayed exceptions from user space */ asm volatile("1: fwait\n" and this comment predates the git history. Could someone explain why exactly the exiting user-space thread needs fwait ? And if it is needed, suppose that a kernel thread exits right after kernel_fpu_end(), can this lead to the delayed exception? And otoh, perhaps fpu__drop() can set TIF_NEED_FPU_LOAD to avoid switch_fpu_prepare()->save_fpregs_to_fpstate() on its path to the final schedule? On 06/08, Ingo Molnar wrote: > > void fpu__drop(struct task_struct *tsk) > { > - struct fpu *fpu = x86_task_fpu(tsk); > + struct fpu *fpu; > + > + /* PF_KTHREAD tasks do not use the FPU context area: */ > + if (tsk->flags & PF_KTHREAD) > + return; I think it can already do if (tsk->flags & (PF_KTHREAD | PF_USER_WORKER)) return; This matches other similar checks. But I won't insist, and I think all these checks need some cleanups anyway. Oleg.