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 X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34E0AC433E0 for ; Fri, 15 Jan 2021 17:10:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CB11D2333E for ; Fri, 15 Jan 2021 17:10:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB11D2333E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 004848D01AF; Fri, 15 Jan 2021 12:09:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EF4478D01AE; Fri, 15 Jan 2021 12:09:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBBA48D01AF; Fri, 15 Jan 2021 12:09:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0144.hostedemail.com [216.40.44.144]) by kanga.kvack.org (Postfix) with ESMTP id C4BE68D01AE for ; Fri, 15 Jan 2021 12:09:54 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8277E82EB55C for ; Fri, 15 Jan 2021 17:09:54 +0000 (UTC) X-FDA: 77708646708.20.flag11_281261127531 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 53C411810DA28 for ; Fri, 15 Jan 2021 17:09:54 +0000 (UTC) X-HE-Tag: flag11_281261127531 X-Filterd-Recvd-Size: 10767 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 Jan 2021 17:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610730593; h=from:from: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; bh=Fzb3OrCvuj9u1ejMitFEdOZGsE/rKLZCXUuasJ8wkyY=; b=LDo4gDfdkQ9kj6ViqN00f5eJMnRLHwyweJYRf2kKuQWJ44+WAeHd9ZC6qK4aAa7zibRWOu 26YP7er2LEd6HRWIuURgxq8mOGHXoUwSnjB+1E+mreOwEOK/JhIgUijvTiPkNVohQ3XX1b /b3oVsztRSvaEdtb6vFokzQz+xrmp0I= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-325-i3rKz7PEPdC3_Px0668S6A-1; Fri, 15 Jan 2021 12:09:52 -0500 X-MC-Unique: i3rKz7PEPdC3_Px0668S6A-1 Received: by mail-qk1-f199.google.com with SMTP id f27so8615126qkh.0 for ; Fri, 15 Jan 2021 09:09:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fzb3OrCvuj9u1ejMitFEdOZGsE/rKLZCXUuasJ8wkyY=; b=HDtVVsN9xTYFxQG1zZxwBH7l6eZyH6m8ioh+nBbtzMxecqFkMvD/kZ+TjQgUEtn91j ZwV3NuRpvrhakGT+2GKfB19UXSXjP4bPqMsNMQJHGUHtiyNjfAM+3mrPr1d1wIRaf/lw giH3kAicCv5620pEcb2lZfPFJS4wEGHFediMblDMl0Fu5jVy69KNTnGNSLZaMtLQfsPd XiCKHRiakjbxlZ0Ga3x9jUcOllkNcuOXni+EyggMYhzLiSUZsBvs+871LtXzIg2frx/p XNy1H54dskRoNyaSTjsZFXK59cMlRWfe8mIYCgXHNfRJsGcazDvlG6L1h2JSUbxbpSsx D4Iw== X-Gm-Message-State: AOAM530zLrBz2dncFSIrNILMCE2zl+lo+LlzE6DzSBe/VJOlR+Rp3d3C S4zb/Vbzcn9IMK7xngJgfbBw8ZCJpp3q3IWxd4QE7RZ7GcgcVwSwz19I4RXjtT5VRRTweSIJ8RO RtiAhkpt7ycI= X-Received: by 2002:ac8:8ca:: with SMTP id y10mr1953478qth.330.1610730591481; Fri, 15 Jan 2021 09:09:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJynPbJZARbFKUAqCyYrAIhsUHZ/PdW2ilr6NGS4nhJHsYltq257UUAHhzGtHV6iYBRr031H3A== X-Received: by 2002:ac8:8ca:: with SMTP id y10mr1953445qth.330.1610730591246; Fri, 15 Jan 2021 09:09:51 -0800 (PST) Received: from localhost.localdomain ([142.126.83.202]) by smtp.gmail.com with ESMTPSA id d123sm5187840qke.95.2021.01.15.09.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 09:09:50 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Mike Rapoport , Mike Kravetz , peterx@redhat.com, Jerome Glisse , "Kirill A . Shutemov" , Hugh Dickins , Axel Rasmussen , Matthew Wilcox , Andrew Morton , Andrea Arcangeli , Nadav Amit Subject: [PATCH RFC 21/30] hugetlb: Pass vma into huge_pte_alloc() Date: Fri, 15 Jan 2021 12:08:58 -0500 Message-Id: <20210115170907.24498-22-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115170907.24498-1-peterx@redhat.com> References: <20210115170907.24498-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable 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: It is a preparation work to be able to behave differently in the per architecture huge_pte_alloc() according to different VMA attributes. Signed-off-by: Peter Xu --- arch/arm64/mm/hugetlbpage.c | 2 +- arch/ia64/mm/hugetlbpage.c | 3 ++- arch/mips/mm/hugetlbpage.c | 4 ++-- arch/parisc/mm/hugetlbpage.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 3 ++- arch/s390/mm/hugetlbpage.c | 2 +- arch/sh/mm/hugetlbpage.c | 2 +- arch/sparc/mm/hugetlbpage.c | 2 +- include/linux/hugetlb.h | 2 +- mm/hugetlb.c | 6 +++--- mm/userfaultfd.c | 2 +- 11 files changed, 16 insertions(+), 14 deletions(-) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 55ecf6de9ff7..5b32ec888698 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -252,7 +252,7 @@ void set_huge_swap_pte_at(struct mm_struct *mm, unsig= ned long addr, set_pte(ptep, pte); } =20 -pte_t *huge_pte_alloc(struct mm_struct *mm, +pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long sz) { pgd_t *pgdp; diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c index b331f94d20ac..f993cb36c062 100644 --- a/arch/ia64/mm/hugetlbpage.c +++ b/arch/ia64/mm/hugetlbpage.c @@ -25,7 +25,8 @@ unsigned int hpage_shift =3D HPAGE_SHIFT_DEFAULT; EXPORT_SYMBOL(hpage_shift); =20 pte_t * -huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long s= z) +huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, + unsigned long addr, unsigned long sz) { unsigned long taddr =3D htlbpage_to_page(addr); pgd_t *pgd; diff --git a/arch/mips/mm/hugetlbpage.c b/arch/mips/mm/hugetlbpage.c index 77ffece9c270..c1d8f51c5255 100644 --- a/arch/mips/mm/hugetlbpage.c +++ b/arch/mips/mm/hugetlbpage.c @@ -21,8 +21,8 @@ #include #include =20 -pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, - unsigned long sz) +pte_t *huge_pte_alloc(struct mm_struct *mm, structt vm_area_struct *vma, + unsigned long addr, unsigned long sz) { pgd_t *pgd; p4d_t *p4d; diff --git a/arch/parisc/mm/hugetlbpage.c b/arch/parisc/mm/hugetlbpage.c index d7ba014a7fbb..e141441bfa64 100644 --- a/arch/parisc/mm/hugetlbpage.c +++ b/arch/parisc/mm/hugetlbpage.c @@ -44,7 +44,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned l= ong addr, } =20 =20 -pte_t *huge_pte_alloc(struct mm_struct *mm, +pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long sz) { pgd_t *pgd; diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.= c index 36c3800769fb..2514884c0d20 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -106,7 +106,8 @@ static int __hugepte_alloc(struct mm_struct *mm, huge= pd_t *hpdp, * At this point we do the placement change only for BOOK3S 64. This wou= ld * possibly work on other subarchs. */ -pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned= long sz) +pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, + unsigned long addr, unsigned long sz) { pgd_t *pg; p4d_t *p4; diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c index 3b5a4d25ca9b..da36d13ffc16 100644 --- a/arch/s390/mm/hugetlbpage.c +++ b/arch/s390/mm/hugetlbpage.c @@ -189,7 +189,7 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, return pte; } =20 -pte_t *huge_pte_alloc(struct mm_struct *mm, +pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long sz) { pgd_t *pgdp; diff --git a/arch/sh/mm/hugetlbpage.c b/arch/sh/mm/hugetlbpage.c index 220d7bc43d2b..999ab5916e69 100644 --- a/arch/sh/mm/hugetlbpage.c +++ b/arch/sh/mm/hugetlbpage.c @@ -21,7 +21,7 @@ #include #include =20 -pte_t *huge_pte_alloc(struct mm_struct *mm, +pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long sz) { pgd_t *pgd; diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c index ec423b5f17dd..ae06f7df9750 100644 --- a/arch/sparc/mm/hugetlbpage.c +++ b/arch/sparc/mm/hugetlbpage.c @@ -272,7 +272,7 @@ static unsigned long huge_tte_to_size(pte_t pte) return size; } =20 -pte_t *huge_pte_alloc(struct mm_struct *mm, +pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long sz) { pgd_t *pgd; diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index fe1dde0afbaf..7d4c5669e118 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -162,7 +162,7 @@ extern struct list_head huge_boot_pages; =20 /* arch callbacks */ =20 -pte_t *huge_pte_alloc(struct mm_struct *mm, +pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long sz); pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, unsigned long sz); diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 18b236bac6cd..eb7cd0c7d6d2 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3767,7 +3767,7 @@ int copy_hugetlb_page_range(struct mm_struct *dst, = struct mm_struct *src, src_pte =3D huge_pte_offset(src, addr, sz); if (!src_pte) continue; - dst_pte =3D huge_pte_alloc(dst, addr, sz); + dst_pte =3D huge_pte_alloc(dst, vma, addr, sz); if (!dst_pte) { ret =3D -ENOMEM; break; @@ -4484,7 +4484,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, stru= ct vm_area_struct *vma, */ mapping =3D vma->vm_file->f_mapping; i_mmap_lock_read(mapping); - ptep =3D huge_pte_alloc(mm, haddr, huge_page_size(h)); + ptep =3D huge_pte_alloc(mm, vma, haddr, huge_page_size(h)); if (!ptep) { i_mmap_unlock_read(mapping); return VM_FAULT_OOM; @@ -5407,7 +5407,7 @@ void adjust_range_if_pmd_sharing_possible(struct vm= _area_struct *vma, #endif /* CONFIG_ARCH_WANT_HUGE_PMD_SHARE */ =20 #ifdef CONFIG_ARCH_WANT_GENERAL_HUGETLB -pte_t *huge_pte_alloc(struct mm_struct *mm, +pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long sz) { pgd_t *pgd; diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 480d91b783d4..3d49b888e3e8 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -291,7 +291,7 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb= (struct mm_struct *dst_mm, mutex_lock(&hugetlb_fault_mutex_table[hash]); =20 err =3D -ENOMEM; - dst_pte =3D huge_pte_alloc(dst_mm, dst_addr, vma_hpagesize); + dst_pte =3D huge_pte_alloc(dst_mm, dst_vma, dst_addr, vma_hpagesize); if (!dst_pte) { mutex_unlock(&hugetlb_fault_mutex_table[hash]); i_mmap_unlock_read(mapping); --=20 2.26.2