Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1267863lqa; Mon, 29 Apr 2024 03:38:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwJ8ZUEuYqe10raHNDIGtnrwMN7I8bhLBCoUfLEbacrw7n+2l+Lwkfa7lH7fcLHQa6V2ATsS/8vnBZ+67HaanBqtXXoRC7hWT7EGWp3A== X-Google-Smtp-Source: AGHT+IE40rkpji4769wL26cXLPghTw+uZCBfyhyXVXPtIJyQ/AvZ6gtSaTpayLhfV26EGYF30sPW X-Received: by 2002:a17:907:20d6:b0:a58:828b:554e with SMTP id qq22-20020a17090720d600b00a58828b554emr7067263ejb.71.1714387101337; Mon, 29 Apr 2024 03:38:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714387101; cv=pass; d=google.com; s=arc-20160816; b=MchBzkzIFwEr26zJFybiyJcSoVl9xg/v2PnQEeC3ivdgjbpW1L9JCiAvHoUapYnOor AsMHAU8TzfqsS72qjl57Sa8IA1/r5VA6Vhr11Aa7kC+UpTUDoq3omPIbAzhmS0GApRju esJj4iPZgoS+yq0UAot0nNO1K1XTvQhbDW65Dn4KdfkLUxL070/VSt8BqfwWKzf/2R0F 7A+/7DDVT2Ri3Nub2w5zWxv0bgKZ4IxddetNL6JFWP136FE7+6Fo2oWC9TD6s2/r6wmG 9mq9Mj6J87eY8z569AYHQqc7MqGcEmLZ0K9VC7kzC5JNRKyu9hEU7v4n0BSSRkMjPZ2h qX6Q== 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=MCByWayo1rTtWGbtdA4qwJOFgDYVs7q3tTYHIInGmHY=; fh=9xlVfU6l1eaRMALSOTbrulKFFu6LW6R2I2OsjpORYlM=; b=F/B2zm+UP0pCe6neC8cQY1FC9QncxrC1RlUH8Voac+ja9eiWK7Ydh1IZSVlNobyt67 YzYeuA+bkJS/sicK+mnMmOCp190G+qqUeT1SMN+HnBa9QVviOjFcDi9a/Q0juqz161XD Ya/5KYU0RA38scCSrZ8FfSWMLYuzEdODhsYBuXA1F3yx6/G4NPGmwifita+8EsY1oYMr JWFOJHmrM19aMgw50JhMH6RVedprw9omUkcchWfpWQ4pL9qpLJFPjeaQIuY+x/bEWucK 0pLHGmgnDyc5LjmrswPj61kq1GAI4iFaanxs1TJt20iB2TmPeLcSHztqcRh39YAwlJds SyMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@antgroup.com header.s=default header.b=V9juz5Rx; arc=pass (i=1 spf=pass spfdomain=antgroup.com dkim=pass dkdomain=antgroup.com dmarc=pass fromdomain=antgroup.com); spf=pass (google.com: domain of linux-kernel+bounces-162072-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162072-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kq19-20020a170906abd300b00a587342f7b5si3509366ejb.332.2024.04.29.03.38.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 03:38:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162072-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@antgroup.com header.s=default header.b=V9juz5Rx; arc=pass (i=1 spf=pass spfdomain=antgroup.com dkim=pass dkdomain=antgroup.com dmarc=pass fromdomain=antgroup.com); spf=pass (google.com: domain of linux-kernel+bounces-162072-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162072-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1717C1F21E2F for ; Mon, 29 Apr 2024 10:38:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DBFE4524AF; Mon, 29 Apr 2024 10:36:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="V9juz5Rx" Received: from out0-210.mail.aliyun.com (out0-210.mail.aliyun.com [140.205.0.210]) (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 B83554E1BE; Mon, 29 Apr 2024 10:36:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.205.0.210 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714386971; cv=none; b=OY/AeFbaM4mUC1XqttBjvRkZi46D/xLwuuPFgtRtbnY3z4802xH7vn1SYaoveW9Ioq4NnpaG8Fhs9jsMu7sC5sphql6xPBqbVCQHxPWRXZwJiR/FByG+7AR8/ZI0zuu60juUkxRbyZ6H7iB8cZNFwXAatBiTQ2dcsc9xVknnt1w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714386971; c=relaxed/simple; bh=VY9sZlLbdOohRHek7Or+cOx51HaBJ+7tOVXra2qD9VE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ar68NBxp9A97f/Q6H772Xi5qj+yroP8ZAi+fx3I4Ha+bWHY2yrTJfnAU2BaBlnwOq1iPcbD5aQS+cBezoEY/TlHVCczJ3PQP3XSsmTioNowX8+r4fbS7o+unG6LfgTmcGDzIaFBdTZRZZ9+pDNipouGAKpdBoAcl03uDW/ZsnQA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=V9juz5Rx; arc=none smtp.client-ip=140.205.0.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1714386961; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=MCByWayo1rTtWGbtdA4qwJOFgDYVs7q3tTYHIInGmHY=; b=V9juz5RxFGMGwrjlGxUh97IayTySsqHdx93GAsZJba2WhiS8GGBz02xt4XsuxTdbaQ9wKXc7rUzfor1j2xII6VQP6ynLRcRZTlCtX/ozvt3PeNKrm2W2FTXR2a1q32wbdkxfpqivwBtjHj2UacqHIdl2SS6tZ0M5i4ybLeSuRJI= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047192;MF=libang.li@antgroup.com;NM=1;PH=DS;RN=17;SR=0;TI=SMTPD_---.XOEanMm_1714386958; Received: from localhost(mailfrom:libang.li@antgroup.com fp:SMTPD_---.XOEanMm_1714386958) by smtp.aliyun-inc.com; Mon, 29 Apr 2024 18:35:59 +0800 From: "Bang Li" To: akpm@linux-foundation.org, chenhuacai@kernel.org, tsbogend@alpha.franken.de, paul.walmsley@sifive.com, palmer@dabbelt.com, chris@zankel.net, jcmvbkbc@gmail.com Cc: , , , , , , , , , "Bang Li" Subject: [PATCH v1 5/5] mm: Add update_mmu_tlb_range() Date: Mon, 29 Apr 2024 18:33:46 +0800 Message-Id: <20240429103346.59115-6-libang.li@antgroup.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20240429103346.59115-1-libang.li@antgroup.com> References: <20240429103346.59115-1-libang.li@antgroup.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 After the commit 19eaf44954df ("mm: thp: support allocation of anonymous multi-size THP"), it may need to batch update tlb of an address range through the update_mmu_tlb function. We can simplify this operation by adding the update_mmu_tlb_range function, which may also reduce the execution of some unnecessary code in some architectures. Signed-off-by: Bang Li --- include/linux/pgtable.h | 5 +++++ mm/memory.c | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 18019f037bae..73411dfebf7a 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -734,6 +734,11 @@ static inline void update_mmu_tlb(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) { } + +static inline void update_mmu_tlb_range(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep, unsigned int nr) +{ +} #define __HAVE_ARCH_UPDATE_MMU_TLB #endif diff --git a/mm/memory.c b/mm/memory.c index 6647685fd3c4..1f0ca362b82a 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4396,7 +4396,6 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) vm_fault_t ret = 0; int nr_pages = 1; pte_t entry; - int i; /* File mapping without ->vm_ops ? */ if (vma->vm_flags & VM_SHARED) @@ -4465,8 +4464,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) update_mmu_tlb(vma, addr, vmf->pte); goto release; } else if (nr_pages > 1 && !pte_range_none(vmf->pte, nr_pages)) { - for (i = 0; i < nr_pages; i++) - update_mmu_tlb(vma, addr + PAGE_SIZE * i, vmf->pte + i); + update_mmu_tlb_range(vma, addr, vmf->pte, nr_pages); goto release; } -- 2.19.1.6.gb485710b