From patchwork Tue Mar 5 07:21:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13581746 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 9339CC5478C for ; Tue, 5 Mar 2024 07:22:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 03BEE6B0089; Tue, 5 Mar 2024 02:22:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F2E836B008A; Tue, 5 Mar 2024 02:22:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF5796B008C; Tue, 5 Mar 2024 02:22:39 -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 CD2386B0089 for ; Tue, 5 Mar 2024 02:22:39 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A075FC0D1D for ; Tue, 5 Mar 2024 07:22:39 +0000 (UTC) X-FDA: 81862142838.02.92A0989 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf28.hostedemail.com (Postfix) with ESMTP id E713CC000A for ; Tue, 5 Mar 2024 07:22:36 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=BZD83fHg; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf28.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709623357; 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=o+H7ANhw43eaevV4VQX7czsRSYarXOXymV+NcuYFHLY=; b=HQfj6Dwfy7Hs8kzz22r49wDy2NbkxIl4JuxSPmwTTUk6KVT55FdIbTyu/G2qyJRCB1e7J6 uWwXbd1qQZvswKrUAOzIhHNLeoAIJ70cqT4thNLzwUYm0M+zGL3/DPGCBZRL0YLe0f8jrE IvOH0Tc0668toWCbzg+DULlCZ1+WZVM= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=BZD83fHg; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf28.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709623357; a=rsa-sha256; cv=none; b=u9DETt52u3rCGRpZKyWARCXPX+1j8QQmejh4BGeYskXgSNCWeSlxggUwX07aGV/1cLzVLR qENjdVoD7s/ivX3kE15zjJrHyLhZTrbe10BhDH6Ifv7PCmK7NvFh4oU1S11CNVjXafGevP cNgd4mPAXtbTlYmWglPyjDLvRjuKw7k= Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1dcf0d7dc8bso2566975ad.0 for ; Mon, 04 Mar 2024 23:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1709623355; x=1710228155; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o+H7ANhw43eaevV4VQX7czsRSYarXOXymV+NcuYFHLY=; b=BZD83fHgzDLFks4NRgCPUy9FhdciiQFj7+qL4oG+n5O/S+dpn58PBbMKfPVGek4rG/ uuktlDs7uURX7e1R8v/vcnspxTLWacrnX4LfW8owVhVRfMXq+iBLftfFwTqzrPhlgvex bgxnaIY8t962mv04FZ35OsmEvfkGQ8nIvuMNio8pYEjKRcx5ucey3/6TuQ9r3+X226pM xGDHEoW5d/WBcYEDNtalaxxfbiBB7IoqWkAJ37zKN/e8HD0MBtJqCtbjTyKszMHlWlWh 2d8XG1DJ8N0QWbP+sXOV50NOxLaFTtuTxekTmpl3pkyAcaEdE5GH9zIALx5hHXQyaLnN 8IhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709623355; x=1710228155; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o+H7ANhw43eaevV4VQX7czsRSYarXOXymV+NcuYFHLY=; b=jaqySSIjI4svcqRU+NK5AKmBTdVjxUrnfsE3E42tY+a1cog87K3hJZSRjCqVXe3Tib iliE3JMXhHv3dugFPa25wEB2/Jg5TXOs+A1ZRBIKVuYFbjfkgPmaCprGFU1kIrrV5ufF NcR0Ruhr0yQfFL+emF0ZEvNn1VoSChqZokAn2z7HScRoGf1mGuUPUmIzEl5nbRLhuEV7 qRsD0MLfG7FiJVOmpjJlW0JFhQylqxK3dR/xHk9fgmHFnDDa+08TIgEdZpxfmNyJP12L Z/hB/acbXLKsXqH1Kn06pIfePrPMb+dwNEJ98i9izrb23A9HjWLFXJdDKZroM2xZExF8 Gqgw== X-Gm-Message-State: AOJu0YzbQm9oyEXHnXPYhAOQfdoeHDgiwyn8nicB3UQOjf7miJMo4kXX 5PGxCUCAC+NilRfc8O6sOQoqZABHK7y57suFzBgqxZAxmAoqoOrveS/S/7dwkGM= X-Google-Smtp-Source: AGHT+IFhfT/2Pzoa8WqwNZ6N0I6kfte1nwbY/CAra5+bDDaMFCyRo5L5BBcrLvPLzeLCAHKbSkJItg== X-Received: by 2002:a17:902:d5cb:b0:1dc:51ac:88ef with SMTP id g11-20020a170902d5cb00b001dc51ac88efmr11752027plh.6.1709623355494; Mon, 04 Mar 2024 23:22:35 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.155]) by smtp.gmail.com with ESMTPSA id i11-20020a170902c94b00b001dcdf24e336sm8994818pla.47.2024.03.04.23.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 23:22:35 -0800 (PST) From: Qi Zheng To: akpm@linux-foundation.org, vishal.moola@gmail.com, hughd@google.com, david@redhat.com, rppt@kernel.org, willy@infradead.org, muchun.song@linux.dev Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v2 3/3] s390: supplement for ptdesc conversion Date: Tue, 5 Mar 2024 15:21:54 +0800 Message-Id: <20240305072154.26168-1-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <04beaf3255056ffe131a5ea595736066c1e84756.1709541697.git.zhengqi.arch@bytedance.com> References: <04beaf3255056ffe131a5ea595736066c1e84756.1709541697.git.zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: x9rf8n97iojojdc8u3b33wy5qic3knz7 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E713CC000A X-HE-Tag: 1709623356-793355 X-HE-Meta: U2FsdGVkX1/XRa5kEfVqw5E6DSJnejC8erQ5EvBE1ZZy3QcKB60m79WP6sn/fm5JK8RIGRP4Z4iCbY77CLo1N2frQpjYgZiottRJ4XpTE6yRQm/rnb3OuwteRYyuzfaDhv8HwISJypzIrG7qM9bsr1bkCqhXloHKiD/5KRNkqAyHfhU9m8c/PdDISt0sKEyk2yi1yjFmESdMTMXW1TwKpVx4qSUZUoEs7bGamWwggDepCCwP0NJfS7Q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2rlW1V7R8hp+7dgb8UAElR+UAr59x51NMP0EQbitBmwh8BIZrwlx/WgJeRyeG9J8YahENIFy7l1U007r4F5erzfCgJcYsIKCQklBS8pEs8/YRzdeqvAcwa7H+Vl0Qes+jFUQ7KbuXp0qDbYG2dDKK2kW93vQADAuIa/4bHP+TQgwBfxY7IqNWzkBqFNDAq1SWlmANO1ltRUZUKQHiTmU/rlt2uM/b6bST0Vx/49tXfjrOlfCGOWGCH+bZ7WUCBldxkKZZcKeQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: After commit 6326c26c1514 ("s390: convert various pgalloc functions to use ptdescs"), there are still some positions that use page->{lru, index} instead of ptdesc->{pt_list, pt_index}. In order to make the use of ptdesc->{pt_list, pt_index} clearer, it would be better to convert them as well. Signed-off-by: Qi Zheng Cc: Christian Borntraeger Cc: Janosch Frank Cc: Claudio Imbrenda Cc: David Hildenbrand Cc: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org --- v1 -> v2: fix build failure (cross compilation successful) arch/s390/include/asm/pgalloc.h | 4 ++-- arch/s390/mm/gmap.c | 38 +++++++++++++++++---------------- arch/s390/mm/pgalloc.c | 8 +++---- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/arch/s390/include/asm/pgalloc.h b/arch/s390/include/asm/pgalloc.h index 502d655fe6ae..7b84ef6dc4b6 100644 --- a/arch/s390/include/asm/pgalloc.h +++ b/arch/s390/include/asm/pgalloc.h @@ -23,9 +23,9 @@ unsigned long *crst_table_alloc(struct mm_struct *); void crst_table_free(struct mm_struct *, unsigned long *); unsigned long *page_table_alloc(struct mm_struct *); -struct page *page_table_alloc_pgste(struct mm_struct *mm); +struct ptdesc *page_table_alloc_pgste(struct mm_struct *mm); void page_table_free(struct mm_struct *, unsigned long *); -void page_table_free_pgste(struct page *page); +void page_table_free_pgste(struct ptdesc *ptdesc); extern int page_table_allocate_pgste; static inline void crst_table_init(unsigned long *crst, unsigned long entry) diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index 8da39deb56ca..e43a5a3befd4 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -206,9 +206,11 @@ static void gmap_free(struct gmap *gmap) /* Free additional data for a shadow gmap */ if (gmap_is_shadow(gmap)) { + struct ptdesc *ptdesc, *n; + /* Free all page tables. */ - list_for_each_entry_safe(page, next, &gmap->pt_list, lru) - page_table_free_pgste(page); + list_for_each_entry_safe(ptdesc, n, &gmap->pt_list, pt_list) + page_table_free_pgste(ptdesc); gmap_rmap_radix_tree_free(&gmap->host_to_rmap); /* Release reference to the parent */ gmap_put(gmap->parent); @@ -1348,7 +1350,7 @@ static void gmap_unshadow_pgt(struct gmap *sg, unsigned long raddr) { unsigned long *ste; phys_addr_t sto, pgt; - struct page *page; + struct ptdesc *ptdesc; BUG_ON(!gmap_is_shadow(sg)); ste = gmap_table_walk(sg, raddr, 1); /* get segment pointer */ @@ -1361,9 +1363,9 @@ static void gmap_unshadow_pgt(struct gmap *sg, unsigned long raddr) *ste = _SEGMENT_ENTRY_EMPTY; __gmap_unshadow_pgt(sg, raddr, __va(pgt)); /* Free page table */ - page = phys_to_page(pgt); - list_del(&page->lru); - page_table_free_pgste(page); + ptdesc = page_ptdesc(phys_to_page(pgt)); + list_del(&ptdesc->pt_list); + page_table_free_pgste(ptdesc); } /** @@ -1377,7 +1379,7 @@ static void gmap_unshadow_pgt(struct gmap *sg, unsigned long raddr) static void __gmap_unshadow_sgt(struct gmap *sg, unsigned long raddr, unsigned long *sgt) { - struct page *page; + struct ptdesc *ptdesc; phys_addr_t pgt; int i; @@ -1389,9 +1391,9 @@ static void __gmap_unshadow_sgt(struct gmap *sg, unsigned long raddr, sgt[i] = _SEGMENT_ENTRY_EMPTY; __gmap_unshadow_pgt(sg, raddr, __va(pgt)); /* Free page table */ - page = phys_to_page(pgt); - list_del(&page->lru); - page_table_free_pgste(page); + ptdesc = page_ptdesc(phys_to_page(pgt)); + list_del(&ptdesc->pt_list); + page_table_free_pgste(ptdesc); } } @@ -2058,19 +2060,19 @@ int gmap_shadow_pgt(struct gmap *sg, unsigned long saddr, unsigned long pgt, { unsigned long raddr, origin; unsigned long *table; - struct page *page; + struct ptdesc *ptdesc; phys_addr_t s_pgt; int rc; BUG_ON(!gmap_is_shadow(sg) || (pgt & _SEGMENT_ENTRY_LARGE)); /* Allocate a shadow page table */ - page = page_table_alloc_pgste(sg->mm); - if (!page) + ptdesc = page_table_alloc_pgste(sg->mm); + if (!ptdesc) return -ENOMEM; - page->index = pgt & _SEGMENT_ENTRY_ORIGIN; + ptdesc->pt_index = pgt & _SEGMENT_ENTRY_ORIGIN; if (fake) - page->index |= GMAP_SHADOW_FAKE_TABLE; - s_pgt = page_to_phys(page); + ptdesc->pt_index |= GMAP_SHADOW_FAKE_TABLE; + s_pgt = page_to_phys(ptdesc_page(ptdesc)); /* Install shadow page table */ spin_lock(&sg->guest_table_lock); table = gmap_table_walk(sg, saddr, 1); /* get segment pointer */ @@ -2088,7 +2090,7 @@ int gmap_shadow_pgt(struct gmap *sg, unsigned long saddr, unsigned long pgt, /* mark as invalid as long as the parent table is not protected */ *table = (unsigned long) s_pgt | _SEGMENT_ENTRY | (pgt & _SEGMENT_ENTRY_PROTECT) | _SEGMENT_ENTRY_INVALID; - list_add(&page->lru, &sg->pt_list); + list_add(&ptdesc->pt_list, &sg->pt_list); if (fake) { /* nothing to protect for fake tables */ *table &= ~_SEGMENT_ENTRY_INVALID; @@ -2114,7 +2116,7 @@ int gmap_shadow_pgt(struct gmap *sg, unsigned long saddr, unsigned long pgt, return rc; out_free: spin_unlock(&sg->guest_table_lock); - page_table_free_pgste(page); + page_table_free_pgste(ptdesc); return rc; } diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c index 008e487c94a6..abb629d7e131 100644 --- a/arch/s390/mm/pgalloc.c +++ b/arch/s390/mm/pgalloc.c @@ -135,7 +135,7 @@ int crst_table_upgrade(struct mm_struct *mm, unsigned long end) #ifdef CONFIG_PGSTE -struct page *page_table_alloc_pgste(struct mm_struct *mm) +struct ptdesc *page_table_alloc_pgste(struct mm_struct *mm) { struct ptdesc *ptdesc; u64 *table; @@ -147,12 +147,12 @@ struct page *page_table_alloc_pgste(struct mm_struct *mm) memset64(table, _PAGE_INVALID, PTRS_PER_PTE); memset64(table + PTRS_PER_PTE, 0, PTRS_PER_PTE); } - return ptdesc_page(ptdesc); + return ptdesc; } -void page_table_free_pgste(struct page *page) +void page_table_free_pgste(struct ptdesc *ptdesc) { - pagetable_free(page_ptdesc(page)); + pagetable_free(ptdesc); } #endif /* CONFIG_PGSTE */