From patchwork Tue Nov 8 19:41:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Torvalds X-Patchwork-Id: 13036780 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 53B3BC433FE for ; Tue, 8 Nov 2022 19:41:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C24B38E0002; Tue, 8 Nov 2022 14:41:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BAD938E0001; Tue, 8 Nov 2022 14:41:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9C938E0002; Tue, 8 Nov 2022 14:41:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 9BD578E0001 for ; Tue, 8 Nov 2022 14:41:42 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 651B51411E4 for ; Tue, 8 Nov 2022 19:41:42 +0000 (UTC) X-FDA: 80111294844.27.DFA6015 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id 106A5C0007 for ; Tue, 8 Nov 2022 19:41:41 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 672A861777; Tue, 8 Nov 2022 19:41:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C42FAC433B5; Tue, 8 Nov 2022 19:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1667936501; bh=KtnZVT0YbwzWMG53hT3URF7/oRWr49RGvTuDrC8WUTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Puc8twx3+crexM3+XlAfoAfXJdSqnXG5mTkZTE+eK9SWgd99KLHzzfjSjbwlSR9rG vIvyljiUS7yb8ThC0QbXeHTUFZEce/ro/TougawWiPy/s00uFg52Nlje34u8jvC+9q toltFhsioCZg7qZXVfUpy2pFWEDN+3iUD9ECCCus= From: Linus Torvalds To: Hugh Dickins , Johannes Weiner , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/4] mm: mmu_gather: prepare to gather encoded page pointers with flags Date: Tue, 8 Nov 2022 11:41:38 -0800 Message-Id: <20221108194139.57604-3-torvalds@linux-foundation.org> X-Mailer: git-send-email 2.38.1.284.gfd9468d787 In-Reply-To: References: MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667936502; a=rsa-sha256; cv=none; b=f9g1oaoco+rGb+rKYf3oRntgYQ1koUYooDOpZjzE99VjaRcectRF42CD3yviir8QCDOv/u AQj4UegtpArdtrYAz1lvXX6cA8z+P6fFOC5JVhU2oEOR79UGc9fUKFyVjIqIzdMhWnbpGA kScLZt4NXMtnhegnXprH3KkeCgTV7ys= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=Puc8twx3; spf=pass (imf10.hostedemail.com: domain of torvalds@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=torvalds@linux-foundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667936502; 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=0U8h3wXAFvQjOZ2F23Z8+zJsbCg1m8KawRjv1q819mw=; b=PlSqfD+BhRFAzModIKZMvuQ8NPwGOlVRUlR7oETviXPnUi+PqFJM8m+hKWqgT0gbTVDzjg evp0WyudCYM86GnwYgEe9nQotUwupBM5WBpHHYwlJeqJ0eLb4/tKoaZnVP5ecIJfhL2Nw2 HPB55rxYAxhnsfYCZUh3KwP1QAuThKM= Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=Puc8twx3; spf=pass (imf10.hostedemail.com: domain of torvalds@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=torvalds@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: m37w7m6x6t1wj58oqdd3jzp5n66ey6xr X-Rspamd-Queue-Id: 106A5C0007 X-HE-Tag: 1667936501-945541 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 is purely a preparatory patch that makes all the data structures ready for encoding flags with the mmu_gather page pointers. The code currently always sets the flag to zero and doesn't use it yet, but now it's tracking the type state along. The next step will be to actually start using it. Signed-off-by: Linus Torvalds --- include/asm-generic/tlb.h | 2 +- include/linux/swap.h | 2 +- mm/mmu_gather.c | 4 ++-- mm/swap_state.c | 11 ++++------- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index 492dce43236e..faca23e87278 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -242,7 +242,7 @@ struct mmu_gather_batch { struct mmu_gather_batch *next; unsigned int nr; unsigned int max; - struct page *pages[]; + struct encoded_page *encoded_pages[]; }; #define MAX_GATHER_BATCH \ diff --git a/include/linux/swap.h b/include/linux/swap.h index a18cf4b7c724..40e418e3461b 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -470,7 +470,7 @@ static inline unsigned long total_swapcache_pages(void) extern void free_swap_cache(struct page *page); extern void free_page_and_swap_cache(struct page *); -extern void free_pages_and_swap_cache(struct page **, int); +extern void free_pages_and_swap_cache(struct encoded_page **, int); /* linux/mm/swapfile.c */ extern atomic_long_t nr_swap_pages; extern long total_swap_pages; diff --git a/mm/mmu_gather.c b/mm/mmu_gather.c index add4244e5790..57b7850c1b5e 100644 --- a/mm/mmu_gather.c +++ b/mm/mmu_gather.c @@ -48,7 +48,7 @@ static void tlb_batch_pages_flush(struct mmu_gather *tlb) struct mmu_gather_batch *batch; for (batch = &tlb->local; batch && batch->nr; batch = batch->next) { - struct page **pages = batch->pages; + struct encoded_page **pages = batch->encoded_pages; do { /* @@ -92,7 +92,7 @@ bool __tlb_remove_page_size(struct mmu_gather *tlb, struct page *page, int page_ * Add the page and check if we are full. If so * force a flush. */ - batch->pages[batch->nr++] = page; + batch->encoded_pages[batch->nr++] = encode_page(page, 0); if (batch->nr == batch->max) { if (!tlb_next_batch(tlb)) return true; diff --git a/mm/swap_state.c b/mm/swap_state.c index 438d0676c5be..8bf08c313872 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -303,15 +303,12 @@ void free_page_and_swap_cache(struct page *page) * Passed an array of pages, drop them all from swapcache and then release * them. They are removed from the LRU and freed if this is their last use. */ -void free_pages_and_swap_cache(struct page **pages, int nr) +void free_pages_and_swap_cache(struct encoded_page **pages, int nr) { - struct page **pagep = pages; - int i; - lru_add_drain(); - for (i = 0; i < nr; i++) - free_swap_cache(pagep[i]); - release_pages(pagep, nr); + for (int i = 0; i < nr; i++) + free_swap_cache(encoded_page_ptr(pages[i])); + release_pages(pages, nr); } static inline bool swap_use_vma_readahead(void)