From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (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 626841DE8A3 for ; Mon, 6 Jan 2025 17:35:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=96.67.55.147 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736184948; cv=none; b=s9weFUNo9oKO5yvhwm3qJWcB1a6a0rUGxOT6VGOKIjGbF/5rN0b9XYjS3U47dG81E+rvN/UmEcVjBYphyLc97zlCLxMN+PQmemFKSOKrSi5r8lYNzCmCRy0dbU0elTVb/TJRu8FsrSd7A3FnEg5uuheFVB++u88k8Mgc45k5JM8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736184948; c=relaxed/simple; bh=osA6VTgbDQ+O31X4owuf7j1QBJkqKvwO2R/9mV7ULA8=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=fYcu1EdZFMAseC5xyc0vb08Lh5qw4tJ7jO48EW7hHD8mqUPZe4rglIzSXvpaMH/x3p1mQyzkykS51X58C9xo2Bj8ZTxiNwO4+sds2OMgexLjQiLeTXJ3qOXZvnOtI3sJpZDN6wOivmlvtZF9V55kHiraUTv8U0CJFlSA+1Q+x8c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com; spf=pass smtp.mailfrom=shelob.surriel.com; arc=none smtp.client-ip=96.67.55.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shelob.surriel.com Received: from fangorn.home.surriel.com ([10.0.13.7]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.97.1) (envelope-from ) id 1tUr0X-000000004Ds-0wdn; Mon, 06 Jan 2025 12:35:17 -0500 Message-ID: <978b4da7c7949e70a515fd04279e12a39e575f1b.camel@surriel.com> Subject: Re: [PATCH 07/12] x86/tlb: use INVLPGB in flush_tlb_all From: Rik van Riel To: Dave Hansen , x86@kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, akpm@linux-foundation.org, nadav.amit@gmail.com, zhengqi.arch@bytedance.com, linux-mm@kvack.org Date: Mon, 06 Jan 2025 12:35:17 -0500 In-Reply-To: <194072ff-32af-4a5d-8e73-0a45f75290e7@intel.com> References: <20241230175550.4046587-1-riel@surriel.com> <20241230175550.4046587-8-riel@surriel.com> <194072ff-32af-4a5d-8e73-0a45f75290e7@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.1 (3.54.1-1.fc41) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: riel@surriel.com On Mon, 2025-01-06 at 09:29 -0800, Dave Hansen wrote: > On 12/30/24 09:53, Rik van Riel wrote: > > --- a/arch/x86/mm/tlb.c > > +++ b/arch/x86/mm/tlb.c > > @@ -1074,6 +1074,12 @@ static void do_flush_tlb_all(void *info) > > =C2=A0void flush_tlb_all(void) > > =C2=A0{ > > =C2=A0 count_vm_tlb_event(NR_TLB_REMOTE_FLUSH); > > + if (cpu_feature_enabled(X86_FEATURE_INVLPGB)) { > > + guard(preempt)(); > > + invlpgb_flush_all(); > > + tlbsync(); > > + return; > > + } >=20 > After seeing a few of these, I'd really prefer that the preempt and > tlbsync() logic be hidden in the invlpgb_*() helper, or *a* helper at > least. >=20 > This would be a lot easier on the eyes if it were something like: >=20 > flushed =3D invlpgb_flush_all(); > if (flushed) > return; One issue here is that some of the invlpgb helpers are supposed to be asynchronous, because we can have multiple of those flushes pending simultaneously, and then wait for them to complete with a tlbsync. How would we avoid the confusion between the two types (async vs sync) invlpgb helpers? I'm all for cleaning this up, but I have not thought of a good idea yet... --=20 All Rights Reversed.