From patchwork Sat Feb 18 00:27:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 58820 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp142491wrn; Fri, 17 Feb 2023 16:30:47 -0800 (PST) X-Google-Smtp-Source: AK7set9fNsJirhnaChnui3kam5YMvzo9K3tH9nkW04deW/HnPGrNS/hNeS9Y6ib8RK726rmn0kI8 X-Received: by 2002:a17:907:9198:b0:860:c12c:14f9 with SMTP id bp24-20020a170907919800b00860c12c14f9mr1349890ejb.40.1676680247318; Fri, 17 Feb 2023 16:30:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676680247; cv=none; d=google.com; s=arc-20160816; b=u4eZ/tFAbrZ2OIeIVkzZfiVSZKJT9zD9xuFERU+awu/sF9V/CpmOq6lu3+jk+MZLR2 ccW7T7PmDtsXNQf+ytKvmltcOJRc+59vuS5QUEpzlj530stDUi/763E4+3D6jQYUtxKi uQFGAwfzOjxpi0cQstqmFc03FTsgQBfKlvfiNNFy/Nsh8lNRYyERvKYFHb89zjmzHUf9 cbq3KZFgtVn1QRTVSMSVtB5RbPA3iqhxY+pKnE62XPn+d8f5eATtpCDCPqDpYeTfMixI mtW/tUfBjJ1B1rEGmxDCiN2HdtfcU44ML6MEdmdMtSHYdujwRB3T3vtcPY4ALKETkHuU uMVQ== 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=xG9DbE8VOder+S14FjxoH+IwzXAdpZM7a0a5kZcYva0=; b=gOnsxS1JYQ82UuIAEU7MqUrYzeo5nG8L8xtXxypoH1eFOzX15EanDykyLQFDU+RRK3 1Q48vBp+BN1vub3mRjnGqVMTPHuYRQ/VbTQt2BaJR7zFgTGaZio1dRLFw9VQyFPZ4U9i c+gPaeTxjoZ2sQ46lSbjK3LS1Y/ylXeGpZOPMH2PZk5CA8dm0rKzwdEDCOUb/vI4Hwtg LPsmnZCNH36p3Raad0GZRIkXP/Et+R1F9R0hWZg61cKCPkMsfnbko8PbPklIAWd6Zyhk UQBxjsj/AuLzJ3vHXP2JZ7wNaHD8m0Gns9ydja5tKSFe4gA+/eYzkQFS3/JbrFZSPDRg UOXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=a3A4PV5p; 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-20020a170907918e00b007ade4c97618si5969921ejb.930.2023.02.17.16.30.23; Fri, 17 Feb 2023 16:30:47 -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=a3A4PV5p; 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 S230081AbjBRA3n (ORCPT + 99 others); Fri, 17 Feb 2023 19:29:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbjBRA3T (ORCPT ); Fri, 17 Feb 2023 19:29:19 -0500 Received: from mail-vk1-xa4a.google.com (mail-vk1-xa4a.google.com [IPv6:2607:f8b0:4864:20::a4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20AC96B311 for ; Fri, 17 Feb 2023 16:28:58 -0800 (PST) Received: by mail-vk1-xa4a.google.com with SMTP id n123-20020a1fbd81000000b00401684aa41aso609622vkf.17 for ; Fri, 17 Feb 2023 16:28:58 -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=xG9DbE8VOder+S14FjxoH+IwzXAdpZM7a0a5kZcYva0=; b=a3A4PV5p5qh9WhQPMBGPxG18XU5syYapjVA8cJrIQKg9SlfzzX0meZ5KSEbjCS76/h KkgUk1GyrdDSRmNwgJs67ciqNHmVAv5DJmhTpojLF0Uyhx6Rxq0nYHhEXa500KqHdLSY 8OPHt1vFrno7tMNUTlD5OZynE2nE9LC7G2tsTG/pmDJw36wEBjXLJkf3kjpEqyBFrFHU onGHC9FIBifpRYHynXz9NhBphtMbFvKNAw8XziHocmnSczkwT0klgF5M5m56ALq64vUA bsFoi/I6FyoSWC8X++RYI9nsaIKHXsGED5l665XewLFlFoDtjmgAh+mOcZ6rWrr94rxB 1OVA== 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=xG9DbE8VOder+S14FjxoH+IwzXAdpZM7a0a5kZcYva0=; b=44XdOPU0tjiy/GdRBHvTZJQxlwEc8kTJGm83Bx1p+wkIszjxL9vD+cKhBEYtyqGJCq xpEqttxco6656KAfXOFz2cny1Rhd6fajnXNtzxY/MyzRFNrcL402xU8gJyHCE3rbprw9 R4dHWAYx44EuUwkEq3IaQtCQpaa3soxpIw9i+DEPGV1nItk6yKQN0IfxGJfrIRSoLfhn Q5MkW56KnoJo2EBcO8gpQ4oXp3Dpi9FesMD8lcT68Bnj2wm5DspYjhBtTmmL0Oyww6bz AYlenYlmukvtykVqqmmkYDcgxsOPesqcN9EoE1DSlPCuUHLuwhVOmBbMFvp7aj96IuIy UBug== X-Gm-Message-State: AO0yUKWWwpudVbK7JLBdHtRgIWe8Fll5ur2FiOKcKdarbDoLp6HGLizN PTeaC1y4j9ogAej6+4/rPGN+g2mk/yu2Bru+ X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:ab0:53d9:0:b0:68d:6360:77b with SMTP id l25-20020ab053d9000000b0068d6360077bmr26282uaa.1.1676680137978; Fri, 17 Feb 2023 16:28:57 -0800 (PST) Date: Sat, 18 Feb 2023 00:27:48 +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-16-jthoughton@google.com> Subject: [PATCH v2 15/46] hugetlb: add make_huge_pte_with_shift From: James Houghton To: Mike Kravetz , Muchun Song , Peter Xu , Andrew Morton 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 , Frank van der Linden , Jiaqi Yan , 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?1758126667439059488?= X-GMAIL-MSGID: =?utf-8?q?1758126667439059488?= 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 Reviewed-by: Mina Almasry diff --git a/mm/hugetlb.c b/mm/hugetlb.c index f74183acc521..ed1d806020de 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5110,11 +5110,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, @@ -5128,6 +5128,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) {