From patchwork Tue Jun 13 21:53:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13279235 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 8F580EB64DB for ; Tue, 13 Jun 2023 21:54:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F6FC6B007B; Tue, 13 Jun 2023 17:54:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6CE4A6B007E; Tue, 13 Jun 2023 17:54:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 437B18E0002; Tue, 13 Jun 2023 17:54:02 -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 2DE256B007B for ; Tue, 13 Jun 2023 17:54:02 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EF1648063C for ; Tue, 13 Jun 2023 21:54:01 +0000 (UTC) X-FDA: 80899077882.02.9BEDAC1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id DF37C20007 for ; Tue, 13 Jun 2023 21:53:59 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BhbO3fDe; spf=pass (imf03.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686693239; 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=V6YucMw264yJynzunMB03zc5mw1fxLam6CUcenZWneI=; b=mzdqher6JuhEfyh6XDNrsoOLWiqUGAbGx73I7/ItxXbd1lwmmpi+kGOCj4vOHihMCvGDS9 tpRBPVPaOlm4Aa2HvSTehpljli6tDjwdw60pvF37vnv4JZNiSnOntKdDgwxXMgNV40kkg1 BDp+dn8PmlecW0eDN3jVZVUaO4IR9hs= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BhbO3fDe; spf=pass (imf03.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686693239; a=rsa-sha256; cv=none; b=2t965fnaihg+u4j09TigbOtnloSrTLy7EJOMU3UpwttsCN/Nv4CpjPNGNRd8tdVjc3Gzel DBv4BUEic5YwNj1xAp0yHrTxM7CusXOiRyI+LxnavZYQEgAg49cxxakDD/YEvNdZ3lWBbs EummLP4NWIur7R1g+I4tny5S0nhTOq4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686693239; 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=V6YucMw264yJynzunMB03zc5mw1fxLam6CUcenZWneI=; b=BhbO3fDeiukURbDWqGWVglUusSMEQ0TS3ULmRRcc3moX7gSWmNiyzRlU0AKmJHCaW3sPA8 T4gd/jivxAA9FLp1U7gbdJh9r+gQmmAZuFnH/tRJsg4ZkJTdUBbyMjtQLR7QkCkdiMbiq7 y1F9OciWzk1HnIsl8FQlmpt+3LOZ8HY= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-XOEF5OqrP5KROSte1TWouw-1; Tue, 13 Jun 2023 17:53:58 -0400 X-MC-Unique: XOEF5OqrP5KROSte1TWouw-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-3fb2e6ca6eeso2354231cf.1 for ; Tue, 13 Jun 2023 14:53:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686693237; x=1689285237; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V6YucMw264yJynzunMB03zc5mw1fxLam6CUcenZWneI=; b=JvAI8qiOqYmwFZpXBGsiEp0z4Yw2bJZnjCGYyxjyN1+8G4JNbLjtu2KrGgzEPaz2mY 7LohlSGmmIcVLleQ3MEW8JUwTWgPzc83JtJP9zR1r3tHcAc5+3rlyWF6rGPUSSqPlAnF IGguwpXyLnWvH7wkE2LhNpNySPStbKw2rJ1koCGIqlXg85aTlNRz/CHiSthUX4+bMbb5 eUzb153bzXOz1tcX6dcu+TajpPjt8AkvEr5SqlPDVBiR6DK8mA5FqgxTYA8cSrtDtrAc eYBHQdClLN0feEzcaF0L7IEbc2kWZmLwupdtskRy6l65aLmlkGn0HmvoBR2jF/saN0DY Izmg== X-Gm-Message-State: AC+VfDwerghiKjnErrHHNKCOuOgYR+E3nj7F+/EZc3CSvLAWw0H+K388 N088PM02V+H+ufxkM8xCmmv+cqFR4zQcVpZk5SzfjCcDL17D+rwZYQP8eCtjtyNT+WlXSUq3znX JC44bVKSO1lg= X-Received: by 2002:ac8:5c4e:0:b0:3f6:b556:7c97 with SMTP id j14-20020ac85c4e000000b003f6b5567c97mr18596643qtj.4.1686693237071; Tue, 13 Jun 2023 14:53:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ47VYSlqHcJsfV8CfLHB7UhI/dxHot2PSaSbvtLl2psd47hStRHqC+I7+xcOOhhfmPV53DjgA== X-Received: by 2002:ac8:5c4e:0:b0:3f6:b556:7c97 with SMTP id j14-20020ac85c4e000000b003f6b5567c97mr18596618qtj.4.1686693236845; Tue, 13 Jun 2023 14:53:56 -0700 (PDT) Received: from x1n.redhat.com (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id fz24-20020a05622a5a9800b003f9bccc3182sm4522330qtb.32.2023.06.13.14.53.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 14:53:56 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Matthew Wilcox , Andrea Arcangeli , John Hubbard , Mike Rapoport , David Hildenbrand , Vlastimil Babka , peterx@redhat.com, "Kirill A . Shutemov" , Andrew Morton , Mike Kravetz , James Houghton , Hugh Dickins Subject: [PATCH 3/7] mm/hugetlb: Add page_mask for hugetlb_follow_page_mask() Date: Tue, 13 Jun 2023 17:53:42 -0400 Message-Id: <20230613215346.1022773-4-peterx@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230613215346.1022773-1-peterx@redhat.com> References: <20230613215346.1022773-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: DF37C20007 X-Rspam-User: X-Stat-Signature: bjhtwmhxfge3eixi9en8d9ftfisecm5p X-Rspamd-Server: rspam01 X-HE-Tag: 1686693239-480944 X-HE-Meta: U2FsdGVkX18idRiffbnGmVwV2IhdRP2cdmlOTAeGQDfyzHMK9F72p9YJMq0CjKHLDOW3bS09IdP9mrBESWX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5ZV5lRkzLS7HE/WfxFfHMnaGg9igvhPpo5C9p1jlMMnmksdsoSWUoUZy1MdkPu2sfa9qfd+/UZlb0sdGqTVzQTpcK+Nz6WdBwiT/rpNM0iOWaxLS8xXcHgXjxtKGS66VFTvSgtfOF2UKGnkJrqxkp4W2nJOOqLzvwnfT04tEDbeq688Vu9afDb5BbG0+ZgJpLm8XxxvwOGC3N6zWA/+dHRxxbQdc1Qa8eUdxueAslqp31tHAESWmuAI6iblEgL03uRhDYgWiym/ttnZgJSDg== 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: follow_page() doesn't need it, but we'll start to need it when unifying gup for hugetlb. Signed-off-by: Peter Xu Reviewed-by: Mike Kravetz Reviewed-by: David Hildenbrand --- include/linux/hugetlb.h | 8 +++++--- mm/gup.c | 3 ++- mm/hugetlb.c | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 21f942025fec..0d6f389d98de 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -131,7 +131,8 @@ int move_hugetlb_page_tables(struct vm_area_struct *vma, int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *, struct vm_area_struct *); struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, - unsigned long address, unsigned int flags); + unsigned long address, unsigned int flags, + unsigned int *page_mask); long follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, unsigned long *, unsigned long *, long, unsigned int, int *); @@ -297,8 +298,9 @@ static inline void adjust_range_if_pmd_sharing_possible( { } -static inline struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, - unsigned long address, unsigned int flags) +static inline struct page *hugetlb_follow_page_mask( + struct vm_area_struct *vma, unsigned long address, unsigned int flags, + unsigned int *page_mask) { BUILD_BUG(); /* should never be compiled in if !CONFIG_HUGETLB_PAGE*/ } diff --git a/mm/gup.c b/mm/gup.c index aa0668505d61..8d59ae4554e7 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -794,7 +794,8 @@ static struct page *follow_page_mask(struct vm_area_struct *vma, * Ordinary GUP uses follow_hugetlb_page for hugetlb processing. */ if (is_vm_hugetlb_page(vma)) - return hugetlb_follow_page_mask(vma, address, flags); + return hugetlb_follow_page_mask(vma, address, flags, + &ctx->page_mask); pgd = pgd_offset(mm, address); diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 9c261921b2cf..f037eaf9d819 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6457,7 +6457,8 @@ static inline bool __follow_hugetlb_must_fault(struct vm_area_struct *vma, } struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, - unsigned long address, unsigned int flags) + unsigned long address, unsigned int flags, + unsigned int *page_mask) { struct hstate *h = hstate_vma(vma); struct mm_struct *mm = vma->vm_mm; @@ -6506,6 +6507,7 @@ struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, * because we hold the ptl lock and have verified pte_present(). */ WARN_ON_ONCE(try_grab_page(page, flags)); + *page_mask = huge_page_mask(h); } out: spin_unlock(ptl);