From mboxrd@z Thu Jan 1 00:00:00 1970 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 345F9ECAAD5 for ; Fri, 2 Sep 2022 19:48:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D334A80105; Fri, 2 Sep 2022 15:47:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D3518010D; Fri, 2 Sep 2022 15:47:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2565F80111; Fri, 2 Sep 2022 15:47:06 -0400 (EDT) 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 4704B80107 for ; Fri, 2 Sep 2022 15:47:05 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 298B8160802 for ; Fri, 2 Sep 2022 19:47:05 +0000 (UTC) X-FDA: 79868178810.02.ED70D41 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id E0B0F80065 for ; Fri, 2 Sep 2022 19:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=g+3prt31CnADlYcIOTknfhIStNKaTWbAAl4JikLJpTo=; b=HfPc/Lu6YeSBzdfWlnDcpLVPoc Kv8um7qb50dMZoShR7W0mnjqgQzF/Gf23frXViHXwcMEbJg5hb1uYxAisYP6P6GVOuKWfIX3PlW1g LpHIyYcA2NtVIgYobxBxzn9RGuGUN7jF6S+S4/1e7T65Ohym3hGijGERW3UdxwSiOL9yhhpkv6wyB gGat0HzllQZb0tG6Am6Dqn+8htCR0MziUr7GK1RXyVTgajrCvSdX3rn9OPRB3ttKcXK3Sm6Esiwjs lMSyKuJAXaFAsKWLBei+dnScVnmw6CWNaO6bpWgBM35r4vDAs32uy7NIpabLUiitAzZsLLisoLA26 hz4Fe6iw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oUCd6-007IiZ-KZ; Fri, 02 Sep 2022 19:47:04 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 54/57] mm: Convert page_get_anon_vma() to folio_get_anon_vma() Date: Fri, 2 Sep 2022 20:46:50 +0100 Message-Id: <20220902194653.1739778-55-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220902194653.1739778-1-willy@infradead.org> References: <20220902194653.1739778-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662148024; a=rsa-sha256; cv=none; b=WrUmaa21rVWukN1Wj5u2jL/f++NQh8XXItlFUiymldXRXPKB/STLdSjo6h14tzfJO8GEKJ z8iN+IDIOYoqajkPXIzK9ymQUxh4JHc3NEDhHERnEapulBQcQSMBsIPHyj9GSCHTJNstfg wOsE6YUs7IScB1mLlJ1IwQIwg60xq1w= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="HfPc/Lu6"; dmarc=none; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662148024; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=g+3prt31CnADlYcIOTknfhIStNKaTWbAAl4JikLJpTo=; b=yOY7aKD8sT8HuAnb/LwrRsElatHBA0WwNVb9VijjDBTRLYLejyK/RcXAFsdjleB186f3FZ 4PRKuCDs8R5BUtDHmMV6YZxBtW+qBFPl+XAXcW277Yn1HLIYfZwTai+lwCi17FlyIEgasU J1ifrzllUH+1ySIhUuWdMtNDHfqV1JY= X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: E0B0F80065 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="HfPc/Lu6"; dmarc=none; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: X-Stat-Signature: e4mz68uc7uifneaaqfu3ickekeaqft7s X-HE-Tag: 1662148024-582216 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: With all callers now passing in a folio, rename the function and convert all callers. Removes a couple of calls to compound_head() and a reference to page->mapping. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/rmap.h | 2 +- mm/huge_memory.c | 2 +- mm/migrate.c | 6 +++--- mm/rmap.c | 14 +++++++------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index b89b4b86951f..79974285a6f0 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -166,7 +166,7 @@ static inline void anon_vma_merge(struct vm_area_struct *vma, unlink_anon_vmas(next); } -struct anon_vma *page_get_anon_vma(struct page *page); +struct anon_vma *folio_get_anon_vma(struct folio *folio); /* RMAP flags, currently only relevant for some anon rmap operations. */ typedef int __bitwise rmap_t; diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 4e76b3c760ac..38213d06f595 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2641,7 +2641,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) * is taken to serialise against parallel split or collapse * operations. */ - anon_vma = page_get_anon_vma(&folio->page); + anon_vma = folio_get_anon_vma(folio); if (!anon_vma) { ret = -EBUSY; goto out; diff --git a/mm/migrate.c b/mm/migrate.c index 7b338ddd011a..c688319ffd46 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1035,14 +1035,14 @@ static int __unmap_and_move(struct folio *src, struct folio *dst, * File Caches may use write_page() or lock_page() in migration, then, * just care Anon page here. * - * Only page_get_anon_vma() understands the subtleties of + * Only folio_get_anon_vma() understands the subtleties of * getting a hold on an anon_vma from outside one of its mms. * But if we cannot get anon_vma, then we won't need it anyway, * because that implies that the anon page is no longer mapped * (and cannot be remapped so long as we hold the page lock). */ if (folio_test_anon(src) && !folio_test_ksm(src)) - anon_vma = page_get_anon_vma(&src->page); + anon_vma = folio_get_anon_vma(src); /* * Block others from accessing the new page when we get around to @@ -1283,7 +1283,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page, } if (folio_test_anon(src)) - anon_vma = page_get_anon_vma(&src->page); + anon_vma = folio_get_anon_vma(src); if (unlikely(!folio_trylock(dst))) goto put_anon; diff --git a/mm/rmap.c b/mm/rmap.c index 76ebfc8beb7e..e37e5377e5a9 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -489,16 +489,16 @@ void __init anon_vma_init(void) * if there is a mapcount, we can dereference the anon_vma after observing * those. */ -struct anon_vma *page_get_anon_vma(struct page *page) +struct anon_vma *folio_get_anon_vma(struct folio *folio) { struct anon_vma *anon_vma = NULL; unsigned long anon_mapping; rcu_read_lock(); - anon_mapping = (unsigned long)READ_ONCE(page->mapping); + anon_mapping = (unsigned long)READ_ONCE(folio->mapping); if ((anon_mapping & PAGE_MAPPING_FLAGS) != PAGE_MAPPING_ANON) goto out; - if (!page_mapped(page)) + if (!folio_mapped(folio)) goto out; anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON); @@ -508,13 +508,13 @@ struct anon_vma *page_get_anon_vma(struct page *page) } /* - * If this page is still mapped, then its anon_vma cannot have been + * If this folio is still mapped, then its anon_vma cannot have been * freed. But if it has been unmapped, we have no security against the * anon_vma structure being freed and reused (for another anon_vma: * SLAB_TYPESAFE_BY_RCU guarantees that - so the atomic_inc_not_zero() * above cannot corrupt). */ - if (!page_mapped(page)) { + if (!folio_mapped(folio)) { rcu_read_unlock(); put_anon_vma(anon_vma); return NULL; @@ -526,11 +526,11 @@ struct anon_vma *page_get_anon_vma(struct page *page) } /* - * Similar to page_get_anon_vma() except it locks the anon_vma. + * Similar to folio_get_anon_vma() except it locks the anon_vma. * * Its a little more complex as it tries to keep the fast path to a single * atomic op -- the trylock. If we fail the trylock, we fall back to getting a - * reference like with page_get_anon_vma() and then block on the mutex + * reference like with folio_get_anon_vma() and then block on the mutex * on !rwc->try_lock case. */ struct anon_vma *folio_lock_anon_vma_read(struct folio *folio, -- 2.35.1