From patchwork Sat Feb 18 00:28:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13145403 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 92BF3C6379F for ; Sat, 18 Feb 2023 00:29:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56BE4280022; Fri, 17 Feb 2023 19:29:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F59E280002; Fri, 17 Feb 2023 19:29:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 396D2280022; Fri, 17 Feb 2023 19:29:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 29618280002 for ; Fri, 17 Feb 2023 19:29:24 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 043434038F for ; Sat, 18 Feb 2023 00:29:23 +0000 (UTC) X-FDA: 80478528648.28.D64F97C Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf25.hostedemail.com (Postfix) with ESMTP id 3DF32A001F for ; Sat, 18 Feb 2023 00:29:22 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=JocgWYIN; spf=pass (imf25.hostedemail.com: domain of 34RvwYwoKCP4pznu0mnzutmuumrk.iusrot03-ssq1giq.uxm@flex--jthoughton.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=34RvwYwoKCP4pznu0mnzutmuumrk.iusrot03-ssq1giq.uxm@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676680162; a=rsa-sha256; cv=none; b=dDuCCUyhJDrhs5hoEd5yL97TWU7Ka6VmcJclExQ5X4boSrPCEoug154lljTmXmFtbcigda CcY5qtQFssdN5UthmHaryWiZVAKItbAk/1ZtKLT2pwSA9PX/yRKkurzeRnUIgzJrJYEggW AM3vHf7URccAyVDjt+CRp7yknBhnv9w= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=JocgWYIN; spf=pass (imf25.hostedemail.com: domain of 34RvwYwoKCP4pznu0mnzutmuumrk.iusrot03-ssq1giq.uxm@flex--jthoughton.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=34RvwYwoKCP4pznu0mnzutmuumrk.iusrot03-ssq1giq.uxm@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=1676680162; 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=GaGw9/EzNbJa/6t4pJ7yTdVKyp/NxSZHrGSlaKMUK+E=; b=KSKWQCYoDBbfhPl0R3zCPwCh8rgsDObXYJIO888GKH2ztJkummYEthKmfOpRNFQhBi1AVE ubaE8GT/sHWuUmO/jrIoCLL9dmMmPGlbxcV9QyCCAbNnk6rgtKSeyBE+kZquSAoGXpxsn4 bfLJMnlnSgQlE3W7tX2ZJkSrFJhbp4Y= Received: by mail-yb1-f202.google.com with SMTP id 84-20020a251457000000b0091231592671so2247220ybu.1 for ; Fri, 17 Feb 2023 16:29:21 -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=GaGw9/EzNbJa/6t4pJ7yTdVKyp/NxSZHrGSlaKMUK+E=; b=JocgWYINYVmULfBzV4L8RQDVrC/ksz9Y8dI+J+nlAsc/Rp1x6bcRPeZoTXr9WfAAcE 637vbboTsrEowR0AFIppjUO9sj33exLylRWnzGJRB4Ke4REBcvqZSCDhAGTVp/j5YufQ YgJobCIYoQmdFEhMN4GhlXFaOyyGAAfpa0yi+wp2F9k5f0rcjtQQjbs0cPJHzrVzFUhk 50adDYi9tmH1ngFR2JYpBWBk6Q0MNk3dZbjF//o0K6YVOKO0ibfrqlf5m/HRlbVFSL22 zZbQkatRHAWrwIFzYMCpOzJ34fpVzrSFt1DFYR7+DUtjlcSXBgnd1OMWELyjBlQGE0L4 N6FQ== 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=GaGw9/EzNbJa/6t4pJ7yTdVKyp/NxSZHrGSlaKMUK+E=; b=miP6erWUjQi4RA64sg2PEjh047jgqniqikHEfakBzwEdTbW9oiPBMP4cIlyVCa+Ye2 riaaoVV3Vc+8Yv5TnMiFDuhcnNtgyih8putqpIRSZVlWRXx5hoyVg/34yrYMmq1asguY TiBR/QFSKxm5gxQT3t39peUrqHBb9XDEaT2mdEj+5hnr8PHJ1NZhfC4YGX/+x2URiwsX HOWB7Xu7GgiKk89xRCjyc5NzlZzXAD/lS5Cudh+wpCzrS57e4ncv5L9EPlVT+fJ37cha LPGYmhEYbY61TijR+fv8NcDInd6jmllciq1+PgL3BDSBohm9GYQttr6zYvVF58vE3IeD FP+w== X-Gm-Message-State: AO0yUKWrgeANsbh07iQzvsTieJWIhWomziGM7weKxCTCFnAXHrGvHJiN bw3ugX7r2vcu7VdpzdcoqkRaeKtRYDqMN4JX X-Google-Smtp-Source: AK7set9wC+TS+nhluAugC3NIlRB72Nwu/shM7r466HV9itDauVe/hJjpxls4Y6ZfyXihDUoWjGrwgClTAbgrS6MV X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a05:6902:12c8:b0:8e3:6aea:973 with SMTP id j8-20020a05690212c800b008e36aea0973mr91564ybu.4.1676680161464; Fri, 17 Feb 2023 16:29:21 -0800 (PST) Date: Sat, 18 Feb 2023 00:28:10 +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-38-jthoughton@google.com> Subject: [PATCH v2 37/46] hugetlb: replace make_huge_pte with 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-Rspam-User: X-Rspamd-Queue-Id: 3DF32A001F X-Rspamd-Server: rspam01 X-Stat-Signature: cidiynkoc9z5ynmksz1tt4d77bekaonx X-HE-Tag: 1676680162-908737 X-HE-Meta: U2FsdGVkX19An4UomyA35iGcZ+/JeOPtWfMBvKMeEAOkWS30w2MdQxCpUG09uZ07EogdSc1yW2+PYE4H+LmdJDz/prkNIOcGcZJLHshHq0y1P4OUNxIUsF7EWfeHSsEvk5OanNB7d8UGINhIvA7l4a+wMQ+paFx4D08ls5oWQJIwOpuswW1/7XPSygyVQrh0ZQsT699X2gRhBZeY+lmeOUVWTOnSO5TctI1EM4K9mdJFHsgt1x4hmdzyG1ojBBG0pVQT9VLsZ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Oow412zR3VV8s9pzIcovovBhlVFOf5Mcgs9bVwZKDhOqHQIB5mT8G7kcTS4R6R1nNqsn7prfcABvir1jaS1jXKLpLiJ/C2PdDjn6EwuG8kMHn4KZyzeJ2oG900f21pDoC47eNPxyCh/F5NHX1MVt4m5jp4DOrS84IH1oA0EtJkTnQHDZQrcPIphXGGcTq39GbmzLH99IxORO9s/x20TOWAwdF8v2bWwB2wI4w/zP34sqLaCv8UCuWOI= 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 diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e0a92e7c1755..4c9b3c5379b2 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5204,9 +5204,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; @@ -5222,14 +5222,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) { @@ -5272,7 +5264,9 @@ hugetlb_install_folio(struct vm_area_struct *vma, pte_t *ptep, unsigned long add { __folio_mark_uptodate(new_folio); hugepage_add_new_anon_rmap(new_folio, vma, addr); - set_huge_pte_at(vma->vm_mm, addr, ptep, make_huge_pte(vma, &new_folio->page, 1)); + set_huge_pte_at(vma->vm_mm, addr, ptep, make_huge_pte( + vma, &new_folio->page, 1, + huge_page_shift(hstate_vma(vma)))); hugetlb_count_add(pages_per_huge_page(hstate_vma(vma)), vma->vm_mm); folio_set_hugetlb_migratable(new_folio); } @@ -6006,7 +6000,8 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma, hugetlb_remove_rmap(old_page, huge_page_shift(h), h, vma); hugepage_add_new_anon_rmap(new_folio, vma, haddr); set_huge_pte_at(mm, haddr, ptep, - make_huge_pte(vma, &new_folio->page, !unshare)); + make_huge_pte(vma, &new_folio->page, !unshare, + huge_page_shift(h))); folio_set_hugetlb_migratable(new_folio); /* Make the old page be freed below */ new_folio = page_folio(old_page); @@ -6348,7 +6343,7 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, else hugetlb_add_file_rmap(subpage, hpte->shift, h, vma); - 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); @@ -6770,8 +6765,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, else writable = dst_vma->vm_flags & VM_WRITE; - _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 @@ -8169,8 +8163,7 @@ static int __hugetlb_collapse(struct mm_struct *mm, struct vm_area_struct *vma, } subpage = hugetlb_find_subpage(h, folio, curr); - entry = make_huge_pte_with_shift(vma, subpage, - writable, hpte.shift); + entry = make_huge_pte(vma, subpage, writable, hpte.shift); hugetlb_add_file_rmap(subpage, hpte.shift, h, vma); set_huge_pte_at(mm, curr, hpte.ptep, entry); spin_unlock(ptl);