From patchwork Wed Aug 2 15:13:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13338348 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 E701EC04E69 for ; Wed, 2 Aug 2023 15:14:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15EF628019A; Wed, 2 Aug 2023 11:14:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C030D280196; Wed, 2 Aug 2023 11:14:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CD4628019B; Wed, 2 Aug 2023 11:14:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1133B28019A for ; Wed, 2 Aug 2023 11:14:16 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A787440FAC for ; Wed, 2 Aug 2023 15:14:15 +0000 (UTC) X-FDA: 81079510470.07.32AEDB9 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id C0AC980016 for ; Wed, 2 Aug 2023 15:14:12 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Lg1xzCUy; dmarc=none; spf=none (imf30.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=1690989252; 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=9qyEM7+DnFqlFc74V3faMXypJWL5ynd3t/43lgDYBHw=; b=w3I8ucH9LnNQj7xnQlDtwlfGwG+7vIFRMQ2PhhW63h1ZcrjW6V0PATVvkDmlwzLPKM6Jdt gZ5uUokGI5QfjsYdWNITnZzCdhVQugow0HP9Nvx918TVe05No3jcMyhy8Y/4b98jAVmNMG jUwGhgB3F69il7s8g8F7keWNEcHn+vk= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Lg1xzCUy; dmarc=none; spf=none (imf30.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=1690989252; a=rsa-sha256; cv=none; b=i01ym4nWR95AKMLNxS78hoOjzC8VENk0xWxup/ciMUBDHnwGuJSMcfRVYl1wnExeLZ4zUs c8GbNKuajnSNPKYZMFJBRSSdxY+/9z+tLV2D1tkbtShIWrRx81gwvHdMB0AtuMSf7k8z6O nmKzjB1g5o6kHN6Ze2rXJQsHpzA5rbA= 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=9qyEM7+DnFqlFc74V3faMXypJWL5ynd3t/43lgDYBHw=; b=Lg1xzCUywUYblSsgkydYQMoLj5 UggqhWH1R2z7tL3VZi0kexW4aiNwI6o3kvhV7Ratz9RRsvrDHVpmfwEgnfSOp4CEtx/YdNnGMJ/dP hgQfbxhlT4WquR74cvQLzYBsWSqHOEzEhXhtfqZ985Eaowptz5N8+ADvY6xFJALSqrba1to1snHhY kzYcmDEu7nO8GdFkkDyD5Mf7nE4Hp7EZvA/oqS5zB/6yLmLsDG7mkf5gnIqzmTubs79iu/0ZvgMP5 i024SM6MGqKapd1m4IjpWOoVaH3CUFjDgFKQRJGG821tjzwMWDoCy9xzbar7I64LtY0IhfzayEKQt S42oF4wA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qRDYA-00FfkY-LY; Wed, 02 Aug 2023 15:14:10 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Gerald Schaefer , Mike Rapoport , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , linux-s390@vger.kernel.org Subject: [PATCH v6 23/38] s390: Implement the new page table range API Date: Wed, 2 Aug 2023 16:13:51 +0100 Message-Id: <20230802151406.3735276-24-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230802151406.3735276-1-willy@infradead.org> References: <20230802151406.3735276-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C0AC980016 X-Stat-Signature: k7ausjeon9j58t1x1j8r8iibc5mbe6k9 X-HE-Tag: 1690989252-204002 X-HE-Meta: U2FsdGVkX1/1ilkCSsHSEsTwIGMUU4RTcxxN9kTYGrfA440Ah4A29TI68hUJwpbJ4cBzf1qDb12+oUsWDS9SoRxwuKMDSkGL+Af6oS4D6b5BtUv3FIyGrxyp4e/0LP36pL+Ff0JgEF/AEgckMuiVtYWxJMoCbglt0qsnagO5eSbgyX4B4/jDlj360B6ldR+Y3yZjLVFycgcXnyOLcAEtWqltHkSMdeek+5HlL1XP42u93RPApgp3PnkSnoOp40uotYtp7vcD9vnR63GIcM9NiHgIbcC898NcCgKMCQAZqsVax/pbj9yeGsPO0vDWb3V6icimaiq1BxnN39CeJsN/eGDaU5K2L7uo1i5/HBUa3DL6FIjNZ5BgGxPUR9RqP4ziKpmiqv+eeoaqsyzwSRjoJQf25/Ht6v5fb0QEJoVbLgvQfBg567RLSBTCGS6Kn2PIkBh7gXJ+4GO9J//OwVNokkJ810zqkEVVFRHWT9LKXUFHhzFRBApqW44dseoXaLeZL1GG/57GM73Qt3Wo2euBPjC2PlmqkfifytZvIe42OWFn7m+a4rXxlFNUCI6LMM9/cxYt2oY9pYCQqFfVpwYf+o7I6Ypsu9rcC2WbNSBkA97G0azZ8Rbc2ow+qjTnmy+71qGRBtN4NsvbFouTspsE80eVL5audlJFKVcjfvNLRue7Z8ETGwKi3L3eBWp7V8TdG/HeJUKnKEFfPUUj91T53zoQFVifUDc624+iFLaQXxegsfOJ2a64KzcpDoERHu4kW1Rv4Z3uQOHhcujBSSZsqdm98kgbo3BbldsHyk0CAJsXs30jBVY7yzZ2LdC7cwPXjg/ERrFd8xygfP3C8jzGSWd/fvVbnD/jPyAisywMidHXGYfYwSlUe6Pjqi/65OeORprkgkVH8k4NqsZR1/Z9hgPuFieiF9BtI2C255jLsgN9wvtnQEfXJB4zWA6hxAELX4rebaIJMSTwc87UJBQ OMj4tOBw 0ptWW/JMsdfPHHT6u9edl4NoGvDcaK1NMoaN39ueInchXTQ59dEVPkVgcppDjKULi832pX867ANSLcRF2NEXF5LAMOu69aBcczE4YXshBcbEsfbU55i4Ij5TuXdwoOhEpxgcgCXVYyQclRr3wdz5TzXel4NLx1qbLv6wugVnfto6gy2kL+hRe6invQLcVFqxVEe56/IqE09cHh8uH9bpW1+1kgtqnxgM+bQl3ULobuX77vCXnDlW5ReRRd8mMwvWkCpzElKe3HP8WUgA= 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: Add set_ptes() and update_mmu_cache_range(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Gerald Schaefer Acked-by: Mike Rapoport (IBM) Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: Christian Borntraeger Cc: Sven Schnelle Cc: linux-s390@vger.kernel.org --- arch/s390/include/asm/pgtable.h | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index 30909fe27c24..d28d2e5e68ee 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -47,6 +47,7 @@ static inline void update_page_count(int level, long count) * tables contain all the necessary information. */ #define update_mmu_cache(vma, address, ptep) do { } while (0) +#define update_mmu_cache_range(vmf, vma, addr, ptep, nr) do { } while (0) #define update_mmu_cache_pmd(vma, address, ptep) do { } while (0) /* @@ -1314,20 +1315,34 @@ pgprot_t pgprot_writecombine(pgprot_t prot); pgprot_t pgprot_writethrough(pgprot_t prot); /* - * Certain architectures need to do special things when PTEs - * within a page table are directly modified. Thus, the following - * hook is made available. + * Set multiple PTEs to consecutive pages with a single call. All PTEs + * are within the same folio, PMD and VMA. */ -static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, - pte_t *ptep, pte_t entry) +static inline void set_ptes(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, pte_t entry, unsigned int nr) { if (pte_present(entry)) entry = clear_pte_bit(entry, __pgprot(_PAGE_UNUSED)); - if (mm_has_pgste(mm)) - ptep_set_pte_at(mm, addr, ptep, entry); - else - set_pte(ptep, entry); + if (mm_has_pgste(mm)) { + for (;;) { + ptep_set_pte_at(mm, addr, ptep, entry); + if (--nr == 0) + break; + ptep++; + entry = __pte(pte_val(entry) + PAGE_SIZE); + addr += PAGE_SIZE; + } + } else { + for (;;) { + set_pte(ptep, entry); + if (--nr == 0) + break; + ptep++; + entry = __pte(pte_val(entry) + PAGE_SIZE); + } + } } +#define set_ptes set_ptes /* * Conversion functions: convert a page and protection to a page entry,