Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp17715lqh; Mon, 6 May 2024 09:53:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVO7rLKH4iX0UeqbBKZoOCwt8YxMH4jFZY7Z+OKm4xVeWCPN8IedDCqTu5PhYNkbmFrDPkggvHRA2XYjrdwoEVjNk6npN8OW65Mh0OmUQ== X-Google-Smtp-Source: AGHT+IEDaiF0iLtzwCuTJ+GyRoh9HC1JaJJodbVr/EMcEyK+oeGKohC+2BmClQfqvG7sXZTATjxq X-Received: by 2002:a25:74d7:0:b0:de5:4bb7:b237 with SMTP id p206-20020a2574d7000000b00de54bb7b237mr10867967ybc.39.1715014414030; Mon, 06 May 2024 09:53:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715014414; cv=pass; d=google.com; s=arc-20160816; b=H85V2RBEEJUIKvnn2kXqaLj8/YUvyz6XeTl34F5TaNdJjZznsJNz+tj+NdMfBk0+G8 Wxlt47Lg3vf45J2PfS17K6TblycOGk+ktcWbJZqTXfMIhrsGFolZ5Z7UQFEzAi+sv/UY BeiSZ1ponF/Uod1loF18Fm8SuJFe3bgQJY/nPDr82sZIeCzgvotM8WrPl2bjlZ0egqoC 1W8hQz6Udb6INcd8sHC1bojCFoCE9DN7NOMkWTEGVHiu6+9GZmq/clbogr6AvPxNk6f8 pTIKn9lZJJZzA4xBeAKvnQIqRL4ey1OkwEoFxyeEnnH4tAEKpM3S/ukdC7aI+jS2B8zN u+Aw== 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=ymFvshx88TI9/EMP30aaqBdjrnITBbXYS6oOftHtOBQ=; fh=ZaPvTvk3greVAhtlw/faBL7y/bcze5JBULOYO1tsevI=; b=lZbsCskNJ9xTqhdN/VLiz1zA9Mit/zBexppx1Mp88soccwgjsgA0wxxlTrho0u04Ts VQ6AoEgirSJiyEeqkaZcMX5CBv0W78H/Wc3roSv0AwujhHC7XO5fI1FUAe+sRxC3AVfV TWOf+x9bKU2eetEAAdgoZKx62d8X6BjMrfeMMKDK/54RTmh9NYzxZIpVUHKL+5oT+1o5 +xHsXfX67oARa5ItixskmrbkwNHqc8pHL+TYTANZJNW0AJpPZa8mCVLWOc0SebPVQO1G fGhx2R/DrfiFNeiHCUmz94DULCi+UwZUlY9qlrKbKKUyiF3lMkkRaNj80eFRBRcMZUu1 4RSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@antgroup.com header.s=default header.b=M5suovjN; 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-170194-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170194-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ay39-20020a05622a22a700b0043adaca2e97si9098802qtb.671.2024.05.06.09.53.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 09:53:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170194-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@antgroup.com header.s=default header.b=M5suovjN; 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-170194-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170194-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 970611C21551 for ; Mon, 6 May 2024 16:53:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F455156F56; Mon, 6 May 2024 16:53:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="M5suovjN" Received: from out0-204.mail.aliyun.com (out0-204.mail.aliyun.com [140.205.0.204]) (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 33AF7156962 for ; Mon, 6 May 2024 16:53:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.205.0.204 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715014403; cv=none; b=I48jR+Dilep5gjClrYyNeRS+gwO/NyqpCfWkSF6xeGg0P9wIYJq7Dt6RXjSnxwGclAcl6h45kJBo1N39SYoj6R9X5bzDVSr7kzx7EOrkF+QSEX5FMD7Fz+51nySS4Gk6JTt7TV92kpIOyMt0aeXavwB9FyG2U8di5sam+DkyLgM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715014403; c=relaxed/simple; bh=e7JJYP/g+sDc4N/7sf9h13R9fpx4WxxFXgInVxkTCBM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=seIhzJCdvFc5vnU4OZLrNAlZ8DQR5y1NwdM8HX7G6W/HWG1WvIzwVl9AbfYInoGXiy0DMEz5URMkDxYa6I0oUTUnC750T70EpVDKJQIi3QDnrS4jseEGJoKZ2yw57dJ2mu8bgpTj1gZrrJtir2nlRYhswLReOI3Efs2ZaAjXcHo= 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=M5suovjN; arc=none smtp.client-ip=140.205.0.204 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=1715014398; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=ymFvshx88TI9/EMP30aaqBdjrnITBbXYS6oOftHtOBQ=; b=M5suovjN6Fv9Goro4oyrEfRW3uE+PwuEtO1cMCOsIPqvpMgccj54ki/Er0Kf3w9EN+98J8MeH/taoLpnQwPZYi5GJTPCvjBXy8h2wrkvQf6se7McnSNB3QnjQt2WedfjlR6/4sZVUmN/tZRJ6U0S58DGw/wocU9wGml6xhbdFgo= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047198;MF=libang.li@antgroup.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---.XTf7qIH_1715010729; Received: from localhost(mailfrom:libang.li@antgroup.com fp:SMTPD_---.XTf7qIH_1715010729) by smtp.aliyun-inc.com; Mon, 06 May 2024 23:52:10 +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 v2 5/5] mm: Add update_mmu_tlb_range() Date: Mon, 06 May 2024 23:51:20 +0800 Message-Id: <20240506155120.83105-6-libang.li@antgroup.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20240506155120.83105-1-libang.li@antgroup.com> References: <20240506155120.83105-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 | 8 ++++++++ mm/memory.c | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 18019f037bae..869bfe6054f1 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -737,6 +737,14 @@ static inline void update_mmu_tlb(struct vm_area_struct *vma, #define __HAVE_ARCH_UPDATE_MMU_TLB #endif +#ifndef __HAVE_ARCH_UPDATE_MMU_TLB_RANGE +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_RANGE +#endif + /* * Some architectures may be able to avoid expensive synchronization * primitives when modifications are made to PTE's which are already diff --git a/mm/memory.c b/mm/memory.c index eea6e4984eae..2d53e29cf76e 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4421,7 +4421,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) @@ -4491,8 +4490,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