From patchwork Mon Jul 10 20:43:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 118103 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp75181vqm; Mon, 10 Jul 2023 14:12:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlEdUJjnWxpzkQ676AOfTbWgw8km3m96tqwgOwvBgk56ZFj98lF7y8Vi4dMlEaU134oIGuvL X-Received: by 2002:a17:903:41c2:b0:1b8:8728:d776 with SMTP id u2-20020a17090341c200b001b88728d776mr23692119ple.0.1689023563653; Mon, 10 Jul 2023 14:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689023563; cv=none; d=google.com; s=arc-20160816; b=ZZoEHzGEN1IxAuxy/X1eUfL3nS2NL23vTl1wonVkOFUKJrmKBH+Y8u8yOl5o3mn21K B7JuFwPTe8Vcx+j/aXXNm+FeSutV+iiOlYPA0BnwEU20JjTAFaIOnRRDrF95HocPStv7 UDxXcRSW9nq8JW/GSZMJI1+EIlN82k3QkWQcpGlokk6zsUQ1dpKcwbCeznvYWGk3gg0Q 9J/mJYGQlJV0GGthiIsCGRIFK0buTBKea2Vewr+Cw81yoL1OVjtCTqJ3SafEARIkhqtk WZ0o3JlVcJYMbGGfSKBFqHRg8HeVaCJHSbFkKaodzvJO6/1JilBCid+CPeCCHIlpbKHF bqOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9mxVcCkW583JrlzbOMVQaZnB0bjf4NUO5YrFMq87KVA=; fh=aOM6241f6jxAbyEFQMMJAXRCR7/Qw+WS0LOuDz3zGIc=; b=qBHKB3s2TSQpTtYCLY3flxxL6Y9hYZG7WjcrMY/oJwfGAG+y6568GKUR3oauloA8Mi tl/RIOpUDi6hoHq6Sb6/zAYkTy6fLdOIel6rioTfrNxMmf7cHUvxC/eSnrv/kbbEby8P +/umLXdaKDwlQd5jnoP92TVRqfHkPTdeuqBRv2ZDe29vNUBnuKLz2vS6JdFmkQxylJh2 kbKy/+sDqXWNpAAlrs/BXgkJeX+Ai/U0u32siz6KjulN76IWRvHfTmyINzFz3xNJIe5b GdHujKQ3INdawVu8j7JdE26L1Ywnq0ASWN/A16kw0A72tFXcw4EzjcxVqXQiu3aQ4ffA /mPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=tiHU73Gt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ik28-20020a170902ab1c00b001b8b3f8ed8bsi348519plb.424.2023.07.10.14.12.31; Mon, 10 Jul 2023 14:12:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=tiHU73Gt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230265AbjGJUpJ (ORCPT + 99 others); Mon, 10 Jul 2023 16:45:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232319AbjGJUoE (ORCPT ); Mon, 10 Jul 2023 16:44:04 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02645E5D; Mon, 10 Jul 2023 13:43:45 -0700 (PDT) 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=9mxVcCkW583JrlzbOMVQaZnB0bjf4NUO5YrFMq87KVA=; b=tiHU73GtBk0CdV4R8NECb7nrWG rlw/hDC8XD9b2zjAZwna48outBRoVxu2IWG4ZicdNlUuRYBDKZRUemkoPgiXlrkf0kVB/sx3qjfs0 KkxCLgeBb0dGeLCejf0eJpZyZUb0QAlMhBZF+E3fcYghEbOccZYeYRtjGSz0QvTXnX52XdAJw1TXs dD9qFxvpT4uZslcdHGUINiZkGgdG7bUfWf+eV3k8ld7aPrcsNPTW5Ce0qlVAzV58FK0Y85gBRJU9t +h+io5vedYA2iPQhdC9XJcsDOkWmkXsYFq638vvxWop58dOIBFBXxPiLMZOQ82sbNU0OuAiljU1om x2DyixKQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qIxjT-00EuqC-Se; Mon, 10 Jul 2023 20:43:43 +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 v5 23/38] s390: Implement the new page table range API Date: Mon, 10 Jul 2023 21:43:24 +0100 Message-Id: <20230710204339.3554919-24-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230710204339.3554919-1-willy@infradead.org> References: <20230710204339.3554919-1-willy@infradead.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771069572314161612 X-GMAIL-MSGID: 1771069572314161612 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 c55f3c3365af..02973c740a5b 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) /* @@ -1316,20 +1317,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,