Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp62762rdb; Wed, 14 Feb 2024 12:46:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+Tfa8vY8Bl+DUwhWVSEXd91QV0cf0U1JkUnckzkFDXPJXXMsT1as7keysbSjdUWQU4ruqvdb200+dGs+03F7DDNECwJzvdg9SINHkaQ== X-Google-Smtp-Source: AGHT+IFt9TsULBNRMdw/ZVARyC1Kj65tDwLs5oExbUdYDqJ0fHQx/UnWwFA8QkQdGWl287PWWnhZ X-Received: by 2002:a17:902:7c0f:b0:1d9:6e53:b8d7 with SMTP id x15-20020a1709027c0f00b001d96e53b8d7mr3314351pll.28.1707943605752; Wed, 14 Feb 2024 12:46:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707943605; cv=pass; d=google.com; s=arc-20160816; b=SmOFwbILBQLNFOSqmgKtdbDtkqOHTJ6YfjRdMDngVLBUyr+rQFS7iJKpwhcE5VxtZO gyTtOwgF7BOMATE7dCg97QXIoCzEdAukPyiTwGjJ6LB3jv6KWdZR2x/Cdm9vSPudKnYu UEsSBmCTnEZnqyi8eJ5ev8lRAGPQVjKWkgfTufIDzC3Y1r8HGjJ49NYWTQCOxzLBdHBY sSyWbCsfNbI3xaRrc1Bcwkk5XDBNl2kPPMgChzo9sLkO4WWYZpb4Ev8Qvy/is0XFXACn zBisTje/cYno9ApEJwjV6HUtn4SBAQNdP9t2U9nVy4kUW67PiFsqSxHnUed5ITczcJeS rxqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=X4BN9bDZrrapc7Xd1FDfmQmuEZxXG5tNILRPdL9R2lg=; fh=Y/uwmpgDEzDLLNie+lJ13mUFpBKQmn5Xq0feRKcAV/E=; b=R2L+HEl6eC2ClF8YijG9IB0P1uJBrHGPV0kBcvggozKHnzenqf8n3CA8rVBdcv4XoU Qstk9kJyCvycnYo8hkiSRXKaFWFpgJz5ju3hay8rbOIJYP67oxIKeEgzNDR9pjRM9Hob Zz7n/SoNgV1CCQlCiIIyRrYQRiEqOaeVY1XePVD+iw+v8eTU6khb1sO5/KLgjjVPVP91 3ENSVSoIEpej1bCecEe3lw657qPoNaZFKgb+rW3aPVrtgueobWL0TtGgBL2w2keEo6kU 8lmNkm6ASABjcVuQn4cmAgwliEX2p9KArpBP416ZeNpgWHohSnKmUfN/PB8HP3l8bN3M ixQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Zd5fCEfy; 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-65953-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65953-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCXaELbXz1ARIk5PGjlztpcAZ2xQNyYXPmWc/P3pUNzT4EzaMs5qOVERP/zJd6W+u8wvDrMcfPYE0aG1kfW9HqdAxD18gAfVBdWDIHM2Xg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n8-20020a170902f60800b001db4cafb9f2si2472031plg.517.2024.02.14.12.46.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 12:46:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65953-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Zd5fCEfy; 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-65953-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65953-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6DB3F285123 for ; Wed, 14 Feb 2024 20:46:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 884201420B5; Wed, 14 Feb 2024 20:45:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Zd5fCEfy" 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 4388E1420BD for ; Wed, 14 Feb 2024 20:45:16 +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=1707943517; cv=none; b=Pqw2pr8pb+eZNLOMXyiLSfteGtB1TQvBSkwUHh5Zyrv+xo/l9vLB2m+ANVHA0XnZUrU7O14aE3i+9FnlteZh3FUpyHp43K4+hZLkMrHXFbOiEZyn0z0kxsjfIXm5QhQHjSzhtmGv/IpIeRjIxMHXGYYF7E1a4lGkvNK++o9y7dE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707943517; c=relaxed/simple; bh=3PQfbTkS/vd68uh/N1+tvV3UXJ8B0ItANJG44cGwxXU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qx0nlfygZ840Ax1qqpPidkPxGyppbw7w6XCiWfcJ2Of+cwzJ0lZV4oYCLqYVP3VARZwJXOWHOLCjoUJvx501lA1TlLDVqqyjmZHApo/i5JDgF6ON5mwFWdBG19NrC/1UXTi1fDftYfX7lPNBH59w5VyRUqbROkiuSdt42Ds2UOk= 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=Zd5fCEfy; 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=1707943515; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X4BN9bDZrrapc7Xd1FDfmQmuEZxXG5tNILRPdL9R2lg=; b=Zd5fCEfyBfpu+FQ/1A82MOcZyIcWwqwMQVk9sVixLzuQ7mXDOJTMt5plnz+favBpSl/HD9 qB1X78F0GEPUL7oOIjCDoHE5rShqYP0TSfq4ptFvPjkgbgZAhQpq66QqlFDHG5cV+GnU85 +yp9au8rEpKzytB2V1u3JxIOlfVVQxs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-520-D3IZQFsSNhyFuV3-aH76jg-1; Wed, 14 Feb 2024 15:45:09 -0500 X-MC-Unique: D3IZQFsSNhyFuV3-aH76jg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6ACBD811E79; Wed, 14 Feb 2024 20:45:08 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3DCE1C066A9; Wed, 14 Feb 2024 20:45:04 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Catalin Marinas , Yin Fengwei , Michal Hocko , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , Michael Ellerman , Christophe Leroy , "Naveen N. Rao" , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Arnd Bergmann , linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org Subject: [PATCH v3 07/10] mm/mmu_gather: add tlb_remove_tlb_entries() Date: Wed, 14 Feb 2024 21:44:32 +0100 Message-ID: <20240214204435.167852-8-david@redhat.com> In-Reply-To: <20240214204435.167852-1-david@redhat.com> References: <20240214204435.167852-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 Let's add a helper that lets us batch-process multiple consecutive PTEs. Note that the loop will get optimized out on all architectures except on powerpc. We have to add an early define of __tlb_remove_tlb_entry() on ppc to make the compiler happy (and avoid making tlb_remove_tlb_entries() a macro). Reviewed-by: Ryan Roberts Signed-off-by: David Hildenbrand --- arch/powerpc/include/asm/tlb.h | 2 ++ include/asm-generic/tlb.h | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/arch/powerpc/include/asm/tlb.h b/arch/powerpc/include/asm/tlb.h index b3de6102a907..1ca7d4c4b90d 100644 --- a/arch/powerpc/include/asm/tlb.h +++ b/arch/powerpc/include/asm/tlb.h @@ -19,6 +19,8 @@ #include +static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep, + unsigned long address); #define __tlb_remove_tlb_entry __tlb_remove_tlb_entry #define tlb_flush tlb_flush diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index 2eb7b0d4f5d2..95d60a4f468a 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -608,6 +608,26 @@ static inline void tlb_flush_p4d_range(struct mmu_gather *tlb, __tlb_remove_tlb_entry(tlb, ptep, address); \ } while (0) +/** + * tlb_remove_tlb_entries - remember unmapping of multiple consecutive ptes for + * later tlb invalidation. + * + * Similar to tlb_remove_tlb_entry(), but remember unmapping of multiple + * consecutive ptes instead of only a single one. + */ +static inline void tlb_remove_tlb_entries(struct mmu_gather *tlb, + pte_t *ptep, unsigned int nr, unsigned long address) +{ + tlb_flush_pte_range(tlb, address, PAGE_SIZE * nr); + for (;;) { + __tlb_remove_tlb_entry(tlb, ptep, address); + if (--nr == 0) + break; + ptep++; + address += PAGE_SIZE; + } +} + #define tlb_remove_huge_tlb_entry(h, tlb, ptep, address) \ do { \ unsigned long _sz = huge_page_size(h); \ -- 2.43.0