From patchwork Mon Jan 16 19:18:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13103589 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 4C3FAC54EBE for ; Mon, 16 Jan 2023 19:18:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 931546B0071; Mon, 16 Jan 2023 14:18:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E0C16B0072; Mon, 16 Jan 2023 14:18:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DA296B0073; Mon, 16 Jan 2023 14:18:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6CA876B0071 for ; Mon, 16 Jan 2023 14:18:06 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2A26816078D for ; Mon, 16 Jan 2023 19:18:06 +0000 (UTC) X-FDA: 80361622572.11.833C42D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 324A8180013 for ; Mon, 16 Jan 2023 19:18:03 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tKECtYxe; dmarc=none; spf=none (imf24.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=1673896684; 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=BnbtySK6ffCqJd0MR8QcSoQMvOcUq25yh2Tdy1+LDNo=; b=zVLJph6QYhS6ZZEzm8Het9BtsBkjN333bPU/kv/FVHmXgJM0DvhSjCo1ZSAaJjy1T1mAmJ wQkqiOzz6WEZXFAcj/74Xi+NOVwu3msBwETSJJi3DZq0sfpmt/9NkqFpT5zQRgQi26MY6m aYZPD0CbreJkvD8loDEhbdtLtdyjw8E= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tKECtYxe; dmarc=none; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673896684; a=rsa-sha256; cv=none; b=ze0UiQXmuQV0ADOM3dm0D7h32z3EOt38S5gD27VdDCQVjbQZHlx1F8GSWOC4Neu2cGRMD1 N9IO5i8gL295UpmQIFmdJpvqJo7gIdbNfKFwWBOMW6CczF9u6vY8ryx9YzlF/PP3xeYbHD 2XM/3NHBHCk49L6J6/D/vlp7nkw60uc= 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=BnbtySK6ffCqJd0MR8QcSoQMvOcUq25yh2Tdy1+LDNo=; b=tKECtYxexgTUGrPFLV7TeO+Iw2 8fir2XzsnKD5KXttaKt8UMg8zXIp+ekPyJRSsq72hNELJ/Yzf62YfxcfF8oXs2pI1dOMJEOU2e8+p 2HJ/1+vx8EZU+JxLqOsjsA652C35GngmFyVy4ul+P7Vkhp1pvfzKOqd2dv3lVC/fEeUEXmnGZ95vb A5pg+BA5vXd+5ok1SwjPA9d7tOiKYevUJu9s4JYWW3mUhWMFs5UshGXJvJdU1WOZoxTwaMISsQGw4 EV0SNayzLRJos+/e/+tGJQR4xBNDnx58gKRN2dbF6mkXiS1ZF9khhJY4SVall1Q5aPiXkUv8Ugr3G c4N+/1kA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHUzm-00904j-PA; Mon, 16 Jan 2023 19:18:14 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 2/5] mm: Convert do_anonymous_page() to use a folio Date: Mon, 16 Jan 2023 19:18:10 +0000 Message-Id: <20230116191813.2145215-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230116191813.2145215-1-willy@infradead.org> References: <20230116191813.2145215-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 324A8180013 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: syj6qn39wi8dynf68bpkupcd9d9rzt3j X-HE-Tag: 1673896683-578306 X-HE-Meta: U2FsdGVkX1+FMKnE9M7RdBUU8fX9iJC6rcopzTgjrMcIn6N3Fjsa6VQPu2WbNbYGdFjU3AyyNDbOz1FUtEv4BT+ljtjnaZnC153zZcGdp7yjFLD4i+eSliK70Sb+UWUPw1bdqD331uV2rv2/UhTwtLEy0H2O2j8XlrNsOr0priGJJJVjqStbW4td9bO6s+HloMRTELmDGtK/+P3kgaWV5Bwe0m+5lX23JONO161f9ZlTFTJIbA1UWeVa4791uxzUX6GVQen5NVF8Nf0mCpqYQhSTDu5REF5rUte++nbwnhYLmDyCtDUZD3XLXBuvKQcAAkxMZ640I240KzyiWuFcJp2TmFe/jYWQAk8tLOd1QfzrgtooBKJ5KZnjThXmTdXjTOwg5U2ZSTdfUSFBvDKb2quSBIBFySzvt6PGY41WiRAQYFh/LdlpHMQSaGyFg7l1vsZml84rRBoH87eAM7KHVikESF1V5eF8cXb3gzOi+XA0OBvAj8iOHKGCdNa8qRY9dpXIbpjoVxyrxBzHyZc/G8GQUe9nTyWtC7FhLjEhk+xMkkU+ILYgWn9igtfAsW9nje/AghvazvBfLIFC/w0gOzjn/1tAxNSJER57hqYnauAeNcdu2C8bqy4/+Kip6fK08NJFFm3MjMEaVWqrLwqlYLvQJ2vDt+8kmhW5a+blaCRFt9eA5nCkMOGLl9IR0bYo9eBe9WUiexBlwZbiL2sGvbc+CN2Mf4tPT0Lbxkq77ZV7aG8jTS/6JbXnrX1V78+7DpIWndr4dwRk3bMgpCiINSTc5l9v0QERAPulW946+JUfl+WAMACLiuUT/fADR1m9JsXMlbnQNbF5pTSZCaI7am0QLKbtReMTLKpizR1pwJ5osPNcz1e0RpO33ux/PqP9T4CQ1kcpKEpkpcJHSmqsM4NDjqK5F9ancziNiRlqhieQ4zzQUAMEUQ== 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: Removes six calls to compound_head(); some inline and some external. Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 4cb2cd809b18..6099c786b5f9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3999,7 +3999,6 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) static vm_fault_t do_anonymous_page(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; - struct page *page; struct folio *folio; vm_fault_t ret = 0; pte_t entry; @@ -4054,19 +4053,18 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) if (!folio) goto oom; - page = &folio->page; if (mem_cgroup_charge(folio, vma->vm_mm, GFP_KERNEL)) goto oom_free_page; - cgroup_throttle_swaprate(page, GFP_KERNEL); + cgroup_throttle_swaprate(&folio->page, GFP_KERNEL); /* - * The memory barrier inside __SetPageUptodate makes sure that + * The memory barrier inside __folio_mark_uptodate makes sure that * preceding stores to the page contents become visible before * the set_pte_at() write. */ - __SetPageUptodate(page); + __folio_mark_uptodate(folio); - entry = mk_pte(page, vma->vm_page_prot); + entry = mk_pte(&folio->page, vma->vm_page_prot); entry = pte_sw_mkyoung(entry); if (vma->vm_flags & VM_WRITE) entry = pte_mkwrite(pte_mkdirty(entry)); @@ -4085,13 +4083,13 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) /* Deliver the page fault to userland, check inside PT lock */ if (userfaultfd_missing(vma)) { pte_unmap_unlock(vmf->pte, vmf->ptl); - put_page(page); + folio_put(folio); return handle_userfault(vmf, VM_UFFD_MISSING); } inc_mm_counter(vma->vm_mm, MM_ANONPAGES); - page_add_new_anon_rmap(page, vma, vmf->address); - lru_cache_add_inactive_or_unevictable(page, vma); + folio_add_new_anon_rmap(folio, vma, vmf->address); + folio_add_lru_vma(folio, vma); setpte: set_pte_at(vma->vm_mm, vmf->address, vmf->pte, entry); @@ -4101,10 +4099,10 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); return ret; release: - put_page(page); + folio_put(folio); goto unlock; oom_free_page: - put_page(page); + folio_put(folio); oom: return VM_FAULT_OOM; }