Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5211922pxb; Sun, 6 Feb 2022 17:54:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxM4RCV/TcY9RP6a486jYSGuAPtyQdjPDd8sdTN7gusZ8G6CpqSMKJ7jMHAU7dbN+cTVEox X-Received: by 2002:aa7:cd1a:: with SMTP id b26mr11516056edw.0.1644198846780; Sun, 06 Feb 2022 17:54:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644198846; cv=none; d=google.com; s=arc-20160816; b=mNy76XW/7jv1n3XMg/guB5hDj2dCDGTobXVZy3AWOPxVmv2EuJsI5wlOYS0MRE6Acs i3UZfIhkTTOQ53Htrr2s3pobIEjPguCwbOtGTfyS9k4zBJiNPw6+U34dd7G6vujl3S8S BpgJO+VJjB1wehOAi9z91HewsydzB7doH87SXdT+amu8nyHMdexLqrW5thmmmvrjEs11 PHSYrfJTzNOpeTvQYQt51zZOPoxh3DacxUr4mTvaM99rr5xLOaUCw2IlziMRDDr2bLOO cV8ob++1Xs8T4v8J3xpqHaVt3iAn4zfpWiZBphZKz41Kh9L94+97LOBF65VVfdnYr9+4 9IRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=96SoL3E8HRraXhW4GJvLh32KeIwpXS7GySgMx5VXOrw=; b=PST3AK2PyrCOvVTRTf9CNfD+JhYti+kjMVZF/eJ2ORchhuCr3mCAZrIazJRTVQnJEU 3sWOCeNPQNi1p0H0zuuuuYCjObRzzzS810FMusUacUpF3tU1S2TRfMByXFIImYo1pLAo xH/u4l7akzOQ4obwdXcHHdb25cawSVX3RLYkGRZW9VMpHnyUYL2M5u6UAYDdqNVslA0e w9e8viUrmPSNiKNby2XkBJr1Fh1rEiQfgOSqh6pzxzhtgO5xSwVkc2fH8F1utBci5CPe McmDlqyO5kwl3r8z4F3eZIQDGq5IC7Hrq3AbPBjZahhKeh1s6sXsiZg4CsRSvjBYCKOq 4ddA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=dl9H1uZ7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p11si6664794edh.410.2022.02.06.17.53.42; Sun, 06 Feb 2022 17:54:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=dl9H1uZ7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378499AbiBDX4J (ORCPT + 99 others); Fri, 4 Feb 2022 18:56:09 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:35248 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377814AbiBDX4D (ORCPT ); Fri, 4 Feb 2022 18:56:03 -0500 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1644018961; 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=96SoL3E8HRraXhW4GJvLh32KeIwpXS7GySgMx5VXOrw=; b=dl9H1uZ7++7Lg9O8+nklBFbOMxVaazDBU+q+U0NCRS0OTWk7CG8E9MX67//cKNReM3zKyJ kfncVJ1nKkBjP1L9TVRAO9C9MZtC4m0B19lXjGaKYxU/g9i5reQE8vYYm5f6w1JMUQ2WJW nwmm+GY9MZRT6xxG19brdWjAlnccQLCV1HcMLqbQOQgsWaK16x6fO6MqZ8A2X5irI/EiGF 3KlB8Cp9jdF/HyGLs15k1DTAer4b/VXtKypipqgBnoevbfkipIbDdLef+PLyPU/NJSuDzn zaU5OWVIoXtm0i0eZd+vfVLQ1zRrawlJ7A64Andor5vrPhXrvSb7X9TL7hNDOA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1644018961; 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=96SoL3E8HRraXhW4GJvLh32KeIwpXS7GySgMx5VXOrw=; b=boPOAy3L0uN2tjlbFX4t2zq9awzckTNT1mstjB0iv6tj8UuvZH2u6cEj7x9WyBdmJ1y5ts ZpdYSFRPbV+iUKCA== To: Fenghua Yu , Dave Hansen , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Andy Lutomirski , Tony Luck , Lu Baolu , Joerg Roedel , Josh Poimboeuf , Jacob Pan , Ashok Raj , Ravi V Shankar Cc: iommu@lists.linux-foundation.org, x86 , linux-kernel , Fenghua Yu Subject: Re: [PATCH v3 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit In-Reply-To: <20220128202905.2274672-6-fenghua.yu@intel.com> References: <20220128202905.2274672-1-fenghua.yu@intel.com> <20220128202905.2274672-6-fenghua.yu@intel.com> Date: Sat, 05 Feb 2022 00:56:00 +0100 Message-ID: <87r18ib2zz.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 28 2022 at 12:28, Fenghua Yu wrote: > To avoid complexity of updating each thread's PASID status (e.g. sending > IPI to update IA32_PASID MSR) on allocating and freeing PASID, once > allocated and assigned to an mm, the PASID stays with the mm for the > rest of the mm's lifetime. A reference to the PASID is taken on > allocating the PASID. Binding/unbinding the PASID won't change refcount. > The reference is dropped on mm exit and thus the PASID is freed. > > Two helpers mm_pasid_set() and mm_pasid_drop() are defined in mm because > the PASID operations handle the pasid member in mm_struct and should be > part of mm operations. Because IOASID's reference count is not used any > more and removed, unused ioasid_get() and iommu_sva_free_pasid() > are deleted and ioasid_put() is renamed to ioasid_free(). > > 20-bit PASID allows up to 1M processes bound to PASIDs at the same time. > With cgroups and other controls that might limit the number of process > creation, the limited number of PASIDs is not a realistic issue for > lazy PASID free. Please take a step back and think hard about it whether that changelog makes sense to you a year from now. Let me walk you through: > To avoid complexity of updating each thread's PASID status (e.g. sending > IPI to update IA32_PASID MSR) on allocating and freeing PASID, once > allocated and assigned to an mm, the PASID stays with the mm for the > rest of the mm's lifetime. You are missing the oportunity to tell a story about the history of this decision here: PASIDs are process wide. It was attempted to use refcounted PASIDs to free them when the last thread drops the refcount. This turned out to be complex and error prone. Given the fact that the PASID space is 20 bits, which allows up to 1M processes to have a PASID associated concurrently, PASID resource exhaustion is not a realistic concern. Therefore it was decided to simplify the approach and stick with lazy on demand PASID allocation, but drop the eager free approach and make a allocated PASID lifetime bound to the life time of the process. > A reference to the PASID is taken on allocating the > PASID. Binding/unbinding the PASID won't change refcount. The > reference is dropped on mm exit and thus the PASID is freed. There is no refcount in play anymore, right? So how does this part of the changelog make any sense? This is followed by: > Two helpers mm_pasid_set() and mm_pasid_drop() are defined in mm because > the PASID operations handle the pasid member in mm_struct and should be > part of mm operations. Because IOASID's reference count is not used any > more and removed, unused ioasid_get() and iommu_sva_free_pasid() > are deleted and ioasid_put() is renamed to ioasid_free(). which does not provide much rationale and just blurbs about _what_ the patch is doing and not about the why and the connection to the above. And the refcount removal section contradicts the stale text above. So this paragraph should be something like this: Get rid of the refcounting mechanisms and replace/rename the interfaces to reflect this new approach. Hmm? Thanks, tglx