Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1217637rdb; Fri, 9 Feb 2024 14:17:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVXbmw3m36Rkj1vkN5bHsskerr/USB5yjEfMm5m+JWRe8ByD7OT3HvrFlCdoI1Q9GsfOsuN18uExMC5zhrEKjC16Llqp4GzQyrEdY3GEA== X-Google-Smtp-Source: AGHT+IFqEWzFRmnvBX9Mrns7M13vmmlhUzB3DmDKPUYfB7RERvykcOAhYPvruxhP75YVsIikFPTj X-Received: by 2002:a17:902:fe0c:b0:1d9:f75f:7657 with SMTP id g12-20020a170902fe0c00b001d9f75f7657mr667153plj.5.1707517053042; Fri, 09 Feb 2024 14:17:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707517053; cv=pass; d=google.com; s=arc-20160816; b=fhGx9BgszL9FwzExZfMb2UDgS71OGAev6POeqvKzmMfwkHHWck9rkNXJ9NkXaPjUN+ qunCT9Zc9/5th7i2hKuVMpYlgbwhBhm0g2mNhlvjL9Zw7gNu3IcraD0TL3jGhm5wJVsl adW1C+K0KVeJ+YB0tdJsCR9KnsBEKX8teSWVPJXwT4/quBDElegZM/M45EyvL1bR5zpp twDAja+XnyM+RiIvv/cnKapqPxrmtUZnaBHClfC5icYv57OZhgLqBiUn8Rur8a5wtYPT jPuUJUsqgUYm2yGmsy85cQ4gzgq7UdIdUXwlzhw8xtriwUKnkY/JAnvIyRWKajIJm8mA 0TUw== 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=LUk7tzo1Jxfji2RkaC1Rk6dgWaG1T4NpJuYZ/lkkZ2Y=; b=MdeApMovB7ZrdPkIkO3PI9y/xAKvZNonlMTadDCaiNxUfWjpbHmnmR4jVUGHVAp9LE uyINMDbrFc0U46hu33sFGdyfafxfB5bGPHdOuXsywfZ0RsaLuZxEW8TgYHVMp8wYf2RH +RE06XSLka0Aj5SvDFGbP8huqLGp0O4ZsOkdHzzbOQWST8pYnEMeAlFeG1yJhEdFll4p PtQ7zVnDypwFL8MpxpTZpKpaRqKg+8kks0pqD2Ub/NCuanuQ2gaVpkuNI8osAvBQN31j AdCsiFvo5LIEUbLMSfuAzDY1zlUExwzWFBL1JfQc64g6gelyOR7sXihtp4mT50TdSLO/ ha2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PNAyHPtf; 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-60079-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60079-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; AJvYcCXosy9vtKkFiX0W9EOymcvcUGMzcWS5MSzpUWLG3zN9GVuowU29xK3b9xd3XN7b8v415CEiUPmOKhH2r2rWqzRtDwRVDXT+H0aysEN0yA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i10-20020a170902c94a00b001d93327867bsi2431008pla.286.2024.02.09.14.17.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 14:17:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60079-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=PNAyHPtf; 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-60079-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60079-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 CA5AF285603 for ; Fri, 9 Feb 2024 22:17:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 683AC374D4; Fri, 9 Feb 2024 22:16:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PNAyHPtf" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 1ED1336AEF for ; Fri, 9 Feb 2024 22:15:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707516960; cv=none; b=bqYUfTV/LXzO3IhLsRFyXEpaaMDjgmMF9McgVkmx5Q+MIq8Vep92Mzljw0UsnH9XCC2vJ02dcIMp/U2bduIuVEDfrDuoNIsoLfbANyK0DSg1WQJDSpj7yWJl3cLA56X7JXXBQ480YrK0GIk5xk17+u1BqooG8RrXAX5IaXIy19E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707516960; c=relaxed/simple; bh=3PQfbTkS/vd68uh/N1+tvV3UXJ8B0ItANJG44cGwxXU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nDP4z+jRGlhpq+mVrj6S3JwWIJ4/H8XvPD955KFEH/aTM9VnQ37ZME2EOMviZNNyJ4yschoCR4o3qwIbzWF1yGEcHj/pjJ0WVmlUrlOvVi8SJeoThrcVeax5iYTvY4Nv76mbOfp3zCnwSbIeG6TuRqQmQDm06nu0VP9+ibMx5yc= 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=PNAyHPtf; arc=none smtp.client-ip=170.10.129.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=1707516958; 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=PNAyHPtfJPw9kdskRJq+fXgxFH3vYP1viGXv3Re4GGsn4DPnwOb5hrKK87xksgv5GSLFWY DF81JeQVfNXAZ7oGt19XbXtC3GPSwv9DM9ksDneFguqkXUHcxEqlnpgwSeK7eZ2I9gdgZ3 yyeO7epHcuG7S1SIRO84+IFOT7kei9Q= 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-373-AMAEvJNUPyeeH3DHaeR2Bw-1; Fri, 09 Feb 2024 17:15:52 -0500 X-MC-Unique: AMAEvJNUPyeeH3DHaeR2Bw-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 9B6CF83722E; Fri, 9 Feb 2024 22:15:51 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.194.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 666531C14B04; Fri, 9 Feb 2024 22:15:47 +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 v2 07/10] mm/mmu_gather: add tlb_remove_tlb_entries() Date: Fri, 9 Feb 2024 23:15:06 +0100 Message-ID: <20240209221509.585251-8-david@redhat.com> In-Reply-To: <20240209221509.585251-1-david@redhat.com> References: <20240209221509.585251-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