From patchwork Tue Mar 8 21:34:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zach O'Keefe X-Patchwork-Id: 12774399 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 5BA32C433FE for ; Tue, 8 Mar 2022 21:35:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CEB4B8D000D; Tue, 8 Mar 2022 16:35:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C9BA38D0001; Tue, 8 Mar 2022 16:35:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A52118D000D; Tue, 8 Mar 2022 16:35:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 951128D0001 for ; Tue, 8 Mar 2022 16:35:07 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6C27295D for ; Tue, 8 Mar 2022 21:35:07 +0000 (UTC) X-FDA: 79222524654.11.FE1A494 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf02.hostedemail.com (Postfix) with ESMTP id EEBF680015 for ; Tue, 8 Mar 2022 21:35:06 +0000 (UTC) Received: by mail-pj1-f73.google.com with SMTP id lp2-20020a17090b4a8200b001bc449ecbceso2404472pjb.8 for ; Tue, 08 Mar 2022 13:35:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=EKD7tUEflTeYheu32sMPeLrGDW2eIa1SzfVfqlF/w18=; b=VLwIRVOtbNVMQIwA9vDGCjKKBnmxB3Gwx9STsng1Eh7UnRkYaGpL4egDF8TEKw35xC 1a9M+qK4YM41yBC9XEKU3A7Vbpn57tj6GyHg1wWrzSaCTsW9VTZNVtAOTXyi/4A7D8eT d9mFLN/tQ6YXvfIoxF2kmj6wtFQQU1El5pYk48vRLoOaMt36c8mB3kNlFkkEcfTSmNlw TNGBWgX4kgj1FKFedyz6ul2opNOEQbycWHxPO//Yirsif7KTdDGbBx6FRsGga0YvfHlw dXCz7hVWIurXtsadC3rH/4W/HjY66H7fVuCMDQaxUm1kYG08IC8LQZ3uQPMtBuEyltCN Adww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=EKD7tUEflTeYheu32sMPeLrGDW2eIa1SzfVfqlF/w18=; b=o0ZaBcqCg8w0vvv/UeB2U1J3/kOikCW+YRxqCO86uUsaL7aQE+DpvnDLpdPXYurzl9 oDqXO6rU/7DDCMsLHk0sajrBuKD0W2A9m0P9uBFmwciQbqFMGG0cvFvKvSDhEP7yJWF3 Qx7XVip68GWac4n+AxzWx6FTNuH8NFKtDX/fjmiyRjL+UE30zwA/ul0HQg9ohL49Tnuv ktyzRyf5I2GADyRfSVc+9mhwpiBbOb7OjTQGwn/HOvCwU78yIMND1p8tbMZb03ICaCyT gPmTKpAgZIgXUPjdEna2gX0rkXVPn4Ik5rhxK0pNFKpbZBpPPGLVf4EgzzHjtr6mOelK RPgQ== X-Gm-Message-State: AOAM530BQe/7DpEgbkzBqvGOqBG9y5eX+QEHipdabCnE/hcI1n205k23 8Stv6Hy1HG1lXuXJklI31pUvFoQPB1t/ X-Google-Smtp-Source: ABdhPJwZReJ91cvgq00tb/R3UOb3nFU6nzO3D7soWBdV1FhZx+sCDdRC15IJBdh/GImf6RrCEFxfzz2xTZrb X-Received: from zokeefe3.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1b6]) (user=zokeefe job=sendgmr) by 2002:a17:902:db0c:b0:151:ef4e:4d99 with SMTP id m12-20020a170902db0c00b00151ef4e4d99mr11058311plx.36.1646775305842; Tue, 08 Mar 2022 13:35:05 -0800 (PST) Date: Tue, 8 Mar 2022 13:34:13 -0800 In-Reply-To: <20220308213417.1407042-1-zokeefe@google.com> Message-Id: <20220308213417.1407042-11-zokeefe@google.com> Mime-Version: 1.0 References: <20220308213417.1407042-1-zokeefe@google.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog Subject: [RFC PATCH 10/14] mm/khugepaged: rename khugepaged-specific/not functions From: "Zach O'Keefe" To: Alex Shi , David Hildenbrand , David Rientjes , Michal Hocko , Pasha Tatashin , SeongJae Park , Song Liu , Vlastimil Babka , Zi Yan , linux-mm@kvack.org Cc: Andrea Arcangeli , Andrew Morton , Arnd Bergmann , Axel Rasmussen , Chris Kennelly , Chris Zankel , Helge Deller , Hugh Dickins , Ivan Kokshaysky , "James E.J. Bottomley" , Jens Axboe , "Kirill A. Shutemov" , Matthew Wilcox , Matt Turner , Max Filippov , Miaohe Lin , Minchan Kim , Patrick Xia , Pavel Begunkov , Peter Xu , Richard Henderson , Thomas Bogendoerfer , Yang Shi , "Zach O'Keefe" X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: EEBF680015 X-Stat-Signature: 56q76dkc8q1wmabwf49eth6oz6oijaek Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=VLwIRVOt; spf=pass (imf02.hostedemail.com: domain of 3CcwnYgcKCFgPEA44546EE6B4.2ECB8DKN-CCAL02A.EH6@flex--zokeefe.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3CcwnYgcKCFgPEA44546EE6B4.2ECB8DKN-CCAL02A.EH6@flex--zokeefe.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-HE-Tag: 1646775306-843210 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: In preparation for introducing a new collapse context, rename functions that are khugepaged-specific (or not). There is no functional change here. Signed-off-by: Zach O'Keefe --- mm/khugepaged.c | 50 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 403578161a3b..12ae765c5c32 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -92,7 +92,7 @@ struct collapse_control { /* Num pages scanned per node */ int node_load[MAX_NUMNODES]; - /* Last target selected in khugepaged_find_target_node() for this scan */ + /* Last target selected in find_target_node() for this scan */ int last_target_node; }; @@ -452,7 +452,7 @@ static void insert_to_mm_slots_hash(struct mm_struct *mm, hash_add(mm_slots_hash, &mm_slot->hash, (long)mm); } -static inline int khugepaged_test_exit(struct mm_struct *mm) +static inline int test_exit(struct mm_struct *mm) { return atomic_read(&mm->mm_users) == 0; } @@ -501,7 +501,7 @@ int __khugepaged_enter(struct mm_struct *mm) return -ENOMEM; /* __khugepaged_exit() must not run from under us */ - VM_BUG_ON_MM(khugepaged_test_exit(mm), mm); + VM_BUG_ON_MM(test_exit(mm), mm); if (unlikely(test_and_set_bit(MMF_VM_HUGEPAGE, &mm->flags))) { free_mm_slot(mm_slot); return 0; @@ -565,7 +565,7 @@ void __khugepaged_exit(struct mm_struct *mm) } else if (mm_slot) { /* * This is required to serialize against - * khugepaged_test_exit() (which is guaranteed to run + * test_exit() (which is guaranteed to run * under mmap sem read mode). Stop here (after we * return all pagetables will be destroyed) until * khugepaged has finished working on the pagetables @@ -836,7 +836,7 @@ static inline gfp_t alloc_hugepage_khugepaged_gfpmask(void) } #ifdef CONFIG_NUMA -static int khugepaged_find_target_node(struct collapse_control *cc) +static int find_target_node(struct collapse_control *cc) { int nid, target_node = 0, max_value = 0; @@ -895,7 +895,7 @@ khugepaged_alloc_page(struct page **hpage, gfp_t gfp, int node) return *hpage; } #else -static int khugepaged_find_target_node(struct collapse_control *cc) +static int find_target_node(struct collapse_control *cc) { return 0; } @@ -979,7 +979,7 @@ static int hugepage_vma_revalidate_pmd_count(struct mm_struct *mm, mmap_assert_locked(mm); - if (unlikely(khugepaged_test_exit(mm))) + if (unlikely(test_exit(mm))) return SCAN_ANY_PROCESS; *vmap = vma = find_vma(mm, address); @@ -1201,11 +1201,11 @@ static int __do_collapse_huge_page(struct mm_struct *mm, } -static void collapse_huge_page(struct mm_struct *mm, - unsigned long address, - struct page **hpage, - int node, int referenced, int unmapped, - int enforce_pte_scan_limits) +static void khugepaged_collapse_huge_page(struct mm_struct *mm, + unsigned long address, + struct page **hpage, + int node, int referenced, int unmapped, + int enforce_pte_scan_limits) { pmd_t *pmd; struct page *new_page; @@ -1468,11 +1468,13 @@ static int khugepaged_scan_pmd(struct mm_struct *mm, scan_pmd(mm, vma, address, cc, &scan_result); if (scan_result.result == SCAN_SUCCEED) { - node = khugepaged_find_target_node(cc); + node = find_target_node(cc); /* collapse_huge_page will return with the mmap_lock released */ - collapse_huge_page(mm, khugepaged_scan.address, hpage, node, - scan_result.referenced, scan_result.unmapped, - cc->enforce_pte_scan_limits); + khugepaged_collapse_huge_page(mm, khugepaged_scan.address, + hpage, node, + scan_result.referenced, + scan_result.unmapped, + cc->enforce_pte_scan_limits); } trace_mm_khugepaged_scan_pmd(mm, scan_result.head, scan_result.writable, @@ -1489,7 +1491,7 @@ static void collect_mm_slot(struct mm_slot *mm_slot) lockdep_assert_held(&khugepaged_mm_lock); - if (khugepaged_test_exit(mm)) { + if (test_exit(mm)) { /* free mm_slot */ hash_del(&mm_slot->hash); list_del(&mm_slot->mm_node); @@ -1656,7 +1658,7 @@ static void khugepaged_collapse_pte_mapped_thps(struct mm_slot *mm_slot) if (!mmap_write_trylock(mm)) return; - if (unlikely(khugepaged_test_exit(mm))) + if (unlikely(test_exit(mm))) goto out; for (i = 0; i < mm_slot->nr_pte_mapped_thp; i++) @@ -1711,7 +1713,7 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff) * reverse order. Trylock is a way to avoid deadlock. */ if (mmap_write_trylock(mm)) { - if (!khugepaged_test_exit(mm)) + if (!test_exit(mm)) collapse_and_free_pmd(mm, vma, addr, pmd); mmap_write_unlock(mm); } else { @@ -2188,7 +2190,7 @@ static void khugepaged_scan_file(struct mm_struct *mm, result = SCAN_EXCEED_NONE_PTE; count_vm_event(THP_SCAN_EXCEED_NONE_PTE); } else { - node = khugepaged_find_target_node(cc); + node = find_target_node(cc); collapse_file(mm, file, start, hpage, node); } } @@ -2241,7 +2243,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, vma = NULL; if (unlikely(!mmap_read_trylock(mm))) goto breakouterloop_mmap_lock; - if (likely(!khugepaged_test_exit(mm))) + if (likely(!test_exit(mm))) vma = find_vma(mm, khugepaged_scan.address); progress++; @@ -2249,7 +2251,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, unsigned long hstart, hend; cond_resched(); - if (unlikely(khugepaged_test_exit(mm))) { + if (unlikely(test_exit(mm))) { progress++; break; } @@ -2273,7 +2275,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, while (khugepaged_scan.address < hend) { int ret; cond_resched(); - if (unlikely(khugepaged_test_exit(mm))) + if (unlikely(test_exit(mm))) goto breakouterloop; VM_BUG_ON(khugepaged_scan.address < hstart || @@ -2313,7 +2315,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, * Release the current mm_slot if this mm is about to die, or * if we scanned all vmas of this mm. */ - if (khugepaged_test_exit(mm) || !vma) { + if (test_exit(mm) || !vma) { /* * Make sure that if mm_users is reaching zero while * khugepaged runs here, khugepaged_exit will find