From nobody Wed Apr 8 03:07:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C21D3C433FE for ; Fri, 21 Oct 2022 16:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231205AbiJUQi0 (ORCPT ); Fri, 21 Oct 2022 12:38:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230361AbiJUQhw (ORCPT ); Fri, 21 Oct 2022 12:37:52 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D525427B579 for ; Fri, 21 Oct 2022 09:37:29 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id t17-20020a257811000000b006c509f9a16dso3792779ybc.10 for ; Fri, 21 Oct 2022 09:37:29 -0700 (PDT) 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=8/NM5zqKrp3T0mJhjHHyOLUnz62gupmqJK/DDFGexZI=; b=kNo3BI9LgJDNbw4zG7f+BcfBeEsxT7zZGWcOge04kuwB3WGs4ua5FnV/ikxacl43mD M6k0xqIMh4xV/kNssOly5E5ouNZTJbE1jiHX8f4BQKdFzjOe8CtoSIjUdke5SPji+pEq kOZ846TjVCKjKeX4b6HxrkfJ6BQ6CGISZePlXZkN2Rm1jtqyKh+RfXYCoD2KqxlK58+X giN/v/U9prCXXWwTgQ+82EXYGKAT/w9/2BGshYZOi4LwaY3LCQutO9qEE+7l1KWb9pbv DCVuuxqs8fuEhlJkR2ekbMYvfUQkoMuOLpKGVnSHPaC+P69I+ARfmCsKOI9PHLE6d5yH SWSQ== 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=8/NM5zqKrp3T0mJhjHHyOLUnz62gupmqJK/DDFGexZI=; b=PE7K8aCeBtl9dPQk2G2iangSq8o390LGl2zyxcz7mCCAMCjsC78mP1kdSk1+MglYdi iRzVxb+pJ5HMkkHJeHwEQL8hbgffR2eo+Hu4e7qp+yTOTHD9f2Rw1fWwuBPzlpgbGrLj Yv6tv3/PB6W4A2LrO89Yhbdx8d4r/yPhqpT5bEB+zRIxQiNKZBDvukphOC2110mPvFex VH9UOVwrwz98a5LYzZZdkDwWA0dCnAHbAYQnu72lmqYCvFcHVMhDF1W1wavNBJ3clUVG zsZea1jbdohwLrEvd3Acm4lPxpu8gbQySy9T8m2X8mdFiOngk9/DnBqrxCHmq341pPY9 lPRg== X-Gm-Message-State: ACrzQf0eRFmTgnQiIODRCrlRFrmtlHgDfLcPQ0SA5Uew7qTxqWxTEDLl TT3xagEHB3Xg296AUjcZ4QtPCufheQCXdxwz X-Google-Smtp-Source: AMsMyM6lUFLmKl2u24xYHvEYAF3HSHyv+Q9NHWaQ4uC8W+BKyVcH1krHI+4kAFLxi7gYBA7W761SZPhq47YrIqjR X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a81:4b96:0:b0:354:8935:d5a9 with SMTP id y144-20020a814b96000000b003548935d5a9mr18239585ywa.36.1666370248722; Fri, 21 Oct 2022 09:37:28 -0700 (PDT) Date: Fri, 21 Oct 2022 16:36:29 +0000 In-Reply-To: <20221021163703.3218176-1-jthoughton@google.com> Mime-Version: 1.0 References: <20221021163703.3218176-1-jthoughton@google.com> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog Message-ID: <20221021163703.3218176-14-jthoughton@google.com> Subject: [RFC PATCH v2 13/47] hugetlb: add make_huge_pte_with_shift From: James Houghton To: Mike Kravetz , Muchun Song , Peter Xu Cc: David Hildenbrand , David Rientjes , Axel Rasmussen , Mina Almasry , "Zach O'Keefe" , Manish Mishra , Naoya Horiguchi , "Dr . David Alan Gilbert" , "Matthew Wilcox (Oracle)" , Vlastimil Babka , Baolin Wang , Miaohe Lin , Yang Shi , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This allows us to make huge PTEs at shifts other than the hstate shift, which will be necessary for high-granularity mappings. Signed-off-by: James Houghton Acked-by: Mike Kravetz --- mm/hugetlb.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 90db59632559..74a4afda1a7e 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4867,11 +4867,11 @@ const struct vm_operations_struct hugetlb_vm_ops = =3D { .pagesize =3D hugetlb_vm_op_pagesize, }; =20 -static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page, - int writable) +static pte_t make_huge_pte_with_shift(struct vm_area_struct *vma, + struct page *page, int writable, + int shift) { pte_t entry; - unsigned int shift =3D huge_page_shift(hstate_vma(vma)); =20 if (writable) { entry =3D huge_pte_mkwrite(huge_pte_mkdirty(mk_pte(page, @@ -4885,6 +4885,14 @@ static pte_t make_huge_pte(struct vm_area_struct *vm= a, struct page *page, return entry; } =20 +static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page, + int writable) +{ + unsigned int shift =3D huge_page_shift(hstate_vma(vma)); + + return make_huge_pte_with_shift(vma, page, writable, shift); +} + static void set_huge_ptep_writable(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) { --=20 2.38.0.135.g90850a2211-goog