Message ID | 20230218002819.1486479-22-jthoughton@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp142784wrn; Fri, 17 Feb 2023 16:31:25 -0800 (PST) X-Google-Smtp-Source: AK7set8xxx5sFiaownuEm9dv1b4mX81kxxIXQP3DqepTPIoJDl1p6q01vO2+VRS6ZJER/hL/2+jd X-Received: by 2002:a17:906:9407:b0:8ac:8f3c:7f65 with SMTP id q7-20020a170906940700b008ac8f3c7f65mr231614ejx.48.1676680285595; Fri, 17 Feb 2023 16:31:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676680285; cv=none; d=google.com; s=arc-20160816; b=hVwJIllLSU7i3bGQUPmF49xMJ/1cpKpQNqwPgmL4w1RZTVBQyx6/ZFZrRtAJCE21ck FMb3CfycG+mzB47QCrOZ6LjoBU7Dh8qpvkWXEP4FNPgtMkToDH41GtHz/qURCVRC4cvP r8xdRe/opT+DjSSfCPRBLJvUHba9gGWEMcL/EwN+Ik+WpIlMZ1frEk59RgS03ajm6pf5 8HwfYHb6/RSK2hXqefLkbOTf0PEBgn/L839X91CT6Wb2jxY4cbxXyoCZ736EdO33a8g8 tw+NhBepf3DqB5zW5qRwL0Du+GX2wXJItScAopLpPF13PV2keBqi857on2o4F0S2l1L1 bY4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=xFEWCFEVqNzp10q8weB+17bzU0TWKtM8UIz/Xx7DMio=; b=um3gOxAyuiZapruwJo601UHzuQQDXVKAZyTQzV4Ltt2bxL7K6dOFS6IqJWsNInKm5w sybMTX9g0vsMhDSVK5X66gNYpzrU1e+WUxzdSGVbGfTPW/bk+LqloDj8bQGJUu7DY3mN ImrYdepggVbYfhsvNfm4ZsgQWqS2k1FBRRcMcJn7Rm1XFX9RabC8LAmGZl3O5Ef5CwNl TabYLYTOPYIX2hzZHT3T70d7Q6HMVU24ebxw3kLHNn56Vzr/2iCOwkyG7d4ccNoRTDrI tkkl8srqK9KdLmzs2Pm/586OwkCcyDbrjlORz0aa+oykpykoZR7h2IQIaXSqGKiOIBH6 xgsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jsCsMDMV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bp14-20020a170907918e00b008b9f63af534si1288603ejb.97.2023.02.17.16.31.02; Fri, 17 Feb 2023 16:31:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jsCsMDMV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230192AbjBRAaT (ORCPT <rfc822;daweilics@gmail.com> + 99 others); Fri, 17 Feb 2023 19:30:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230009AbjBRA3l (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 17 Feb 2023 19:29:41 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E148360F8D for <linux-kernel@vger.kernel.org>; Fri, 17 Feb 2023 16:29:06 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-536566339d6so26929197b3.11 for <linux-kernel@vger.kernel.org>; Fri, 17 Feb 2023 16:29:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xFEWCFEVqNzp10q8weB+17bzU0TWKtM8UIz/Xx7DMio=; b=jsCsMDMV78mjE8aA5hDj4ELvx3b3FYDfUCGtdB3AxH26EGW3FR4Wa7s8y12aCgjJAY xZHdXI0S9zLwyoyC2XXFQ/t878xZ76UJxTZdgaT1614gKQ8S86PPdMjKwYlq97dle3xZ X18JJ5MDR3KedDVpG1uX/f8VVj8pEdf241wOEt1/1ioMygZNzU7w6K5FfESBrPr6rcwL oyCOP/Tffhfxzt33/TtBRunbLaQrs+s+Ng2bav+9PXMaH8T+pd/4F//IKbtKNQ3pXtLn zm3LA/sIhVTcMgTue+SyM1JfkLU6x3PjoLgkHIa6SXkJODW1AhFZZ0jaKNWlzrRQQiMx uOCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xFEWCFEVqNzp10q8weB+17bzU0TWKtM8UIz/Xx7DMio=; b=HCe+oOi7FFFkPp3lIVuSIXEHLbjpBvrIAvnt9jZYus2jkriYkwRllplyGHUpSXFxiL GWUGb8D/3+tkjpktm2XkCHc1YEkKvYPMX/IO0xm7dftlu5zGjRwAxNB84uahGxvQZaqP KdMaDxYidZkpCPiw5EMJ2VJL/5wnJj29Bq2UAMgG7fJVCn40Dur5nntmSlw61aFwWIbY LQT8DGJAPYVdlWnzUDxmUc9qtfeewf8Ae3veTQKbat5dpGQutgqDBXHTSna2lmwX8cIE vQmnrDWl2k3KTkEt8x1GKdBxu+SXlvK/0tjaoNxRskeW7wmL64IzsX13omodT4mAKbzk fxCg== X-Gm-Message-State: AO0yUKWSFdTOlwxBJ9HUj+z/bXjJsr4DwRatM/wYlIOhaVBRDWe0QnWn /o8mgUNwSh0svXpEMpmHCTu7b5Cy29dkuxtN X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a5b:10e:0:b0:94a:ebba:cba6 with SMTP id 14-20020a5b010e000000b0094aebbacba6mr249759ybx.9.1676680144192; Fri, 17 Feb 2023 16:29:04 -0800 (PST) Date: Sat, 18 Feb 2023 00:27:54 +0000 In-Reply-To: <20230218002819.1486479-1-jthoughton@google.com> Mime-Version: 1.0 References: <20230218002819.1486479-1-jthoughton@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230218002819.1486479-22-jthoughton@google.com> Subject: [PATCH v2 21/46] hugetlb: add HGM support to hugetlb_follow_page_mask From: James Houghton <jthoughton@google.com> To: Mike Kravetz <mike.kravetz@oracle.com>, Muchun Song <songmuchun@bytedance.com>, Peter Xu <peterx@redhat.com>, Andrew Morton <akpm@linux-foundation.org> Cc: David Hildenbrand <david@redhat.com>, David Rientjes <rientjes@google.com>, Axel Rasmussen <axelrasmussen@google.com>, Mina Almasry <almasrymina@google.com>, "Zach O'Keefe" <zokeefe@google.com>, Manish Mishra <manish.mishra@nutanix.com>, Naoya Horiguchi <naoya.horiguchi@nec.com>, "Dr . David Alan Gilbert" <dgilbert@redhat.com>, "Matthew Wilcox (Oracle)" <willy@infradead.org>, Vlastimil Babka <vbabka@suse.cz>, Baolin Wang <baolin.wang@linux.alibaba.com>, Miaohe Lin <linmiaohe@huawei.com>, Yang Shi <shy828301@gmail.com>, Frank van der Linden <fvdl@google.com>, Jiaqi Yan <jiaqiyan@google.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton <jthoughton@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758126707091028041?= X-GMAIL-MSGID: =?utf-8?q?1758126707091028041?= |
Series |
hugetlb: introduce HugeTLB high-granularity mapping
|
|
Commit Message
James Houghton
Feb. 18, 2023, 12:27 a.m. UTC
The change here is very simple: do a high-granularity walk.
Signed-off-by: James Houghton <jthoughton@google.com>
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index c26b040f4fb5..693332b7e186 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6655,11 +6655,10 @@ struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, unsigned long address, unsigned int flags) { struct hstate *h = hstate_vma(vma); - struct mm_struct *mm = vma->vm_mm; - unsigned long haddr = address & huge_page_mask(h); struct page *page = NULL; spinlock_t *ptl; - pte_t *pte, entry; + pte_t entry; + struct hugetlb_pte hpte; /* * FOLL_PIN is not supported for follow_page(). Ordinary GUP goes via @@ -6669,13 +6668,24 @@ struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, return NULL; hugetlb_vma_lock_read(vma); - pte = hugetlb_walk(vma, haddr, huge_page_size(h)); - if (!pte) + + if (hugetlb_full_walk(&hpte, vma, address)) goto out_unlock; - ptl = huge_pte_lock(h, mm, pte); - entry = huge_ptep_get(pte); +retry: + ptl = hugetlb_pte_lock(&hpte); + entry = huge_ptep_get(hpte.ptep); if (pte_present(entry)) { + if (unlikely(!hugetlb_pte_present_leaf(&hpte, entry))) { + /* + * We raced with someone splitting from under us. + * Keep walking to get to the real leaf. + */ + spin_unlock(ptl); + hugetlb_full_walk_continue(&hpte, vma, address); + goto retry; + } + page = pte_page(entry) + ((address & ~huge_page_mask(h)) >> PAGE_SHIFT); /*