From patchwork Fri Sep 15 17:28:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13387301 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 11D06EED619 for ; Fri, 15 Sep 2023 17:28:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80E586B035E; Fri, 15 Sep 2023 13:28:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76ED86B035F; Fri, 15 Sep 2023 13:28:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 635466B0360; Fri, 15 Sep 2023 13:28:43 -0400 (EDT) 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 550606B035E for ; Fri, 15 Sep 2023 13:28:43 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 27C57C067D for ; Fri, 15 Sep 2023 17:28:43 +0000 (UTC) X-FDA: 81239516526.13.02B94BC Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id 8A8DF140028 for ; Fri, 15 Sep 2023 17:28:41 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=KELzHD3j; dmarc=none; spf=none (imf26.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=1694798921; 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=2i/sXmSR7Ozo56DuBZMs0VNeeLRw22KLzNAbjpObZmM=; b=kqz6+FWdrsx1f+ZSB0Bmi6sHXn1fyhMefPAe3O6Hk0P3o5weWIEU68Ccz+Ox7EOsBzQTDI CHBDKGGIqf946Oa1EMsyrJcwqcmygA/xQosGcUL5wsr3ulGWOq9nX6rphuOUNzwFReQaH6 dyY0/lCoHqSRC7UtaI/yCegDd4QR4po= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=KELzHD3j; dmarc=none; spf=none (imf26.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=1694798921; a=rsa-sha256; cv=none; b=B11qqr3tkN7sWDCFvXv0n3LX4t75AmfLzvJIfDx97eGSkLYo+MydlmQVBOzpSPesNrSgB6 /+tuu+xazHqCNvcNImblkrXdH+B4je53t6/pmLGPTNu/5odYmvBOd+jutZMnzAsVIEi8O9 gYdgd85dpwQYV0if1N0Jx0R3bv0Lju8= 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=2i/sXmSR7Ozo56DuBZMs0VNeeLRw22KLzNAbjpObZmM=; b=KELzHD3jhsEdbC0d5YQRPhCjCb VXnx6bRq+99LdZHQQA64VkBwEU6daG4JCKk8gA+OETsEyFUXnPD5mBRFgyTQd2djDc5LpjoOQFNug awAryetTdBr2gj6hS8M/Ad9FUcpBVzNZ4zoWL+ApESxKeOX88cQBlP44ZsxzHjfm2qUt8guLGTFMX yqHwEJJjW6qnTFr43xwhyHmLW73hZvZ43fr0JNeRn20U8zNfM3/sxxSfA6SQXqj8qIqSj53+bKFxY Cfk7UHweI7D5BusCRJi97CiZ6RAqsxnbpohzp522AsxMtrVMe9IXIrlpuuIsM40xtC18vSpZcbwvc EVNbgyEQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qhCcI-00B2xr-Ge; 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 1/3] mm: Use arch_make_folio_accessible() in gup_pte_range() Date: Fri, 15 Sep 2023 18:28:26 +0100 Message-Id: <20230915172829.2632994-2-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-Rspamd-Queue-Id: 8A8DF140028 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: dmj3kxjaog8r98ktcnmqpstsjb8jhuo9 X-HE-Tag: 1694798921-48015 X-HE-Meta: U2FsdGVkX18zb7hLTlGOa2a8zPq5/IjAHPm17ddHWUOzZqePbrrnK0THDwoqUUCG8+xDZo24S2oIaIzRlozHDHWmYVKafaqMUjgrxJfuSdr+q5Wv+EIFYRO4UYU7KHTrBavCRp4Ah3EXIcWJ/+08HcBmX909cYsdw6mP0xbIBangP1ciwwfUZUU0+4iZAVgmfgyM2PXi7HUAMGZF8+X1BM6qMyuKf8TK65S2Bh10z+Vf/yZQyq/wLMQgAySp9vlTEPGZo0nzFgK9lrNVBMlr5dF07EBOChoF5FAftQk6/b2iOeFELkee3VQ4LnHA+oTQtelCDS9ThfwcFR1Dacqay47gYLxuzTwlm3mrPd0Q/lQgN3uBrBffIqBesuTshl/ff3wNCPaDREfzMYgogACTt4e06e11WDUMHpGBGpOwkmBLSmgh1fVdJFsxF0xqo787vS+Jdn0oNuXzBtYwo3Gvcg2tYhkMo84JVxZIwkiqCEhv5K+QHmrzP1YYfQQvdQcIu5g+zJwmbD3rhXo58Jph6caQbO38hmfF6427V3I4tlfzNl5vBXcnMgmqukSY0l12IAv3TJtWOjslvv+PCOwlngHSnwhJxurAR9hXxqDID5FI0+FsrSJezwqLEBh7pVStPi4YxZNmsr7J+90m1TSU46u7BC/oBqNd1lpygPI4QXYGc4ChT+Z0PFyWRyxd5XPYG5gOsp8XcX9RCqms6+L2sTnsPorywAiFL+9xNX6B8XEL4mhhA30HmReYXt8SPFW44TCUqZmMK1gDpx02X7pjLOsrFvjXt/niu8Ufqdofe6XeKuPsUiMlMB6iIXASBLlNgyajXivPi0lAUDFP7ijryDUXHyjFgPkfh0UNf6pqsCaHKpxnyajecPUS6/GJzpVnsdrE3cnFOX7FEouj7IqD366ArIxNzQ88DJwP+FNyVyj6dO2P+GkaBKrp7xH/3cnxD/DJkAcVCulGGITETKP clo3HNXJ a+J0xTZqmC+VSfDGcy+DSKWHvVXUEQ+2+/PPmN35AXhgmPRpUltTXHg2MmqEeTu7aifwjpaRPNmYGqqgEn2RgmTApuzEsYKkkI/DZBIoK6vYLHi+MHp0Crip7wp81GIcw+bTLI0ZOwgmbiaYM1E4vopYXVxXmTjrdNZ6xrOXCIQ3NKgJVoQWRYbpv8ac9XmfwudLqiibKThyeF/xJuZobTyTqrul206nkuF07ScH4umuMxlJUE7nWfcFpzQ== 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 function already uses folios, so convert the arch_make_page_accessible() call to arch_make_folio_accessible(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/gup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 2f8a2d89fde1..ab8a0ebc728e 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2622,13 +2622,13 @@ static int gup_pte_range(pmd_t pmd, pmd_t *pmdp, unsigned long addr, } /* - * We need to make the page accessible if and only if we are + * 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) { gup_put_folio(folio, 1, flags); goto pte_unmap; 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); From patchwork Fri Sep 15 17:28:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13387298 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 82249EED619 for ; Fri, 15 Sep 2023 17:28:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DED16B027C; Fri, 15 Sep 2023 13:28:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 98FCD6B034F; Fri, 15 Sep 2023 13:28:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8581C6B035D; Fri, 15 Sep 2023 13:28:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 771A36B027C for ; Fri, 15 Sep 2023 13:28:35 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 531851A0417 for ; Fri, 15 Sep 2023 17:28:35 +0000 (UTC) X-FDA: 81239516190.25.01AEEAF Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id 2F0981C0003 for ; Fri, 15 Sep 2023 17:28:32 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=HX7V942n; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694798913; 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=yD9ktfId0rEPTuzY1QWVmcz2oEdRPlEREsQSBWfYTjA=; b=lHziuK4KHE0x4WSB/p5oco/chLDE8L1Txf27C+F83wQ2DvGb9qhf5BD5Lgj3Dyv00cOD41 BwXeVM6BAhLrjkFhnxdqKod24BnJ+VdmjDJ49LU40NMgv5Rxpu1VZpTH9CRYDHV6lTetEg etksTs1F7fSG4vpSyQ3hh8GfNRk973g= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=HX7V942n; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694798913; a=rsa-sha256; cv=none; b=RpXvyjRPDXGmszjrHh91sCylxr22gnPYnO63I2nfmkiBNd3YJPdnv+uJEakOKu0A8QP3V4 /fPNJ6pEmGR1plzPVI2OqLCKHRawUaWwbxjnMe/XCWVOV7UkZvDGEPcOSbnJZlGbU+WkVb US/L3z1Y7QQzL7CsJV8RGuKgpTuSb1I= 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=yD9ktfId0rEPTuzY1QWVmcz2oEdRPlEREsQSBWfYTjA=; b=HX7V942nk7CHODHYQIA5tKfGxK cqfI5oqlGmQtDriP6IOkzJVbb4aQ9RVu+dirfylSh9gv/23r1hv78HpgIe6qdGAv9305ibm/CcUiP Cy7+3Mb8ROXAJWT218q0vG0yenqlmVqwmpfUAiqkSYIU1i8d6Kllw2K8786NlWuL+qk9sic5Q84av vz6Tnnu+8qAIDYA6k0PurN9+jHhz8oS1Zz1yC7jBuK7KTc9AMNsD0E2OnAnjGA97omR5Dc2FrvaBt NHsa8YRE+hRQ5/zTc7ddCWQ201F0sGDveVYd+7PeKe+MhfDy0+FawWBchRl7RY8NXygzu1sr3awRc EYMtiwEg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qhCcI-00B2xv-MV; 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 3/3] s390: Convert arch_make_page_accessible() to arch_make_folio_accessible() Date: Fri, 15 Sep 2023 18:28:28 +0100 Message-Id: <20230915172829.2632994-4-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-Rspamd-Queue-Id: 2F0981C0003 X-Rspam-User: X-Stat-Signature: 8uixf6qsypfoyned8fgfs1hwc7o57don X-Rspamd-Server: rspam01 X-HE-Tag: 1694798912-922096 X-HE-Meta: U2FsdGVkX18hL8WISOZBFY3fpZxtlsiwXX5HUUNgTwilwHF09osVa/TDKOv2L3LaL/+EsAvB/ke6YbpzgIC4a5SqIoDz9aqg6pP9sWmnlDGJAwsCqwaJcgVTm4gDLCzMAAWAOwuLw2IioYC7AICVAB0+g7Ehz/4No+IVGrZ7cJFtE8wmu7gDoy5uq5Mw/Yd7sRLlr1sYF2kUieEnOxmIvoCIVGoQYc8w147H8pRTk0XwZz1jsa/b/L9WIHIL7Lg0FB+keT4xvMBQeqEIdFGMnR6OoTGNqyfSJMHcEDUxOof+BXLzMwphcdulhvYFFlbmHC58DQrB3hqCy4eXbxWnxEMzhn5z8juFKSOcXjDcnYKhGJV2skmUebryCw+AtsTYFAjEpUAtkm1YMcceHJH7NVPnw1hFLWJKVQYNZJT2V7Mtoyx8WwCm4vKKSeA9PdvZOcuNNh4JY7nsAZCIgmcr3I7aEKLIkEI9XUXr98L3AcD7DXlJbyAJ37iocdBkCXtww5qBwy3doGsgMWMaI/M1mdQMneKxNGRA6MWShYm5XXIgrN9VmLnupng7fSv4Ja7oJ/mhps92tpULAVqQYXl63Dh59hlfKm1vHPIj+UgfdL+VoUwdFpB2j9yDA3faBU6BX/NgUCWEYYk/S2t45SZY23fFdkBg9g1ZkB8I8d0XTauOSRZrnxst3b/5Ik2Ha1HqTnPdLG0q4/jcajImt6rARykBEznVQGfIzPQGasqdqFIaNyM1fDKxWLc83l8K2ZZnZKNN1gX7Y88mxWMKEc+OLwwqBg/1mjPgJoKuAnLKDbUyNhstOAAI+soRH1E4TA/VTbcNQDXUylkjfiw3Y55qseI1pk0qK+UJtenLsdlcVhkB4+nsQMsxchgJu0P4yVl+IUCEnVtJc5AfB1VjzT8qgBbVJ01urGZ//Gs3UA/Cmfxge2AzY3UbUqnATwFXvz16yFefjG6opVxkxHIxCCD 2LMjsyaR iyGNUFscgL4qtqbEJXcUfItPgxdT4qKZIKbKRAYUwbu9Mi5PAL+fvoihN+oUZJdb0cXlLFmwI8OCbkYcnWL4VI59UgGOpA2DXd1y+5JahHi4YSBlWBaIC+Fg7tpU8z+e+45DXCuLyPXASvGsMRqUXMo7df31trUpF5kAUIOR6sYbpPpipF5aOPmLaGYZm92GdsPG2h/vZRoFHlyD5L91WZVPznKoQ3O2OVT/I 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 users now using arch_make_folio_accessible(), move the loop over each page from common code into the only implementation. Signed-off-by: Matthew Wilcox (Oracle) --- arch/s390/include/asm/page.h | 5 ++-- arch/s390/kernel/uv.c | 46 +++++++++++++++++++++++------------- arch/s390/mm/fault.c | 15 ++++++------ include/linux/mm.h | 20 ++-------------- 4 files changed, 42 insertions(+), 44 deletions(-) diff --git a/arch/s390/include/asm/page.h b/arch/s390/include/asm/page.h index cfec0743314e..4f1b7107f0d9 100644 --- a/arch/s390/include/asm/page.h +++ b/arch/s390/include/asm/page.h @@ -162,6 +162,7 @@ static inline int page_reset_referenced(unsigned long addr) #define _PAGE_ACC_BITS 0xf0 /* HW access control bits */ struct page; +struct folio; void arch_free_page(struct page *page, int order); void arch_alloc_page(struct page *page, int order); void arch_set_page_dat(struct page *page, int order); @@ -175,8 +176,8 @@ static inline int devmem_is_allowed(unsigned long pfn) #define HAVE_ARCH_ALLOC_PAGE #if IS_ENABLED(CONFIG_PGSTE) -int arch_make_page_accessible(struct page *page); -#define HAVE_ARCH_MAKE_PAGE_ACCESSIBLE +int arch_make_folio_accessible(struct folio *folio); +#define arch_make_folio_accessible arch_make_folio_accessible #endif #define __PAGE_OFFSET 0x0UL diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c index fc07bc39e698..dadf29469b46 100644 --- a/arch/s390/kernel/uv.c +++ b/arch/s390/kernel/uv.c @@ -426,46 +426,58 @@ int gmap_destroy_page(struct gmap *gmap, unsigned long gaddr) EXPORT_SYMBOL_GPL(gmap_destroy_page); /* - * To be called with the page locked or with an extra reference! This will - * prevent gmap_make_secure from touching the page concurrently. Having 2 - * parallel make_page_accessible is fine, as the UV calls will become a - * no-op if the page is already exported. + * To be called with the folio locked or with an extra reference! This will + * prevent gmap_make_secure from touching the folio concurrently. Having 2 + * parallel make_folio_accessible is fine, as the UV calls will become a + * no-op if the folio is already exported. + * + * Returns 0 on success or negative errno. */ -int arch_make_page_accessible(struct page *page) +int arch_make_folio_accessible(struct folio *folio) { - int rc = 0; + unsigned long i, nr = folio_nr_pages(folio); + unsigned long pfn = folio_pfn(folio); + int err = 0; /* Hugepage cannot be protected, so nothing to do */ - if (PageHuge(page)) + if (folio_test_hugetlb(folio)) return 0; /* * PG_arch_1 is used in 3 places: * 1. for kernel page tables during early boot * 2. for storage keys of huge pages and KVM - * 3. As an indication that this page might be secure. This can + * 3. As an indication that this folio might be secure. This can * overindicate, e.g. we set the bit before calling * convert_to_secure. * As secure pages are never huge, all 3 variants can co-exists. */ - if (!test_bit(PG_arch_1, &page->flags)) + if (!test_bit(PG_arch_1, &folio->flags)) return 0; - rc = uv_pin_shared(page_to_phys(page)); - if (!rc) { - clear_bit(PG_arch_1, &page->flags); + for (i = 0; i < nr; i++) { + err = uv_pin_shared((pfn + i) * PAGE_SIZE); + if (err) + break; + } + if (!err) { + clear_bit(PG_arch_1, &folio->flags); return 0; } - rc = uv_convert_from_secure(page_to_phys(page)); - if (!rc) { - clear_bit(PG_arch_1, &page->flags); + for (i = 0; i < nr; i++) { + err = uv_convert_from_secure((pfn + i) * PAGE_SIZE); + if (err) + break; + } + if (!err) { + clear_bit(PG_arch_1, &folio->flags); return 0; } - return rc; + return err; } -EXPORT_SYMBOL_GPL(arch_make_page_accessible); +EXPORT_SYMBOL_GPL(arch_make_folio_accessible); #endif diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index b678295931c3..ac707e5d58ab 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -588,6 +588,7 @@ void do_secure_storage_access(struct pt_regs *regs) struct vm_area_struct *vma; struct mm_struct *mm; struct page *page; + struct folio *folio; struct gmap *gmap; int rc; @@ -643,17 +644,17 @@ void do_secure_storage_access(struct pt_regs *regs) mmap_read_unlock(mm); break; } - if (arch_make_page_accessible(page)) + folio = page_folio(page); + if (arch_make_folio_accessible(folio)) send_sig(SIGSEGV, current, 0); - put_page(page); + folio_put(folio); mmap_read_unlock(mm); break; case KERNEL_FAULT: - page = phys_to_page(addr); - if (unlikely(!try_get_page(page))) - break; - rc = arch_make_page_accessible(page); - put_page(page); + folio = page_folio(phys_to_page(addr)); + folio_get(folio); + rc = arch_make_folio_accessible(folio); + folio_put(folio); if (rc) BUG(); break; diff --git a/include/linux/mm.h b/include/linux/mm.h index bf5d0b1b16f4..55d3e466d3cb 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2139,26 +2139,10 @@ static inline int folio_estimated_sharers(struct folio *folio) return page_mapcount(folio_page(folio, 0)); } -#ifndef HAVE_ARCH_MAKE_PAGE_ACCESSIBLE -static inline int arch_make_page_accessible(struct page *page) -{ - return 0; -} -#endif - -#ifndef HAVE_ARCH_MAKE_FOLIO_ACCESSIBLE +#ifndef arch_make_folio_accessible static inline int arch_make_folio_accessible(struct folio *folio) { - int ret; - long i, nr = folio_nr_pages(folio); - - for (i = 0; i < nr; i++) { - ret = arch_make_page_accessible(folio_page(folio, i)); - if (ret) - break; - } - - return ret; + return 0; } #endif