From patchwork Thu Jan 5 10:18:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13089670 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 ECBE0C3DA7A for ; Thu, 5 Jan 2023 10:19:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1067694001E; Thu, 5 Jan 2023 05:19:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B705940008; Thu, 5 Jan 2023 05:19:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E72EF94001E; Thu, 5 Jan 2023 05:19:49 -0500 (EST) 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 C7FB1940008 for ; Thu, 5 Jan 2023 05:19:49 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A02E1A0D0D for ; Thu, 5 Jan 2023 10:19:49 +0000 (UTC) X-FDA: 80320349298.11.25C04D4 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf15.hostedemail.com (Postfix) with ESMTP id 1D020A000D for ; Thu, 5 Jan 2023 10:19:47 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=rzwvJ5O+; spf=pass (imf15.hostedemail.com: domain of 3Q6S2YwoKCIox7v28uv721u22uzs.q20zw18B-00y9oqy.25u@flex--jthoughton.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3Q6S2YwoKCIox7v28uv721u22uzs.q20zw18B-00y9oqy.25u@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672913988; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hEbQ+jBtLxtopyfN7uZpWk6gsndFSvLkXCtItdMk4sk=; b=vqLr3c6ZsET8mrcjamXeBt4vE1vltE7IbAHU0xU73TqbdI1iF2YhbKNE480v8uM7gJW1zx p0kzfnUwTkYaPRRXqGRYKc5HU6relZAAaImSjt7J5tviZuTXIsYXZZfdbb0hEdfVtgn66H wP3laEMnp4jFe5cly77yaaiHzQeX+uI= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=rzwvJ5O+; spf=pass (imf15.hostedemail.com: domain of 3Q6S2YwoKCIox7v28uv721u22uzs.q20zw18B-00y9oqy.25u@flex--jthoughton.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3Q6S2YwoKCIox7v28uv721u22uzs.q20zw18B-00y9oqy.25u@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672913988; a=rsa-sha256; cv=none; b=Nw5jOxpspwrAC5nyGxyAhjK/3z2W5ttaLWnNxLtDMX0WfK4HHXX1Gh9kBgh4KB0S9AnXmD aprQXMVyp/XwjOfqxSL68bDpM9GN2E4+kU24mHVDaO/SHIbqC+pLRgou4+SHf5FOi3J/9M LeHLms8u2yXxR1ZSv2e8iSjT6Z0Q/yk= Received: by mail-yb1-f202.google.com with SMTP id v9-20020a259d89000000b007b515f139e0so1270363ybp.17 for ; Thu, 05 Jan 2023 02:19:47 -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=hEbQ+jBtLxtopyfN7uZpWk6gsndFSvLkXCtItdMk4sk=; b=rzwvJ5O+RQ04BJH+OwNVawRQc+ih25bUT/fZ/ETXftYRdFLi35+tT7QSZVPpjxQS1b ABqV/Hscpt1tyn1fI606OsdBiPRbxM/DjtciO23jBbkIiSjZtGIU3B25/psNHjy2QqL+ n+3yYQBuUK1pJUfmrrK81ggN3y49WxAlQreHX/XO36/3irdaWFvE8DSXKP/d0WyODufr NKEQ4IDvemsHhse43nm2blfRwsmlA0BhLtmZ35A63iDIfnnlMTETvBoFXN6Dtdoz/wqg ut170EwANC3ESebWxhfhtn0H73/Xo/GUK5HnUthjZUYekYmuVYd1stlWrAvlonj7Th8O f90g== 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=hEbQ+jBtLxtopyfN7uZpWk6gsndFSvLkXCtItdMk4sk=; b=7n4Zw/83rq7/NLrKKpzHFcy4Vtaq8xJHkaEb507wrTkod7ogAGX0rT+mMnSSHVJPwz i8jK71Oe2Pfpd4ps0W1w9BwUogGvs/uu70RnLzVWJdUMBMVy3mvVO+bEXYxlUeQaMaXb VRyW4L1FbHlwouJZfSvTwnNa/yF2fne3yUaf6xty40MRxiwOqKcxyIelDa1D2k5nlZ78 dUuYTvjOy6sfcDkw95xzVBti9vLxbyOQLmDyadLwqeRK/uoYWi43AP7+9mAKmcVpJAvP dRkmnccizJkUy7RizSzPiCUtePZVrhRHi2Il967dG+OLmfzkXEMBj2ARfcXKkdAOk27p eeYQ== X-Gm-Message-State: AFqh2krQg4WMjdIVVZnZJXQ1U5bzyrVbnUQSe897U9GR/DKdDJOCFJmB GmFY4o5NBLkaPhgLcy7MBHa53hN7TSDiIVGT X-Google-Smtp-Source: AMrXdXsemwUzDJMwgzQg89O7O9QxdUcYFBlrWYezrLK7LXzb/jgbmzFmnWrbyc26/hsZEaa1LCvqsSIGoI/G4zn2 X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a81:c30e:0:b0:4b2:72:d8ee with SMTP id r14-20020a81c30e000000b004b20072d8eemr1083439ywk.272.1672913987306; Thu, 05 Jan 2023 02:19:47 -0800 (PST) Date: Thu, 5 Jan 2023 10:18:35 +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-38-jthoughton@google.com> Subject: [PATCH 37/46] hugetlb: replace make_huge_pte with 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-Stat-Signature: rgjsb7kz9is6q7efdmca59cu55k99g65 X-Rspam-User: X-Rspamd-Queue-Id: 1D020A000D X-Rspamd-Server: rspam06 X-HE-Tag: 1672913987-894168 X-HE-Meta: U2FsdGVkX18kGoWDzk7x2SAXYBfxdxlmxqy68ip3Qrb1cPWu12lGFlxz4W2XRidb+vrL7aexviR9V4I5M+thmG2DwzksxJMiiibWm9cF56hh5Woy1K5l6zMMHmEf06sPACMPTJMDAKuJglMNxTbjxPaq03yTEWGyx7Xaoy1j9IkjYRKWutnSc3TCsJvY585Bnk7b1MUkzbpL/fKWlb3B4ROu0flb8z+U7u4CVWHf4OBj3tjD3bfwUKMdoep0/wiWpAQ06vjYoZWoGmPYj6lGH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RAXHJ9unUefSGpLusZPeEs9Nutap3kLb95zU1iTbcmvmnCI2cKKTDur0hdcPOLZ9eqvmCuEUHipP 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: This removes the old definition of make_huge_pte, where now we always require the shift to be explicitly given. All callsites are cleaned up. Signed-off-by: James Houghton --- mm/hugetlb.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index d71adc03138d..10a323e6bd9c 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5069,9 +5069,9 @@ const struct vm_operations_struct hugetlb_vm_ops = { .pagesize = hugetlb_vm_op_pagesize, }; -static pte_t make_huge_pte_with_shift(struct vm_area_struct *vma, - struct page *page, int writable, - int shift) +static pte_t make_huge_pte(struct vm_area_struct *vma, + struct page *page, int writable, + int shift) { pte_t entry; @@ -5087,14 +5087,6 @@ static pte_t make_huge_pte_with_shift(struct vm_area_struct *vma, 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) { @@ -5135,10 +5127,12 @@ static void hugetlb_install_page(struct vm_area_struct *vma, pte_t *ptep, unsigned long addr, struct page *new_page) { + struct hstate *h = hstate_vma(vma); __SetPageUptodate(new_page); hugepage_add_new_anon_rmap(new_page, vma, addr); - set_huge_pte_at(vma->vm_mm, addr, ptep, make_huge_pte(vma, new_page, 1)); - hugetlb_count_add(pages_per_huge_page(hstate_vma(vma)), vma->vm_mm); + set_huge_pte_at(vma->vm_mm, addr, ptep, make_huge_pte(vma, new_page, 1, + huge_page_shift(h))); + hugetlb_count_add(pages_per_huge_page(h), vma->vm_mm); SetHPageMigratable(new_page); } @@ -5854,7 +5848,8 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma, page_remove_rmap(old_page, vma, true); hugepage_add_new_anon_rmap(new_page, vma, haddr); set_huge_pte_at(mm, haddr, ptep, - make_huge_pte(vma, new_page, !unshare)); + make_huge_pte(vma, new_page, !unshare, + huge_page_shift(h))); SetHPageMigratable(new_page); /* Make the old page be freed below */ new_page = old_page; @@ -6163,7 +6158,7 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, page_dup_file_rmap(page, true); subpage = hugetlb_find_subpage(h, page, haddr_hgm); - new_pte = make_huge_pte_with_shift(vma, subpage, + new_pte = make_huge_pte(vma, subpage, ((vma->vm_flags & VM_WRITE) && (vma->vm_flags & VM_SHARED)), hpte->shift); @@ -6585,8 +6580,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, subpage = hugetlb_find_subpage(h, page, dst_addr); - _dst_pte = make_huge_pte_with_shift(dst_vma, subpage, writable, - dst_hpte->shift); + _dst_pte = make_huge_pte(dst_vma, subpage, writable, dst_hpte->shift); /* * Always mark UFFDIO_COPY page dirty; note that this may not be * extremely important for hugetlbfs for now since swapping is not @@ -7999,8 +7993,7 @@ int hugetlb_collapse(struct mm_struct *mm, struct vm_area_struct *vma, page_dup_file_rmap(hpage, true); subpage = hugetlb_find_subpage(h, hpage, curr); - entry = make_huge_pte_with_shift(vma, subpage, - writable, hpte.shift); + entry = make_huge_pte(vma, subpage, writable, hpte.shift); set_huge_pte_at(mm, curr, hpte.ptep, entry); next_hpte: curr += hugetlb_pte_size(&hpte);