From patchwork Fri Jan 13 17:10:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13101196 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 D882CC3DA78 for ; Fri, 13 Jan 2023 17:11:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4373A900003; Fri, 13 Jan 2023 12:11:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E6A38E0001; Fri, 13 Jan 2023 12:11:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AF85900003; Fri, 13 Jan 2023 12:11:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1D0308E0001 for ; Fri, 13 Jan 2023 12:11:13 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DA172AAD68 for ; Fri, 13 Jan 2023 17:11:12 +0000 (UTC) X-FDA: 80350416384.28.7DFA1F9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 42829120008 for ; Fri, 13 Jan 2023 17:11:11 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MNvhqfWv; spf=pass (imf29.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=1673629871; 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=CsZI6CBJjkMgqSDB0pNEUq6oiZDvtrxY4s2APwPC8ec=; b=4OcnQz5z9LrC4UpejLcVjfRRiG0/g/Xqa47IOuT5lKqSFVZWVvw4blayR+UVdR07SRhUeo d2fpEO9NWk3U2lW7lRf6BTkit+foeLpXEepCbrca9OclnTSgXsIScTOybmQYv03KFASBBu qIlZWdsW1pR8ohT9YIaZ+V3rF9JMHAY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MNvhqfWv; spf=pass (imf29.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=1673629871; a=rsa-sha256; cv=none; b=8Fa24fQnMhmONY+GuQzZF4/muLKu8XE231u8r2err6mj6eapDHIElcpxLEsJJz9tUFDxOs ZIYlx+Yh23hMasw3qMVHRnaYI1mR3DJPcsjQg3ugJ641IJS3hPyYENbohwkliCDyyTVF2X IzmoVIL/2vvNoZh2yM6vGHgUJtghKlQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673629870; 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=CsZI6CBJjkMgqSDB0pNEUq6oiZDvtrxY4s2APwPC8ec=; b=MNvhqfWvlJmIz2eirqFSQ50EaAdw2Ah8aI8yBRP3go54ZZyx8OX+9/VEqh953ONV9WQ2YC ZnhDgCmt/L+XyWEs/WIuWy/ZhbqmfNkhVQoDHHHGSqJtUs6Hf6DYp/UqFK9uMs9SLiqncr pMxlaSAmtC8UmAU82gkfl9WPiJ6pDkI= 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-226-ElAanbZ3Nt6z3bJp0Ss8PQ-1; Fri, 13 Jan 2023 12:11:08 -0500 X-MC-Unique: ElAanbZ3Nt6z3bJp0Ss8PQ-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 A512010113C2; Fri, 13 Jan 2023 17:11:06 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.193.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7DEC840C2064; Fri, 13 Jan 2023 17:11:00 +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 , Vineet Gupta Subject: [PATCH mm-unstable v1 03/26] arc/mm: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE Date: Fri, 13 Jan 2023 18:10:03 +0100 Message-Id: <20230113171026.582290-4-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-Queue-Id: 42829120008 X-Stat-Signature: c8a9ztor7jmo3tcxngj1gt4nhtwwgfo6 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1673629871-991144 X-HE-Meta: U2FsdGVkX1/cz+bVrGXrwOpaGMiWGlO3c9GHPngEraez50y5irp9wAIV6HmWPbEWVJ7xbcXuMlYJkqZuRgHva7bI3Fc4mX6UrEd3+DC46KarIoDR1mFTq4mlpqgqbp93LEqdmdpDAM82Gjox0VfqCe9jbQJ2U8YhXJWWD81CzlNGFHQ53cWtc1PuVkF/pso4RKi0kQyd6ezYmTfZ5QiPXQ5SzFAm711XOvLT67GqBgnashHg+o4LbPqscUqN89mBt+c/sHSsBkjP7ZMY2KENq+xY1+jNA2hkNgW6zhRDIwlQBErWDvS/Ct7v+7C0vVmpSlo1aruuDPDQ/7UEOS8AH7DzSNskQ1zWvKwLFu+eibLtQB4SjsYZ2bZiOBTUDDHsYaOP7+q2UPQYTAIxfngZnHoUTV0Qf/ZRh9LF9YPOXTvBw7jWaCrl69H8pgehycJtVQMbwsfpVpLv3In/W/6jKXR8SK9/NbOyv466QPRQNuf0oPWnJR1oFwGdO1nDlxeYDEYEzMFeF6kGNayYW9H7G6XU0Qr5Il2kA367jOyywfMNHKmLUYEYsfa93G0dbIoMpI6gSEVgsUU+qKEUDX6fV4ylSjO+nVfoYKlaD0En8pvMkcCmJBo9aCdrd75HcdDWOGNy0dWA+tjui/a1cPhnYCJYwcJiAz2c/oUIKOggdqExs4BxDxxV9HscaUJPsKnBnMqTGdB9A6sCo+aBmAK/BuF978kwTLbkzH07tjtmYYIzKmtBlq8RYRaqt3XdYE6dXfjfeMwpJgG7qoJ3sDrFavn1E3RNxhqM3frRXEOS/crlukwBdD4YRdzhiiiI8z/qFGEm+Pqx45KgWLE838bfqh8kp+yXHeyP7XHPTNliXpCqSm7hRpuWq5KJLL8XdDsNGpFhdhXQcn7qL3UE7pLr1gVanYbPi91JZeFcUgKKJ8dLSgIUnvPS+2exBYdmafCfi45BH8IKmWqz2wub7tT JjJhsUJB 7ZUbWkKA7tqWemW8OzwBXK4VoKdtBxdpwufjO 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 bit 5, which is yet unused. The only important parts seems to be to not use _PAGE_PRESENT (bit 9). Cc: Vineet Gupta Signed-off-by: David Hildenbrand --- arch/arc/include/asm/pgtable-bits-arcv2.h | 27 ++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/arch/arc/include/asm/pgtable-bits-arcv2.h b/arch/arc/include/asm/pgtable-bits-arcv2.h index 515e82db519f..611f412713b9 100644 --- a/arch/arc/include/asm/pgtable-bits-arcv2.h +++ b/arch/arc/include/asm/pgtable-bits-arcv2.h @@ -26,6 +26,9 @@ #define _PAGE_GLOBAL (1 << 8) /* ASID agnostic (H) */ #define _PAGE_PRESENT (1 << 9) /* PTE/TLB Valid (H) */ +/* We borrow bit 5 to store the exclusive marker in swap PTEs. */ +#define _PAGE_SWP_EXCLUSIVE _PAGE_DIRTY + #ifdef CONFIG_ARC_MMU_V4 #define _PAGE_HW_SZ (1 << 10) /* Normal/super (H) */ #else @@ -106,9 +109,18 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t *ptep); -/* Encode swap {type,off} tuple into PTE - * We reserve 13 bits for 5-bit @type, keeping bits 12-5 zero, ensuring that - * PAGE_PRESENT is zero in a PTE holding swap "identifier" +/* + * Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that + * are !pte_none() && !pte_present(). + * + * Format of swap PTEs: + * + * 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 + * <-------------- offset -------------> <--- zero --> E < type -> + * + * E is the exclusive marker that is not stored in swap entries. + * The zero'ed bits include _PAGE_PRESENT. */ #define __swp_entry(type, off) ((swp_entry_t) \ { ((type) & 0x1f) | ((off) << 13) }) @@ -120,6 +132,15 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, #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; +} + +PTE_BIT_FUNC(swp_mkexclusive, |= (_PAGE_SWP_EXCLUSIVE)); +PTE_BIT_FUNC(swp_clear_exclusive, &= ~(_PAGE_SWP_EXCLUSIVE)); + #ifdef CONFIG_TRANSPARENT_HUGEPAGE #include #endif