From patchwork Mon Aug 21 16:08:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13359617 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 657BFEE4993 for ; Mon, 21 Aug 2023 16:09:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECFA88E0006; Mon, 21 Aug 2023 12:09:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E7FA88E0002; Mon, 21 Aug 2023 12:09:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF82F8E0006; Mon, 21 Aug 2023 12:09:07 -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 B752E8E0002 for ; Mon, 21 Aug 2023 12:09:07 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 87DCFB19B7 for ; Mon, 21 Aug 2023 16:09:07 +0000 (UTC) X-FDA: 81148595934.23.F8A5009 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 3675040028 for ; Mon, 21 Aug 2023 16:09:05 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jC3lEYgi; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692634145; 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=oXgxSUiHlACYEZ8/tewWc2FJCrUF3dBlQ9Skg2Bh23k=; b=8VPzAzVDhvS1AjWaYsdniit0ePGbYrG/gIWdklM0tbHidWaRp/w2HWqUrMM2oRASNx6q/T xlJQ2ipoHA44LOGEIOgfUqDwbMaBXDEzTvZMlyHIbSZ9/077pi9g0j2V6IsqoZbJjiQlhH tsSThsFizYpaPf0uavYYb6tiR8JsdsM= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jC3lEYgi; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692634145; a=rsa-sha256; cv=none; b=p+7eLrhkvffzT/iXn4qNm4AHbMLlwwWmoVzRdx8c1P49GtktyUdy3MdKYquHowUuoclpC5 WMM1q28B4x+ORfrfBOaEZILd/2qqvOkMlKYYDX16T5TSXYvKWk89rNk11pUWBSaIIhd90F gd5xY95/tLX36b0om9f4rgghWuWNPyI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692634144; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oXgxSUiHlACYEZ8/tewWc2FJCrUF3dBlQ9Skg2Bh23k=; b=jC3lEYgidJpd+7Bhb6sAw7iUUGBKjzK6BePX3APWMLxaQ3+5+YspYU9t9ru8F5d+QpnQNB cs5kCjDv9xKLY5MSmOSVQAhHI9UUIv1u2kmSbwOu+TJsA8yNbi2E8pUJzTQHk6iBZGEXTp vIBcg4H6S8LwZkHBLAwAPt9bzppn+Ps= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-312-gUGvI0rJOSu3AbVA6NUL9A-1; Mon, 21 Aug 2023 12:09:01 -0400 X-MC-Unique: gUGvI0rJOSu3AbVA6NUL9A-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 807BE3C11A04; Mon, 21 Aug 2023 16:08:59 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.184]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EBE9492C13; Mon, 21 Aug 2023 16:08:56 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Peter Xu , Catalin Marinas , Will Deacon , Hugh Dickins , Seth Jennings , Dan Streetman , Vitaly Wool Subject: [PATCH mm-unstable v1 2/4] mm/swap: use dedicated entry for swap in folio Date: Mon, 21 Aug 2023 18:08:47 +0200 Message-ID: <20230821160849.531668-3-david@redhat.com> In-Reply-To: <20230821160849.531668-1-david@redhat.com> References: <20230821160849.531668-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 3675040028 X-Stat-Signature: jbifaypxperfg3z8xje6gs37mkg359u7 X-HE-Tag: 1692634145-883988 X-HE-Meta: U2FsdGVkX19lktyIC/bL8NkYMAXNgNizNY1HDLUuHT4tD83MHykZiQwbqCwIdigWo/QzbsBnyAUG/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pF+TE1oFUxqk1BcVxa8HxanR/cYiTdWUT0Nt7sQZGdwzwmGg1YH10H5FMKn3F7yO7oHM= 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: From: Matthew Wilcox Let's stop working on the private field and use an explicit swap field. We have to move the swp_entry_t typedef. Signed-off-by: Matthew Wilcox Signed-off-by: David Hildenbrand Reviewed-by: Chris Li --- include/linux/mm_types.h | 23 +++++++++++++---------- include/linux/swap.h | 5 ++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 61361f1750c3..438a07854f8c 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -259,6 +259,14 @@ static inline struct page *encoded_page_ptr(struct encoded_page *page) */ #define TAIL_MAPPING_REUSED_MAX (2) +/* + * A swap entry has to fit into a "unsigned long", as the entry is hidden + * in the "index" field of the swapper address space. + */ +typedef struct { + unsigned long val; +} swp_entry_t; + /** * struct folio - Represents a contiguous set of bytes. * @flags: Identical to the page flags. @@ -269,7 +277,7 @@ static inline struct page *encoded_page_ptr(struct encoded_page *page) * @index: Offset within the file, in units of pages. For anonymous memory, * this is the index from the beginning of the mmap. * @private: Filesystem per-folio data (see folio_attach_private()). - * Used for swp_entry_t if folio_test_swapcache(). + * @swap: Used for swp_entry_t if folio_test_swapcache(). * @_mapcount: Do not access this member directly. Use folio_mapcount() to * find out how many times this folio is mapped by userspace. * @_refcount: Do not access this member directly. Use folio_ref_count() @@ -312,7 +320,10 @@ struct folio { }; struct address_space *mapping; pgoff_t index; - void *private; + union { + void *private; + swp_entry_t swap; + }; atomic_t _mapcount; atomic_t _refcount; #ifdef CONFIG_MEMCG @@ -1220,14 +1231,6 @@ enum tlb_flush_reason { NR_TLB_FLUSH_REASONS, }; - /* - * A swap entry has to fit into a "unsigned long", as the entry is hidden - * in the "index" field of the swapper address space. - */ -typedef struct { - unsigned long val; -} swp_entry_t; - /** * enum fault_flag - Fault flag definitions. * @FAULT_FLAG_WRITE: Fault was a write fault. diff --git a/include/linux/swap.h b/include/linux/swap.h index 84fe0e94f5cd..82859a1944f5 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -335,8 +335,7 @@ struct swap_info_struct { static inline swp_entry_t folio_swap_entry(struct folio *folio) { - swp_entry_t entry = { .val = page_private(&folio->page) }; - return entry; + return folio->swap; } static inline swp_entry_t page_swap_entry(struct page *page) @@ -350,7 +349,7 @@ static inline swp_entry_t page_swap_entry(struct page *page) static inline void folio_set_swap_entry(struct folio *folio, swp_entry_t entry) { - folio->private = (void *)entry.val; + folio->swap = entry; } /* linux/mm/workingset.c */