Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp426979rdb; Mon, 29 Jan 2024 06:40:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQZ4vRoMg6i6JdEnqh9EibU1V1JXy66vhjcQILzBagp+iOIgnar66N+vnGCjbEOU/FNklU X-Received: by 2002:a05:6a00:2da0:b0:6dd:7b4f:ed8b with SMTP id fb32-20020a056a002da000b006dd7b4fed8bmr2311814pfb.27.1706539216688; Mon, 29 Jan 2024 06:40:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706539216; cv=pass; d=google.com; s=arc-20160816; b=wo7lztz7P1b9SuJmrPEdAmQQLfmWidoHSboIUP4cDYXCmkZM8Hr+zBHajP5lIoX/dR YZzZ7WpE1zqL0becQGPxFv41grQv3X6Tq31qK3gEtH/lulXDzzBhbCGKKh6IIelXEuqd 92GpLe358did/RNBaLhWTHrh0Jf3CYzU3VCtJlvRQqUnqZ6L1M7PPxzCHcx6AiV9orly KFnTs3x/G3Z5WywYmvE5MVrIv40nwuue031h/0YcP4vPvODO/EMWMjOXV/fxD+CYN5yU 26mmOw8JLzwddjUfgIlLQTfwRf9RPvxA1gwp3KKQKiwPHw4+bRAAzaWC7mNpriUeEwWQ RD7A== 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=hD+wJlVoYoeun3CtWSKYM8LYSFldaYp0TLUcFe85aZ0=; fh=18RVDvllJ6L23pprpg+CRg5YQHffBN1k78GW6gBbnXE=; b=YkW8iHYwvaxmu1sQpgb/C0tltMugMqrV/MA1gKxQt+5LFPGagZrJMOhKDCpwc9fB7V YZp03CvFM8E256prqPYqh67XJzjyMorlGVaroT9wr2R/uxhs6JImAtRQBYgwW6PZn0bA Ev0In0ktLZit7MoHRgiMNnPNxfnN/BXrvksj77MJzzWkone2AFB9dmFGU5ufEA6nvxzR kSjuY4+ir9bgNT5YIUFGYAe9tOfOBKGQJP41tUwXQ5vjHa3j67ayHyn2zYQKVAA871cM 3EIOzfddMW3TFHp+W5OudujJCRbO3WR6PMiVtNM/GfqcmiXEqXbCyUedMMoqcjeCsxJj QBYA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NU96guWR; 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-42918-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42918-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w19-20020a056a0014d300b006dd82e644f5si5851903pfu.288.2024.01.29.06.40.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 06:40:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42918-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=NU96guWR; 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-42918-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42918-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 BF2CF28B883 for ; Mon, 29 Jan 2024 14:35:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4794315445E; Mon, 29 Jan 2024 14:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NU96guWR" 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 051621534F9 for ; Mon, 29 Jan 2024 14:33: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=1706538798; cv=none; b=CJqMSxPzLlOoxbvCcCKUYSvxFGFMMK+fsgSVFiqXyZp3tYoua5xYDO9sS2bbNqm0ToJ/x48anfIrbaeAYACrevfQh2K/lnFfpHC9254pins0C3HfKHqwYshx6znvxqG1ZuTFJ82u13wXJR41ngP80lm0roWjy1N0glOHQOMbGLo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706538798; c=relaxed/simple; bh=zw6RATGgPG5UGfHtEP8dnEvhsSimfAqvKLqzhVagRpU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BUoIGpBy/y73xoMP7FpB7dVtu+N3gi6o8mKH9sJSLFppB8taj8oEasyG6QVtUJWY4qEFte+04wRCo9mqWLnuZbQ8HU9ZhAZV4XUtL6QeMHMQ0BkclyddsNBaIB1ld6JupBZXr4uqF6TMwbi2vEsX/Fj5tTEbN6LH2Sepms3V9kM= 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=NU96guWR; 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=1706538795; 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=hD+wJlVoYoeun3CtWSKYM8LYSFldaYp0TLUcFe85aZ0=; b=NU96guWRNiYjInyiO/0AgWcC10x1XAYIMmtrEvJphrxQtKqE9SUWtXqgN2LoFHVlDwt1Gp i9vHEv9ubuCjcuvYCnhgtOLlXzKF7haQK+Ur12nXVfVkW5GRnIzaLxdy/WuuUNkrzNVudx vWdsYb3sjJsdtKCepJ3vs+gbCXSuPJo= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-64-0ZkSAIR7N62aRzlXnFbltw-1; Mon, 29 Jan 2024 09:33:09 -0500 X-MC-Unique: 0ZkSAIR7N62aRzlXnFbltw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 88CF43C13A9D; Mon, 29 Jan 2024 14:33:07 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1D40AD1; Mon, 29 Jan 2024 14:33:02 +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 , 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 v1 8/9] mm/mmu_gather: add tlb_remove_tlb_entries() Date: Mon, 29 Jan 2024 15:32:20 +0100 Message-ID: <20240129143221.263763-9-david@redhat.com> In-Reply-To: <20240129143221.263763-1-david@redhat.com> References: <20240129143221.263763-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.1 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). 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 428c3f93addc..bd00dd238b79 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -616,6 +616,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