From patchwork Fri Jan 13 17:10:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13101207 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 904BCC3DA78 for ; Fri, 13 Jan 2023 17:12:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FD678E0005; Fri, 13 Jan 2023 12:12:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 286A58E0002; Fri, 13 Jan 2023 12:12:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 100E38E0005; Fri, 13 Jan 2023 12:12:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id F19CC8E0002 for ; Fri, 13 Jan 2023 12:12:33 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C12A01A0DED for ; Fri, 13 Jan 2023 17:12:33 +0000 (UTC) X-FDA: 80350419786.10.0165A9F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 160E61A0022 for ; Fri, 13 Jan 2023 17:12:31 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ifJlVlOt; spf=pass (imf19.hostedemail.com: domain of david@redhat.com designates 170.10.133.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=1673629952; 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=EeU2y0OYHKgx8U/PANyBx/2XuleLv4VIrJJxaFNmqf8=; b=m+WtkOcJ6dGk/oG1Nmcnp/+xLl1mR0vnasWfze6Z99nZ+1GVdXF824m4Y7/sYnak8wHndo vVZek6Rj9PigCQsL74HPEZBBXgb5GqkQe/wQ2a0dZ8Z9Ref8GQCta3vfAflnqdHzE0fC9M CJi1Wdjl4ri41zmpfmwVBg+/uOa3b9k= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ifJlVlOt; spf=pass (imf19.hostedemail.com: domain of david@redhat.com designates 170.10.133.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=1673629952; a=rsa-sha256; cv=none; b=pCf9OMfwiaSDW0vKC9FM5ML45oDT1+Qtfo7Uao+zRAqQWvkOn6Hg2Rx3OmUjkxlAp8Zx6d A6KshDJXEHh8OxIqvbrTBtfd5MJICW4oMFuuiuwS0m3lazq4BGVJLGYUP3Q+zVu3b3h1/e 82O1d6xxdnOqVTRSeMjUl0ee99SCIF4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673629951; 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=EeU2y0OYHKgx8U/PANyBx/2XuleLv4VIrJJxaFNmqf8=; b=ifJlVlOtafhuq4YxSiYiqai8GICQSYOjICBFb2KDT7Y4PgRk3wXvZdIGR7j0GDN88g4DaC dLj3hNBSVmviUan6VmvIpkVcNzSVnMxLT5T5aPcEIqcBRu5/xS07LzIeRnDZqJpfAftDKI O+2OVc9CaXIRfYedjkWYVl33qX3uQZk= 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-86-oCTSLD83Ooa0ioE_-N0TXQ-1; Fri, 13 Jan 2023 12:12:26 -0500 X-MC-Unique: oCTSLD83Ooa0ioE_-N0TXQ-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 93ED685A588; Fri, 13 Jan 2023 17:12:24 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.193.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF76240C2005; Fri, 13 Jan 2023 17:12:17 +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 , Thomas Bogendoerfer Subject: [PATCH mm-unstable v1 14/26] nios2/mm: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE Date: Fri, 13 Jan 2023 18:10:14 +0100 Message-Id: <20230113171026.582290-15-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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 160E61A0022 X-Stat-Signature: hqj9hamstyyqxqow5c8zs59rt3uitkmt X-Rspam-User: X-HE-Tag: 1673629951-983886 X-HE-Meta: U2FsdGVkX18j3zaHL75+G9c9YDpDWU0OAUJL1poAaA7Dy7GUq8VL9mJ3NwDcKm0kUoOyUlNHXvuCuHdM8PNds1+KMAURBRyMbSldo6igTWuCBAIhqjrVa0mMHmxvCoOV7VBEe2IZnrdOnnn96IlsYKDCjLwwaUzJSAVDGKDStZ7lan089smMkxPsgf312EVpqzPG3uCUuXKZjEEuMlGRiCU3ShNEMPgc7i126xBHnEhx6ORh6BY18SCDMTKXWhJ628NXIRQN0hL+QpZ973zZTKo+nxJ6iYLSeflM78yzmlrY2w1biDg3Xm3ANd+gziflRTf4uZkYJi7fxGsqcwB0bTwDZ3TCs9ELVWvb1ODA6dxFO8LXBU6tYrRR7UqYHpOiit9PMNvEp3fOsetzkBD2QHi5MogNOkZ9szFfF8/tMwcXnYWxzGbhbZuQBV4mZF9FhsQG/n0HryISBm/ubpaWpN82zJnKRz38SJSlUJaNb64fBeafWeCTSWG6Eho5K/iOvycIc9NrhFZpMf/rzVQr44CV2NgGJZSrk0v0Fn/TT8Xm+rADcg+WlW7ZvobFLhvOsBeuV7uG4gstcDhYZXoBmFxauCsCJ9I/UOARXs2MHqMQl6g/kRjjabAP1D/G+OtZjw+kdJSQIwLB6gQENR6mJwh2jl/3bHlehaMAKtiUUFlxab5vfRz+lHrMPb2Sspgw970ex2Vla3Jvm7fl7/uvy5ug2N7Mkw/FjMbXJvDMToZmvsZCSVVNWSSpav6hk+WE19DOszPG24QTXbAN2xp/JuF+OdwJYKavhJ3Ko2XQR77KuWZ7tCG5eSxsXlKCStjpI4GewUdvpY1a+QvE0WlVEfepZTp5JV/7VKLHRvOQeMsYzRmR7GY8LYReAo4RWnVGDjjIchMzp6kIX4B0mHBwr+rGmM4osm55/bRKWWMPATo9cpoBOorO6tC+1NdrOxpT9CxHDSH2D+55wDViwwY oL9ja+uk Z1coO7fZfXuwcO9d1rMMUsqLTyYqJAl8VcNjv 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 using the yet-unused bit 31. Cc: Thomas Bogendoerfer Signed-off-by: David Hildenbrand --- arch/nios2/include/asm/pgtable-bits.h | 3 +++ arch/nios2/include/asm/pgtable.h | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/arch/nios2/include/asm/pgtable-bits.h b/arch/nios2/include/asm/pgtable-bits.h index bfddff383e89..724f9b08b1d1 100644 --- a/arch/nios2/include/asm/pgtable-bits.h +++ b/arch/nios2/include/asm/pgtable-bits.h @@ -31,4 +31,7 @@ #define _PAGE_ACCESSED (1<<26) /* page referenced */ #define _PAGE_DIRTY (1<<27) /* dirty page */ +/* We borrow bit 31 to store the exclusive marker in swap PTEs. */ +#define _PAGE_SWP_EXCLUSIVE (1<<31) + #endif /* _ASM_NIOS2_PGTABLE_BITS_H */ diff --git a/arch/nios2/include/asm/pgtable.h b/arch/nios2/include/asm/pgtable.h index d1e5c9eb4643..05999da01731 100644 --- a/arch/nios2/include/asm/pgtable.h +++ b/arch/nios2/include/asm/pgtable.h @@ -239,7 +239,9 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) * * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 - * 0 < type -> 0 0 0 0 0 0 <-------------- offset ---------------> + * E < type -> 0 0 0 0 0 0 <-------------- offset ---------------> + * + * E is the exclusive marker that is not stored in swap entries. * * Note that the offset field is always non-zero if the swap type is 0, thus * !pte_none() is always true. @@ -251,6 +253,24 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) #define __swp_entry_to_pte(swp) ((pte_t) { (swp).val }) #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) +#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; +} + extern void __init paging_init(void); extern void __init mmu_init(void);