From patchwork Thu Jan 5 10:18:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 39439 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp227630wrt; Thu, 5 Jan 2023 02:22:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXt7QXRR1gnjlg+vplF+u/m2Xoyo+5/EV798+tQn5F5oVmIBVKe34T5fVuolu7KwtTLROP3z X-Received: by 2002:a05:6a20:3c8f:b0:ad:97cc:e948 with SMTP id b15-20020a056a203c8f00b000ad97cce948mr78577513pzj.45.1672914138510; Thu, 05 Jan 2023 02:22:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672914138; cv=none; d=google.com; s=arc-20160816; b=q8+Eypq4PY0HDqOKU3Fz1wdXn8gt5upn8LUFIlieG4wJMDXf1HOs0QLW1gk8MxFd0e vqcNuYoo+BcVTUkfB9ct8Hkj4m8/egPC/NEmnPKiHojkuRyyPLW82/DWcS7v8lcVuk0O 80mun2Aeo+9R3gKrbecx/Q9n8Fab/wFGmp1F3Uaf2v8qHpg7IhTEV1pQSEqobQw9Hkrd pB08d+PnKInKrae2YF+t6VHu/+Yq7S7h6129jtyFssdjuce0rbrYrKVz73TcW4tLwO2Y uq7agkAImpsmxBK8nV8LSB1Ps4Hq83AEoj7c8C7zGKW1Gf2VD5gOzU16Aj2FZLccoJa2 h0Dg== 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=TZkjgoDFSdPqMdf6PVi66Nkhma8WC4z5Ws9uGEsRfvU=; b=BVdnvO0N6dTIFklpYcuGzyw8+MmdG+6qeckkdbF64gIOS890k8uRk98NUyvt4U+fZV r+X48LQ0g8PYekhJxY+5RD8TNe/23ISl9IM+BZ/i+fMAJ0c75tLJcUlY/0vC85i2Inog d5b2n6jW143+6n9TPDPeJCk62xKLscCEtrdZGmy45zIIRZ+OyFGuQnws/0o+vKRtoiCd OxRChZ/InSBmtZQwiyDQabnTzbknlAY+FhEhbTGZT8283Qm1UtuCKgJ2nQsaGXEJV5qo OHxvM4mSu9JaQfXme/NrJoWImtfaqdJNYwJr+6zBMvJhZ+1zjntuUN7Gc9/gUmBgqj9N h0Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=b1RVVWEc; 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 q29-20020a635c1d000000b0047785402653si37793032pgb.776.2023.01.05.02.22.05; Thu, 05 Jan 2023 02:22:18 -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=b1RVVWEc; 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 S232856AbjAEKUf (ORCPT + 99 others); Thu, 5 Jan 2023 05:20:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232697AbjAEKTl (ORCPT ); Thu, 5 Jan 2023 05:19:41 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41FAB551C6 for ; Thu, 5 Jan 2023 02:19:16 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id i17-20020a25bc11000000b007b59a5b74aaso773082ybh.7 for ; Thu, 05 Jan 2023 02:19:16 -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=TZkjgoDFSdPqMdf6PVi66Nkhma8WC4z5Ws9uGEsRfvU=; b=b1RVVWEcn7xCiOOjSjy13xNZs7I3m2tPgL+vaICF4A006PbkCzbik5RH+bvlc5t1Qx smy7s9lD0NeMHyXR/guX74nirJ4mhSP/b5OsHYtrukajSYuo8SN51XOlUZveqfcIBxTi pCfvLZWOwBGymc/6OMx4GvgiaEZ8gEeK8Ch/w/fxFKNdFChMKGauZEpNnT4CrnGxewHT oGPT+PC4YdlyU5cZzBSC43pYPeJidbn+PHc6Uj+0smcgsOefwqWpVuhCtBoBfzEfEMFV upTK7E8QZhz98epzC3+PkHQg4sEDxGGdEgPVD9h872OYNbYRLMjyEnUxFS/EyfSg2GYD aEIQ== 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=TZkjgoDFSdPqMdf6PVi66Nkhma8WC4z5Ws9uGEsRfvU=; b=qshl5wbcNG5G1zJME2vwAA5XZS+LHFNuzg1NZFuKbP7rHWQCjXqAOtUoPWakgVToYk iAjPVmRxzRZDz4oJ2x/daRb517k5qrsj2wMUD3MANz+QRtOwGj/00h6wDG7TCtx0Z8KK 8Y6TK5TB1ZMB2vgtfyouvQqllM8cb6I8IP+8Vxnt0ntVZCtBbGBdhMt+7PjsQihiEMXt 1tLpZOy/zAaMVkVZAXyL3OJ2101dATlzL6NqFTyGj9f2+lCmkpn2uCAXnkuXx38p48cg H/TIeWXNYv72s5rDyGc8VwuSwf35aF48GnaxdHMfi3W7bMtYgKklG+BQ7tdNObsCSLW2 iAnQ== X-Gm-Message-State: AFqh2kpgy87sLN9NRZSP5NErS6bL4Nfh84FBpI78o8LkEvqSLTyyq0PK NuqEFlw4Mvw3vGxY2WatFM+nLCfkJ5CNc7pD X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a25:f41:0:b0:6f9:bd92:e428 with SMTP id 62-20020a250f41000000b006f9bd92e428mr4815135ybp.28.1672913955309; Thu, 05 Jan 2023 02:19:15 -0800 (PST) Date: Thu, 5 Jan 2023 10:18:12 +0000 In-Reply-To: <20230105101844.1893104-1-jthoughton@google.com> Mime-Version: 1.0 References: <20230105101844.1893104-1-jthoughton@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230105101844.1893104-15-jthoughton@google.com> Subject: [PATCH 14/46] 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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754177615329904239?= X-GMAIL-MSGID: =?utf-8?q?1754177615329904239?= This allows us to make huge PTEs at shifts other than the hstate shift, which will be necessary for high-granularity mappings. Acked-by: Mike Kravetz Signed-off-by: James Houghton --- mm/hugetlb.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index aa8e59cbca69..3a75833d7aba 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5028,11 +5028,11 @@ const struct vm_operations_struct hugetlb_vm_ops = { .pagesize = hugetlb_vm_op_pagesize, }; -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 = huge_page_shift(hstate_vma(vma)); if (writable) { entry = huge_pte_mkwrite(huge_pte_mkdirty(mk_pte(page, @@ -5046,6 +5046,14 @@ static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page, return entry; } +static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page, + int writable) +{ + unsigned int shift = 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) {