From patchwork Fri Sep 15 17:28:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13387300 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 2B2BFEED619 for ; Fri, 15 Sep 2023 17:28:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDC226B035D; Fri, 15 Sep 2023 13:28:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B8E346B035E; Fri, 15 Sep 2023 13:28:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A52B56B035F; Fri, 15 Sep 2023 13:28:40 -0400 (EDT) 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 95CCC6B035D for ; Fri, 15 Sep 2023 13:28:40 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 64DCC1C96D5 for ; Fri, 15 Sep 2023 17:28:40 +0000 (UTC) X-FDA: 81239516400.09.5E7E06C Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP id C81391C0012 for ; Fri, 15 Sep 2023 17:28:38 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=BRBrYogw; dmarc=none; spf=none (imf21.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=1694798918; a=rsa-sha256; cv=none; b=qohaCHu9TBkb0ksGy8ptisxQV/4P1RW49rERhZB+TNS/vbhf4L87DtINLwCko56mp4+LnY VU78swq5vmuxhUZCD/lLXrQuQ6yOXqkygnG+OeFaMDPocZ/IwFQUVKf2XOGll4r6Cyb4CG XeIHu4OMYBrI+Vg9wxJB4x2mJ46sCt4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=BRBrYogw; dmarc=none; spf=none (imf21.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=1694798918; 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=ljKmIcCKst9DHe3IfbavuoPBudCpT3+oRR2H1OkUvA4=; b=G3J/JGhpihVvo7bCDKuuiXJzpwSDbyA27J2H/GVp8aPxUUc7Vusp0eiSsqxvZwelHO3FQp DvWXGBNudSDOmkwHY6KfxHlewDTGxcFyBKUciG/JDiHbMF4LBG4tTDoCCYjgqiSwkG3NC7 /4WEbbFh4v+t3P/YyJ+E9l4HxM0Z0RE= 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=ljKmIcCKst9DHe3IfbavuoPBudCpT3+oRR2H1OkUvA4=; b=BRBrYogwJLaEabmxwgaUjlbSMe CV4/6qA1wg4YbLawsYY/VjTxp1stCVMiCAgB+7R6R1Hr8iIZrKnUsgRIJgSLZCwquuBYaop7JUycL nnI55Gtyn7HE1B7S/aAmNZPp6xWVHaWcZYCRAavD/29BcSWVAVHStrrm4JEluywCFhysOG5RdTR3F CEps4GThOwQsircqgTvFoEEnrxZ9BS3hNq5jpnpRVg5oLKNbRO3RUNyIds+CQu5wawdN1MyJXwu/0 LrkZJ8R8iDRKcZkHEmRa8QaPMfd5AQxzdnBpcfJHjVJqRLGVf+RYyy8dXMgXHqMoxUy8OHEEJlmrN fvln2Fgg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qhCcI-00B2xt-Jb; Fri, 15 Sep 2023 17:28:30 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Claudio Imbrenda , linux-s390@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH 2/3] mm: Convert follow_page_pte() to use a folio Date: Fri, 15 Sep 2023 18:28:27 +0100 Message-Id: <20230915172829.2632994-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230915172829.2632994-1-willy@infradead.org> References: <20230915172829.2632994-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C81391C0012 X-Stat-Signature: 147bzfkmmrwighn9kz637qkbo99o4puq X-HE-Tag: 1694798918-410681 X-HE-Meta: U2FsdGVkX19Tq/PhnBmV9mtpsJa/4IXI1Yc+qnafixIF2TT2fG8CIoLzTHpvTCpjkKJ/etiI6iYeVqqyA4gXCfsGResSIwRbZgrmzy9o81z2v/nQqyxFzSL8MFCKFIzOEjZaNPc0daRpw89cRxzuznsivozD2h/LYdhgaOKCL1ymZkFFUWI+SUUS0V94rhOVOT/uXeIPPrW86fOsnJFESKZygo07bNEKG2j1vRu9/UvYLQ++MDyNHJAdi1ZV3rg9MABU3Nr2wuUI7Dv1npCNbe4a31tfMZLVB5n3UsDkz3is6qtwRMZNkW1i0ZTTHWo6Euai+saLEWr5pmKWs3h3cDgc2XkkwUTWsUv8iwLWKjSVfTT2EVEdOL2bveDwN5A//H9QAVbEsPG5be3zSbZXCkF/mkDCI782nAuUIeZyMDm2vtBV/RzuS+RKxRAWI6uSU6rl30FMLcI3a4/YXPXOJxir2eNThU7J7EI6msWGcb0ASmr5zxOroA0w2xyy+iDtYEo5WYstscCdhJyOeyh1e9Fxok/TtwhPQU4Be+a/Y2K61qbSz/XRBY63C0AmnKSCyMKKqEd/jOe5tt/++KVEG02j33TJizXUH3lrGwjK6woUGIzf11IUyQeOCtj9PCB9iz6sxzJ3VjxwFUGxCQuN2IBDmYWCXVeJJC6iLjI9XAAHHm3j9hivTgT6hvP5ruVu75/HfSRNq+ABcdEW/3mFXY5LfGe+tlutLBW+BjFpFScrxXIlzIuUK2q2g/hsEme5H4OXU4Jh0W4r3y9F3pbwJ1tNXRfR/l4hskg6gL33UnBeOVDOGJnpoUzItpcMtclfomZqa913gmZuMPNYUFgTh+BDHyUVusAYIXWVd8iacosfmF3suPAyG2BKbnmzzaPofVxxs73J+t14Bo51pamb+lWwBsN7DG9LrSU+IeTuZJrydhBpIE4agjMgO/G9HYQqOmmgpNKtbJEBbF9x794 ROfl5l+r PiauBPKlwRw9onyn1TaFCrsPHTxD2vbdzfbsLtaEZbUlD+e6XQmmYLAa8iGmvyrcVkVImBu2SWFa4f/MY3pI12swC5xaBV1BCv2r8nbAjONalYve8qxKmLfa33R+rF/WTAhOGQxwBQ1scPOoM7G5AsqVQ3CqJOmok7RGRWSOFyQvpVTqBmU8U2r7MoQImvtOBVuLU8JCidg8O6phMaeDZy3uzXcTyOKxBIYmA 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: Remove uses of PageAnon(), unpin_user_page(), PageDirty(), set_page_dirty() and mark_page_accessed(), all of which have a hidden call to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/gup.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index ab8a0ebc728e..ff1eaaba5720 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -582,6 +582,7 @@ static struct page *follow_page_pte(struct vm_area_struct *vma, { struct mm_struct *mm = vma->vm_mm; struct page *page; + struct folio *folio; spinlock_t *ptl; pte_t *ptep, pte; int ret; @@ -644,7 +645,8 @@ static struct page *follow_page_pte(struct vm_area_struct *vma, goto out; } - VM_BUG_ON_PAGE((flags & FOLL_PIN) && PageAnon(page) && + folio = page_folio(page); + VM_BUG_ON_PAGE((flags & FOLL_PIN) && folio_test_anon(folio) && !PageAnonExclusive(page), page); /* try_grab_page() does nothing unless FOLL_GET or FOLL_PIN is set. */ @@ -655,28 +657,28 @@ static struct page *follow_page_pte(struct vm_area_struct *vma, } /* - * We need to make the page accessible if and only if we are going + * We need to make the folio accessible if and only if we are going * to access its content (the FOLL_PIN case). Please see * Documentation/core-api/pin_user_pages.rst for details. */ if (flags & FOLL_PIN) { - ret = arch_make_page_accessible(page); + ret = arch_make_folio_accessible(folio); if (ret) { - unpin_user_page(page); + gup_put_folio(folio, 1, FOLL_PIN); page = ERR_PTR(ret); goto out; } } if (flags & FOLL_TOUCH) { if ((flags & FOLL_WRITE) && - !pte_dirty(pte) && !PageDirty(page)) - set_page_dirty(page); + !pte_dirty(pte) && !folio_test_dirty(folio)) + folio_mark_dirty(folio); /* * pte_mkyoung() would be more correct here, but atomic care * is needed to avoid losing the dirty bit: it is easier to use - * mark_page_accessed(). + * folio_mark_accessed(). */ - mark_page_accessed(page); + folio_mark_accessed(folio); } out: pte_unmap_unlock(ptep, ptl);