From mboxrd@z Thu Jan 1 00:00:00 1970 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 5A414C001DE for ; Mon, 31 Jul 2023 08:44:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5D3328001E; Mon, 31 Jul 2023 04:44:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C0D8228001A; Mon, 31 Jul 2023 04:44:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD50428001E; Mon, 31 Jul 2023 04:44:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 99C2A28001A for ; Mon, 31 Jul 2023 04:44:09 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6F0AAB1FA2 for ; Mon, 31 Jul 2023 08:44:09 +0000 (UTC) X-FDA: 81071269818.09.2605842 Received: from mail-vk1-f177.google.com (mail-vk1-f177.google.com [209.85.221.177]) by imf01.hostedemail.com (Postfix) with ESMTP id 8C65D4000F for ; Mon, 31 Jul 2023 08:44:07 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=H1dHmR4j; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.221.177 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690793047; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=r18jhhWoKmGAEeggGFCS+IEIfqajuENPnaVmIm75UL8=; b=2tcgH3i9ukkV+zh9Yi1XOv/RhuitouDUVqsrxn/JYltg5AWnB+d/Z6e4fLP4mBEaS3UNtr tL9DyJF1XTujK7cVP/4Zua2P8DTdnKZcGtQoSM6PU9sGo6tHGHBLxyAP4T5SpsLOKPRsYJ YpFg//Z9p95lHq4BhuZoY560sskVGNw= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=H1dHmR4j; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.221.177 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690793047; a=rsa-sha256; cv=none; b=gEPlVvrlCNLEDvtlShJ6n6Sy2BV+9pGtYITrYOkTCZueN5oYERUBce/1dfIQ77EwNJhlnd NvOPud8iFYd+9DwWl4dhOtbbD446xF1xcFrnybf3QpNPkZ/U8tHNM8tiB7VSms7n/HwbXd SXHmzWoSk2d/3/qXL8oA1a+5OWbfuw4= Received: by mail-vk1-f177.google.com with SMTP id 71dfb90a1353d-486518f0ed4so1505017e0c.3 for ; Mon, 31 Jul 2023 01:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690793046; x=1691397846; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=r18jhhWoKmGAEeggGFCS+IEIfqajuENPnaVmIm75UL8=; b=H1dHmR4jWtu8kb3DPgCWGa1RmtkcCk6HzdcYf7ay04AB6dxdagGOH9Kzgy0NvSwozK yOnTCJ8eTDMG6yd5Jm4TLC9rthA7NCMe5+Nj/t2wNz4mBI+hKrcwNQGglEgLDH6Wcjq0 UwnRu5PR2BC7K156kyjshOItozObwQOHxWJp4iyTrY5wLbn9Lq5QiiYspFqjcQ2FikZy w/shpcFbFmyTch37zlGqMQsqMXyzzB+ekiQjj4+xkWBwDxybjUCOcplMex21MuWvDfqo AA5phC124mJVdN9Sa4+qJd4xTOnKC7jGNrprtkkd8OcQD0HWEgyE0phs9f2nNx2Vkl5i Q8+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793046; x=1691397846; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r18jhhWoKmGAEeggGFCS+IEIfqajuENPnaVmIm75UL8=; b=kt9pmQrbnnoabo58LYb0JzOMXv0NNy/wudJiFK+ukHPyUywvfPkbQZAoGzM86+T6ys JPi1QBiXvgZPGHT4gGK4RxNVpNGaoaiwlqXqciHpTMwwyKoqMUDVH7eJk07xRnKn9Rh9 guqRHE4ny/FjWbf+L1AFHzJOREbqpeEAkSKyeAAq66n/yyx0nEa2zTpAY7kxt11zBunZ o3H9AbS59Gn+PQnaPFFUOVy2MmNb4pFbrWASsHxV3frvnPQ35tttiRUKionw68apcc8j 3ioAT9DMXSHCcLS89T3wekNCSnTPJVpiBIVuXwnUGcxCnVTILmKQAGU24F5H8ALQM1/5 P9cQ== X-Gm-Message-State: ABy/qLadmMzwBuj7XNcizSVCyZLZ43sPd2oCX6aV8z6UVWTnPvt+ATfj Glbq1KPWv0uuSsdT8KAJ6fkBvABvThZPSwO/8n8= X-Google-Smtp-Source: APBJJlG8e+qI8QNAcosXZ3z3fAXYcapIo1K+d6cwFVVnDMsJV+SfFjxe9TyLi82bx2QRpFvRQQgnvdn62vyp/1ZE2AI= X-Received: by 2002:a1f:c14b:0:b0:486:6cd7:95f2 with SMTP id r72-20020a1fc14b000000b004866cd795f2mr4599786vkf.8.1690793046602; Mon, 31 Jul 2023 01:44:06 -0700 (PDT) MIME-Version: 1.0 References: <20230731074829.79309-1-wangkefeng.wang@huawei.com> <20230731074829.79309-5-wangkefeng.wang@huawei.com> In-Reply-To: From: Barry Song <21cnbao@gmail.com> Date: Mon, 31 Jul 2023 16:43:55 +0800 Message-ID: Subject: Re: [PATCH 4/4] arm64: tlb: set huge page size to stride for hugepage To: Kefeng Wang Cc: Andrew Morton , Catalin Marinas , Will Deacon , Mike Kravetz , Muchun Song , Mina Almasry , kirill@shutemov.name, joel@joelfernandes.org, william.kucharski@oracle.com, kaleshsingh@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 8C65D4000F X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: jojykfhhju1jdhwzcrtk76ayarsou8cf X-HE-Tag: 1690793047-240490 X-HE-Meta: U2FsdGVkX1/9M+5kw/TM0JFhwJgLX+IhFDhfz4DKLVvWIiGuLV4lTPALroQ284caeIkZvKXL9rrfziLdD4UZ/dPx/M97zvHPTHyl7jcqp37mJWJ/RkMNFsN5t2bqEqhxUI7VvoC0EITLhjgJBPc+p5acHumWSjGwr+yfCh//nK9qrGvec7RrhBVZ2ARn0qvR1ke5zYkq5xH5h3YVyM9nRIA0uo+FIjMacl23lGVgmoz7/405XJLMivicIT8Pvju5FaFicuCbGhbZBd9l/IrHZ/VHL1kaPHPq566XBamVKmA38n2X/qC7WBsR2VG5/pJt3Ag+RNlwEg++kkp62z+tOD+GpSFQq2FPB098000ovAc78AK3ddzNjTi4566tvsXwY92MY1BB0ouDDyS8LTgIgVoL1+EBbxYn8x+jhFZQ4QtzUh6IM0mk/Bz2Ngpd7vaD1Dz1MFhIT0zbs565HQWM7I/W069328totQRV+w3+VRvdaMlrIZgSUKfPqxuTLLKSby30/0a0RNbhpJEPCh+fBR4ax0bl0pdYJwQMUUYopqSBv4q2NRHpx2Y98xu4oVu4axMcQ9cqG3s6zMy4meXFym6cTEIYQqiHj/4WEk/5kStunxosdC1xW3WVqVXH/gtPwFXzJa/QCmBB8xRRAKHdRSdJOIzKZdJemDSOzhb163dZkgOsUjjO/1xGXD9421KQkfrreY15q9cSJJnMUxVEkH+tFPaxah+9tY7E75czl9gI9bADZJJwEpphTLyqKF74LbEk7PtFWdUBsq/gFEehScpwiookUk9SXB6/H4clOvLxHZEURkAyZlWQoShV0e/4agrfVqSGig5qD+S1ZjhjGjmR+YhbPqqSbEm5wZq4TKtg9guYtZyrO3bBN+bCg1ZMTm4siTBxpIEArQs/S7S509Yl+P+USsjcSN/JfYEcJk3dbywgVCpyq0gJssjDffbsffrkq8A0WVNGcFWjUjO VyO0yLEr Jj54N2F0lK89UDif4S2DDl6oYk0CUIxr9Ru+Es67iWEc3ij8PRRSlMyTl7xUqe8FCR0Gi/GN9Zk3gA7DmbRNwgny1im2/0L21eWdt4xniRQzYt6b3+1q/seHEa8zDzqwLSKpq/lSm3zXl9Yr2QwB8BYCQadZaniHE5lhA4xqMPopWcCl2+89oRBjPpB7Lf6fJF2xh99074w9QKp5W3YrJ708Xi6YKTTZhuiLmRCmMX81bySW+/hkrlIeY1YcC76fcP9RE3BLlXQW7rw9K/3WzkxS0seHkoLbk508L/zHCRAgwcpqkkDqH96Pyq7WYOErrm2IFd0aZDn72CvdkZr4oQgLb7qGVYgkaC6UHrTS2NmDoY/43n8hPm0/7+8JSmty1WIREnUPwgZWn5pBXKZAM1BMZEw== 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: On Mon, Jul 31, 2023 at 4:33=E2=80=AFPM Barry Song <21cnbao@gmail.com> wrot= e: > > On Mon, Jul 31, 2023 at 4:14=E2=80=AFPM Kefeng Wang wrote: > > > > It is better to use huge_page_size() for hugepage(HugeTLB) instead of > > PAGE_SIZE for stride, which has been done in flush_pmd/pud_tlb_range(), > > it could reduce the loop in __flush_tlb_range(). > > > > Signed-off-by: Kefeng Wang > > --- > > arch/arm64/include/asm/tlbflush.h | 21 +++++++++++---------- > > 1 file changed, 11 insertions(+), 10 deletions(-) > > > > diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm= /tlbflush.h > > index 412a3b9a3c25..25e35e6f8093 100644 > > --- a/arch/arm64/include/asm/tlbflush.h > > +++ b/arch/arm64/include/asm/tlbflush.h > > @@ -360,16 +360,17 @@ static inline void __flush_tlb_range(struct vm_ar= ea_struct *vma, > > dsb(ish); > > } > > > > -static inline void flush_tlb_range(struct vm_area_struct *vma, > > - unsigned long start, unsigned long e= nd) > > -{ > > - /* > > - * We cannot use leaf-only invalidation here, since we may be i= nvalidating > > - * table entries as part of collapsing hugepages or moving page= tables. > > - * Set the tlb_level to 0 because we can not get enough informa= tion here. > > - */ > > - __flush_tlb_range(vma, start, end, PAGE_SIZE, false, 0); > > -} > > +/* > > + * We cannot use leaf-only invalidation here, since we may be invalida= ting > > + * table entries as part of collapsing hugepages or moving page tables= . > > + * Set the tlb_level to 0 because we can not get enough information he= re. > > + */ > > +#define flush_tlb_range(vma, start, end) = \ > > + __flush_tlb_range(vma, start, end, = \ > > + ((vma)->vm_flags & VM_HUGETLB) = \ > > + ? huge_page_size(hstate_vma(vma)) = \ > > + : PAGE_SIZE, false, 0) > > + > > seems like a good idea. > > I wonder if a better implementation will be MMU_GATHER_PAGE_SIZE, in thi= s case, > we are going to support stride for other large folios as well, such as th= p. > BTW, in most cases we have already had right stride: arch/arm64/include/asm/tlb.h has already this to get stride: static inline void tlb_flush(struct mmu_gather *tlb) { struct vm_area_struct vma =3D TLB_FLUSH_VMA(tlb->mm, 0); bool last_level =3D !tlb->freed_tables; unsigned long stride =3D tlb_get_unmap_size(tlb); int tlb_level =3D tlb_get_level(tlb); /* * If we're tearing down the address space then we only care about * invalidating the walk-cache, since the ASID allocator won't * reallocate our ASID without invalidating the entire TLB. */ if (tlb->fullmm) { if (!last_level) flush_tlb_mm(tlb->mm); return; } __flush_tlb_range(&vma, tlb->start, tlb->end, stride, last_level, tlb_level); } > > > > static inline void flush_tlb_kernel_range(unsigned long start, unsigne= d long end) > > { > > -- > > 2.41.0 > > > > Thanks > Barry