From patchwork Fri Jan 13 17:10:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13101200 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 3CB3DC3DA78 for ; Fri, 13 Jan 2023 17:11:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE8EB900007; Fri, 13 Jan 2023 12:11:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C725C900006; Fri, 13 Jan 2023 12:11:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEC10900007; Fri, 13 Jan 2023 12:11:41 -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 9E448900006 for ; Fri, 13 Jan 2023 12:11:41 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 82106120C9F for ; Fri, 13 Jan 2023 17:11:41 +0000 (UTC) X-FDA: 80350417602.28.DE0FB9F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id EECF4180017 for ; Fri, 13 Jan 2023 17:11:39 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SLrWrxVm; spf=pass (imf24.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673629900; 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=aoWiVle2vALbm81f87GqQxp1lNDAFbpV4WpvPll4VZk=; b=URiO4UNosjeF2EWEZIMnq6ydQVII7eZLxGkqUeSVHEZdMHW66zAU65tjgA4w7nuTW26GB9 rLe0G0oA/RXoGZkkzQG264Vel8hp/B5vMiR4RU//UlZbfwV2jwubsQ0SIRE6UOuXlV/XT7 HA/xw5M503se3QmGsy7Im0uVvIIIH0c= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SLrWrxVm; spf=pass (imf24.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673629900; a=rsa-sha256; cv=none; b=RMHqrsMeSSGorr1yRMJA/59M6tbqU3hx+QkxjdS4HWeE/KuUhfTpUC0KXWu6VR5vL/292S YmjZTDkfNEq7dt3/cC9jSpjU8HVZdAO8fPK+EFGKubGPN5QgEYSQKuKOq/TAAwh+CGnnpv fI5Dr5lYCx9zSV9NQzvsW05Nxyht7lQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673629899; 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=aoWiVle2vALbm81f87GqQxp1lNDAFbpV4WpvPll4VZk=; b=SLrWrxVmP5LVjot99SUR3ProFdEdpmF1Oc4XSTuyR63CyayNN3622+6gXh/tKYDJE2cI8b ydgGD8A4xhvef1xmXNJdPFD/NnG9+VixclpwIjk/siO2D0eoAxvvxgj0SjQ1tqYU1sbMlK HJqoq0aCEd59cD4TnhNbaYbqdIFfCGE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-527-rdVTI0nvPQSRFri4XAJDbA-1; Fri, 13 Jan 2023 12:11:36 -0500 X-MC-Unique: rdVTI0nvPQSRFri4XAJDbA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 82DD1101B42B; Fri, 13 Jan 2023 17:11:34 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.193.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4259640C2064; Fri, 13 Jan 2023 17:11:27 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: Andrew Morton , Hugh Dickins , John Hubbard , Jason Gunthorpe , Mike Rapoport , Yang Shi , Vlastimil Babka , Nadav Amit , Andrea Arcangeli , Peter Xu , linux-mm@kvack.org, x86@kernel.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, linux-xtensa@linux-xtensa.org, David Hildenbrand Subject: [PATCH mm-unstable v1 07/26] ia64/mm: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE Date: Fri, 13 Jan 2023 18:10:07 +0100 Message-Id: <20230113171026.582290-8-david@redhat.com> In-Reply-To: <20230113171026.582290-1-david@redhat.com> References: <20230113171026.582290-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 8ak8mtaf1pq8fhuuzkczzdzptp3c8a1h X-Rspamd-Queue-Id: EECF4180017 X-HE-Tag: 1673629899-33922 X-HE-Meta: U2FsdGVkX1+NIID8TChiNikh0KwybBhKSY3/cZIStFDEwCLPkBJTnMHhHp2ZHRplcMCv/0T2g85t053/lDBl4KkOPKuUGInOuQ9ftofXumfSBzZE98+mu/odNqAKJQ9xU6o+7rbV8qYUmxqfYJ0zF2W1nIop1/iKQV+J+t0yC9zTPBvdnhNc6esVGC48SyN3eLl+yH/kyW21tDYfXL4q3sb/zKqQP7Oqcoz5/K1/v0Q5rAOfJVTcFEtsweqQ5hfiAaDG+fSbAvIHD03VCAOTSyT/lPRFwL0mVda3DtNkLDewrsI9mduXmt+V7UF6nA+k6uLJU8Rjh/yNLVY8Hn6E6pgWDrj3cuQODfkOQTRdsoVkfGkFz7JIXbAQS2AeHW5p1XwIgr7l/GiLRXNuXahb+QOlO8OVDgOm2Te09mvHWiCmAujdpNxcxhsr/jyfL1ORELV4rSb7oktx27ucIVga3ahSZ3dRXwvBLjb900BzRVyZE1jvuAzKsMg5n5GlY5NTE95c8AgQX/a4oDiAmbT4Dl14EJFTLME+9ufnEbVzrc772QtFHoNo7bQsZoDCcYiFNNzxVbsaa2TtWtYXW+I2z8j/dknkmWKb+dKllCu3Dl9zWTm7+Xhjn/+F1JbHY8VA2PJ9Gp9Ngi35AhRJqAczCp0K1PamABZxx7HMXMIAuq3ZmksXCjh1k99TPRo4DhT+ZxJ14lQlLSgxKZU+uYASXveUgxU1oo+4YkCLYHs8x6kU3pZSEuJDP95KzwNB0n34K4gQ/S08zyEoAr5ia8nTlJ/ajhJGxYTM7i7i48+HfqxoHMPNvKlF8+TS/G9BhCQRTG5WnsGxBHZ6joYqQpKIg7vqpzg30XkE4mYVJI8DjCRvVmf0TVQI2SmeTLOGAuB8IiS7YxHu28m4GrZ6a5kZDDj9j10nZZJwDaf6iMsd4JeZIeQ90puC4V9AqKH+M8MPIZawQfP/B9bd0x61E6C ou26GTpz oYfD9b/QsxporNRfZRIILU6L/zjExuLhJrq05 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: Let's support __HAVE_ARCH_PTE_SWP_EXCLUSIVE by stealing one bit from the type. Generic MM currently only uses 5 bits for the type (MAX_SWAPFILES_SHIFT), so the stolen bit is effectively unused. While at it, also mask the type in __swp_entry(). Signed-off-by: David Hildenbrand --- arch/ia64/include/asm/pgtable.h | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h index 01517a5e6778..e4b8ab931399 100644 --- a/arch/ia64/include/asm/pgtable.h +++ b/arch/ia64/include/asm/pgtable.h @@ -58,6 +58,9 @@ #define _PAGE_ED (__IA64_UL(1) << 52) /* exception deferral */ #define _PAGE_PROTNONE (__IA64_UL(1) << 63) +/* We borrow bit 7 to store the exclusive marker in swap PTEs. */ +#define _PAGE_SWP_EXCLUSIVE (1 << 7) + #define _PFN_MASK _PAGE_PPN_MASK /* Mask of bits which may be changed by pte_modify(); the odd bits are there for _PAGE_PROTNONE */ #define _PAGE_CHG_MASK (_PAGE_P | _PAGE_PROTNONE | _PAGE_PL_MASK | _PAGE_AR_MASK | _PAGE_ED) @@ -399,6 +402,9 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; extern void paging_init (void); /* + * Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that + * are !pte_none() && !pte_present(). + * * Note: The macros below rely on the fact that MAX_SWAPFILES_SHIFT <= number of * bits in the swap-type field of the swap pte. It would be nice to * enforce that, but we can't easily include here. @@ -406,16 +412,36 @@ extern void paging_init (void); * * Format of swap pte: * bit 0 : present bit (must be zero) - * bits 1- 7: swap-type + * bits 1- 6: swap type + * bit 7 : exclusive marker * bits 8-62: swap offset * bit 63 : _PAGE_PROTNONE bit */ -#define __swp_type(entry) (((entry).val >> 1) & 0x7f) +#define __swp_type(entry) (((entry).val >> 1) & 0x3f) #define __swp_offset(entry) (((entry).val << 1) >> 9) -#define __swp_entry(type,offset) ((swp_entry_t) { ((type) << 1) | ((long) (offset) << 8) }) +#define __swp_entry(type, offset) ((swp_entry_t) { ((type & 0x3f) << 1) | \ + ((long) (offset) << 8) }) #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) +#define __HAVE_ARCH_PTE_SWP_EXCLUSIVE +static inline int pte_swp_exclusive(pte_t pte) +{ + return pte_val(pte) & _PAGE_SWP_EXCLUSIVE; +} + +static inline pte_t pte_swp_mkexclusive(pte_t pte) +{ + pte_val(pte) |= _PAGE_SWP_EXCLUSIVE; + return pte; +} + +static inline pte_t pte_swp_clear_exclusive(pte_t pte) +{ + pte_val(pte) &= ~_PAGE_SWP_EXCLUSIVE; + return pte; +} + /* * ZERO_PAGE is a global shared page that is always zero: used * for zero-mapped memory areas etc..