From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CDFFC433F5 for ; Wed, 29 Sep 2021 09:55:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2EC361407 for ; Wed, 29 Sep 2021 09:55:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245227AbhI2J5G (ORCPT ); Wed, 29 Sep 2021 05:57:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245221AbhI2J5E (ORCPT ); Wed, 29 Sep 2021 05:57:04 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A26EFC06174E for ; Wed, 29 Sep 2021 02:55:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=F1ZLDmFr3JLFI67mtkM8Oy3hemi9FH59+C4PCq5sths=; b=Bx9A2ZQm8vmqJMBPFMuIDNxMyB eOMl3ZkUiyslKrodeaEND2oczaTUs42se3v0AbZZkabbDvqckedmQ8L+J85fqlOiVeJDs0kNvY8QX gg2Dctz7UPC7xqcjyILXT3RMCNHaEHiIN2f0o5WXO2+maOa4JxqX6/QfV9oQd5IFjPA/VQmgrQ8XH limRSmVdVjwo6nh13WHuGZiNbH5w/wDd8I8qFDngAe51PGGFtIL9bxvRB6P44/3dHKhR6YAYGai5x IeD9wuwyZU0xBLqt+QM/1wdr7TcAm+qJiKfZZF2z4MVWDyXCigfyAhr/vwQNxRiDByIV+uS7HDdsp I6DSRJHA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVWHz-00BhuC-Sr; Wed, 29 Sep 2021 09:54:17 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (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) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id CD91C30023F; Wed, 29 Sep 2021 11:54:09 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BAAE02DC92D07; Wed, 29 Sep 2021 11:54:09 +0200 (CEST) Date: Wed, 29 Sep 2021 11:54:09 +0200 From: Peter Zijlstra To: Andy Lutomirski Cc: Tony Luck , Thomas Gleixner , Fenghua Yu , Ingo Molnar , Borislav Petkov , Dave Hansen , Lu Baolu , Joerg Roedel , Josh Poimboeuf , Dave Jiang , Jacob Jun Pan , Raj Ashok , "Shankar, Ravi V" , iommu@lists.linux-foundation.org, the arch/x86 maintainers , Linux Kernel Mailing List Subject: Re: [PATCH 5/8] x86/mmu: Add mm-based PASID refcounting Message-ID: References: <20210920192349.2602141-1-fenghua.yu@intel.com> <20210920192349.2602141-6-fenghua.yu@intel.com> <87y27nfjel.ffs@tglx> <87o88jfajo.ffs@tglx> <87k0j6dsdn.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 24, 2021 at 04:03:53PM -0700, Andy Lutomirski wrote: > I think the perfect and the good are a bit confused here. If we go for > "good", then we have an mm owning a PASID for its entire lifetime. If > we want "perfect", then we should actually do it right: teach the > kernel to update an entire mm's PASID setting all at once. This isn't > *that* hard -- it involves two things: > > 1. The context switch code needs to resync PASID. Unfortunately, this > adds some overhead to every context switch, although a static_branch > could minimize it for non-PASID users. > 2. A change to an mm's PASID needs to sent an IPI, but that IPI can't > touch FPU state. So instead the IPI should use task_work_add() to > make sure PASID gets resynced. What do we need 1 for? Any PASID change can be achieved using 2 no? Basically, call task_work_add() on all relevant tasks [1], then IPI spray the current running of those and presto. [1] it is nigh on impossible to find all tasks sharing an mm in any sane way due to CLONE_MM && !CLONE_THREAD.