From patchwork Mon Apr 29 10:33:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bang Li X-Patchwork-Id: 13646591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C0E5C4345F for ; Mon, 29 Apr 2024 10:36:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1B306B008C; Mon, 29 Apr 2024 06:36:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E55066B0092; Mon, 29 Apr 2024 06:36:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA8216B0093; Mon, 29 Apr 2024 06:36:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AA8236B008C for ; Mon, 29 Apr 2024 06:36:05 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4978240B55 for ; Mon, 29 Apr 2024 10:36:05 +0000 (UTC) X-FDA: 82062214290.18.CC9AD04 Received: from out0-221.mail.aliyun.com (out0-221.mail.aliyun.com [140.205.0.221]) by imf25.hostedemail.com (Postfix) with ESMTP id 30CD7A0012 for ; Mon, 29 Apr 2024 10:36:02 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=antgroup.com header.s=default header.b=YOwVAoZk; spf=pass (imf25.hostedemail.com: domain of libang.li@antgroup.com designates 140.205.0.221 as permitted sender) smtp.mailfrom=libang.li@antgroup.com; dmarc=pass (policy=quarantine) header.from=antgroup.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714386963; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MCByWayo1rTtWGbtdA4qwJOFgDYVs7q3tTYHIInGmHY=; b=X0zuvuXREiAAo77TmQuc6USRGBEtGKR7NoL/qiMIlud1ueOKA+3t/xcfd+TSWbRP79vOlD bHB16COJKcS/M3jZ0IS+o0ta9+O3gMi/AxfruZNFC4eZh84r6riYP73CwisdUXtExBIDkx DspAV22/4ImhkmsjJkF1K891t+QkPGc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=antgroup.com header.s=default header.b=YOwVAoZk; spf=pass (imf25.hostedemail.com: domain of libang.li@antgroup.com designates 140.205.0.221 as permitted sender) smtp.mailfrom=libang.li@antgroup.com; dmarc=pass (policy=quarantine) header.from=antgroup.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714386963; a=rsa-sha256; cv=none; b=WLXna4iu+ROJWr0FCtTS6EOA3f70EHq+HbOtohZwxzLrIQ9OkeDlVQhomqQIEb+2RTK9nc Nv2u0xL42T2ROSBNXSxOZWualuwEoVFKKH/kH9s4+YNI9oEmPUuh+wp0epUKq2C6a7BDIy 9GBGKkjXMEXWkzvLieMsqdQckx2FC1k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1714386960; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=MCByWayo1rTtWGbtdA4qwJOFgDYVs7q3tTYHIInGmHY=; b=YOwVAoZk8FqMSrg8/9ps1rdKpTCIBOfsvyANgI3kLYOVTsvcYX7glFlsHS8M9hqn6NOyXE6+H9eCI4aEqGZH76h3zDuxSTkI/Rl2/yA56vfx+h+sfA1zCcbCvvXLJgQ6N99votAuMlSHmBy9gL3zl6kd4v4+YbPtoGeWyHWKg1o= 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> MIME-Version: 1.0 X-Stat-Signature: k518o1wamqhipk1jctnuowo69tzukcp5 X-Rspam-User: X-Rspamd-Queue-Id: 30CD7A0012 X-Rspamd-Server: rspam05 X-HE-Tag: 1714386962-713004 X-HE-Meta: U2FsdGVkX19IYVdWmQk7/CJiizM36PFk/ZR/vMIxeONtquAyQlJw7k3d33cKrexDYd0T4WehDhrSMLFaQdzS9ZOn+EnMex2wcUPRM4WsenM865HuMjj/o3Ghq2R9pU0Ul2Rs4hcb7XzcgyYhIJN4fSCfz7x75pE0uqCqHu80FnR1jIbV36kNmXfrJ/BqynG/0XJTBYhAJLbZlo+CGjv9WlBDrWod1IovDKSLAIH//OIUPd4R1S6ycuZD6P+d8RIVOmHlKQgTNq3L0PJsmlsUbVEU4pC0WQnljTcfFNs2DWuEuF4ZDKTk/RKy2XCNyWSnhZGsvsFECr9Fhb2yXZsFJ3vvAK8q/jVVl6kiOmEYQ6x9S4tQzoAT+26xIQldKPGPdUDN+1ch4gRWM7G902k2X9/67Cd53Nkruh0qWjuv5sE34L9ydWLE8E8KL0uAWFcsOJMZmkVh/H8pg7PKwuvNmwgZ4AQxgDRhfzGch5GezSw/Bo2qVhBbA8VPRuU0eF4ZyLpiNz95ynEjZuo1c6cy4URZDVboaKlhnfY4gJ1OQYwf6k5YwC07p2j+q15XYHrzdCWSNmuNClPFvJpMmkEcTGsfe8LuhHhst73MV3dIusenG1jPbuxyZGAyMEooTxe2j7PW4PJ0vF7mKi2jk30qegVrsneTNhle9EWtKVDpBWsUUvohvX7thpwJRoZRaXofLsfSK/H2zYkjyxTpIGm5bbnXQuleZyqGil+GKQFjeR6mMmMJDZddERIexxx1j028Cp2qfjwkckto24qaBns7vbyUqX83UdtKeq5h1LAorWsikT1rzewCjjiw7vvtggGUIFYy5QHJFfotDNgIwqHn+bDrJ3wdmBRi0Xrn9bXP8lYQny7Hl5RyZPmRdcDXVVa8DleRvnG1Jcq5YEShnNbXEy72eneTAC+tZyWDG3bu1BIHdAcXUMHjmBCXErcAfSRv1fthaUyG2iZu1w3ialf 3h7q0/ST 8Va5+LTOxBT5RN1boBDnfch9M8ONrXP1NE558+2HBRxd5kAkpOrDDLytLWWIdF2rVWJ1e2xZxOHlksFVkhFc+j8lOZ3khNtpR6XqkpXsyRNdawuo6qWFz7avvhxXR4TgufD98cWP8Gh0bNx7mTfpR57AYOjY/+6rPN3kT4XzUtJw7i8iyqccT0fWXv1YxfvUQppZjgxD8Md1HDJdHVPvDpJwPr6pomNSoN8ZJ5r/6qjqQ/vLwAeF4vN+Oh+jWtwcQ61gQySdEnI+hiefjIw7+yMkLs3o2KFF8v2OFWqChEZ1Jyo5Z5i9AlKB4WsqSyvv2KN1YIrQkBtRMnfJeewBNlKyA2pU1YpA0P0t8MmXzDVy/5qi/ZFpuCoGiMg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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; }