Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp272578lqh; Mon, 6 May 2024 20:26:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUWoe7GxVexrbrMXR3xg6HsKsUWI2j/AfJK15mSG1GlEUUXTp4cap1q+tYdRkVxEWv6MidkzDAoq6RPtVbnBYjkL8au4soJRiKLchDMYw== X-Google-Smtp-Source: AGHT+IHGHuRjSq13IGfF3y0KzO0GHqdHjCQWW0IQambm3fykD8Ywtl/CE+oPCtfCIn7HjM4zXOBc X-Received: by 2002:a05:6808:2388:b0:3c8:575f:4135 with SMTP id bp8-20020a056808238800b003c8575f4135mr15753268oib.7.1715052402366; Mon, 06 May 2024 20:26:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715052402; cv=pass; d=google.com; s=arc-20160816; b=VDwi2pLgAI/7657Ofg5Gc4YvZRxtmEFbkoDr5TG30xzJsy0Kiu9juSMm/z8gbIwW/n XTpGvWQVeONvlANECtmJ9pFm+PJvauz8ShuH72pt7NBgPeE3t5kj0CYZw3SL70RY7Xyy 8UWFwsrigLENCT4PBfXrCNClIksYcJ5R2UBsWaV97Z8jUlQVcvXuxRzEE7PqtfZqBnYm IG+4JJqx4leQzvkv1SGk8iixjxbTqgYwBK9JzZOPtO6tQiN7T+yfho0qS7gg5xAdlOa/ WELv1AyQc3wami1/m7ERUSqG97Qd1GSAkfAOWvqCTzdguOE3G3RkFrCUKU/IY09WYNGt tTJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=5G08kj7fI6VhU0nVl7AlR+J897u+++S/y5nHUajrQj8=; fh=CfNAuThlg6Y781KHviCrn/KsuU3GCj64VJ+u7/aeiIc=; b=pNkWrxhI/zCmHye0P5O2ntIa5BKGh4RU0J09SDYXnVOKo1Hu+jWbzzivK+THZl8y6g ZPpqfv8CoaTzkHY6F593ft/rXHOZYsa0nDAWhC6eUAX/ffq504pUuY0xcgfD87xpoCdT T4Cu6nw1U+NGl707jza9S+Ap+g1dlJdbUZsC03IhfX4k44mSiLxkLEyPZJzJIL2lyTCJ 56jjfeZdNfWWwk6dMRGJR7Mfzn5Ntr3xt3zXkCgjxZ2KcWP+MwQjG4ZUeUNuV8twUJx7 xrvcPgL0MY8llkzE5I3DGywJ+6UczMQVX2jeIkD9cRiay3V0wykprgjp9rGk6Q6JiScC 3PLQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@antgroup.com header.s=default header.b=ZyzpYOlQ; 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-170611-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170611-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p30-20020a63951e000000b005f751c16a59si8180311pgd.657.2024.05.06.20.26.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 20:26:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170611-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@antgroup.com header.s=default header.b=ZyzpYOlQ; 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-170611-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170611-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B253EB237DD for ; Tue, 7 May 2024 03:26:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19D0B3FBA2; Tue, 7 May 2024 03:26:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="ZyzpYOlQ" Received: from out0-205.mail.aliyun.com (out0-205.mail.aliyun.com [140.205.0.205]) (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 694A98F59 for ; Tue, 7 May 2024 03:26:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.205.0.205 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715052391; cv=none; b=WBYUxDzPHUmJ/+2H6/AAl5dRe/FqHQ6Z/QQX5dqrixv7rv8e96DAR2gjm0ubRwEHQUJ5cbUjWTlJSv2BvLKWe55n90KDGbo7pGE5/DErebe4/XGxtLAKdjHnrFvR66vc2E8Vb0G6vWnnMFceD3VZ7Qvf72lANJIKrRJRcRQV9zY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715052391; c=relaxed/simple; bh=iHuRD/dtOgMuKMHeBX+HNdWTT10H1EJDGlz7gP05Kv4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MEBNV6rW9qzsYeqqg1baSiaM5WmjKa14FLkwDCFc/+m3R4cIv0P2tTyRgulMmKJKSnJ8DUXH2nVxrN8H8cTgNuWIIujHDjZJaf3fZ9cCf+efZ3XMVLV0Sc9KVFjljLo/O8vAo+FDu26W9b7Klge4IQd6RcW77aRbPwqwCrfvXNc= 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=ZyzpYOlQ; arc=none smtp.client-ip=140.205.0.205 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=1715052384; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=5G08kj7fI6VhU0nVl7AlR+J897u+++S/y5nHUajrQj8=; b=ZyzpYOlQBVti3aUO6gWt5/JahWz5Q7gUt59jjVE9DOu+GV1bBet0zeEL3P+ZDp8FZsEjEkTcXFSQRiFL6V/4Eat2IyKSKJkJ9G9V1+C81fCMARBc13m6qplYvJODwCO3QeTI5zlJ7un9p24bml4IbNxihtFOCeTj+o98OmD3zEs= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047187;MF=libang.li@antgroup.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---.XU6c0Rr_1715052381; Received: from 30.230.85.161(mailfrom:libang.li@antgroup.com fp:SMTPD_---.XU6c0Rr_1715052381) by smtp.aliyun-inc.com; Tue, 07 May 2024 11:26:22 +0800 Message-ID: <9d251090-ed68-49a2-9e94-7347b71367b3@antgroup.com> Date: Tue, 07 May 2024 11:26:17 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 5/5] mm: Add update_mmu_tlb_range() To: Lance Yang Cc: akpm@linux-foundation.org, chenhuacai@kernel.org, tsbogend@alpha.franken.de, paul.walmsley@sifive.com, palmer@dabbelt.com, chris@zankel.net, jcmvbkbc@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, david@redhat.com, ryan.roberts@arm.com, libang.linux@gmail.com References: <20240506155120.83105-1-libang.li@antgroup.com> <20240506155120.83105-6-libang.li@antgroup.com> Content-Language: en-US From: "Bang Li" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hey Lance, Thanks for taking time to review! On 2024/5/7 0:07, Lance Yang wrote: > On Mon, May 6, 2024 at 11:52 PM Bang Li wrote: >> >> 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 > > IIRC, the contemporary practice is to define a macro with the same name > as the function if it is being overridden. The macro __HAVE_ARCH_UPDATE_MMU_TLB_RANGE defined here is aligned with the macro __HAVE_ARCH_UPDATE_MMU_TLB corresponding to the update_mmu_tlb function. IMO, it should be better to use my method in this case. Thanks, Bang > > Thanks, > Lance > >> +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 >>