From mboxrd@z Thu Jan 1 00:00:00 1970 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 86C34C001B2 for ; Wed, 14 Dec 2022 11:23:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12EB08E0003; Wed, 14 Dec 2022 06:23:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DFA68E0002; Wed, 14 Dec 2022 06:23:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC1DE8E0003; Wed, 14 Dec 2022 06:23:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id DBFC48E0002 for ; Wed, 14 Dec 2022 06:23:00 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9A753120E8B for ; Wed, 14 Dec 2022 11:23:00 +0000 (UTC) X-FDA: 80240674920.14.8FE5826 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 79540100012 for ; Wed, 14 Dec 2022 11:22:58 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DCiGf1wh; spf=pass (imf05.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=1671016978; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yxc01zNwMiugjthmgVOlTrtXQnLfLvXjRGMFtbZZLpc=; b=O4Kcmy4IaZdOjZnyV7fwSHTMggynB0/jbhLwXUFYggibTwlSWWO7w6gEmtALJWs6rNUxn4 7TflPrlNFBWA+L8kmNL+3AlUxVENgxi2x0MGIuTbv5z8iEzVzbWZzetek8cfRRwD9/uqCI e/l23OUHrxL4PJWnKTxhewz8/wYldzc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DCiGf1wh; spf=pass (imf05.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=1671016978; a=rsa-sha256; cv=none; b=7WxoeqwDgPxDW8eDCOqtZmy/na38wp0LLIO3d0YC3JQ4zIo04gKvuSSmH7Sz9D9GHM+ogp YvwFh/Ti/7u+vwktEE9u/xVteH4jAVZK7PQ6WqDgxJqiYV+vxq4WC6g3/QGsLPSPDczR1o jn7QMRD5Ln2Eio3J3Hr8V8hHslY7bv8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671016977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yxc01zNwMiugjthmgVOlTrtXQnLfLvXjRGMFtbZZLpc=; b=DCiGf1wh+DUgXgUnFGqan/11O9qimSJGAfY0mc8FmRYGHEZZmyGfItqNqIdPZ1oFB+Nxky 4BV1XN4L+7DNv2Hs2U6WwrVPPNaRZyBL1HunPhhjKjPReH4cD+0idSht+QPXiEc78PNjgl 0DKs8Lt8E7KznDFDvrw3aiccrSwG3NI= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-186-dC369egbO5eHUrtc969VxQ-1; Wed, 14 Dec 2022 06:22:54 -0500 X-MC-Unique: dC369egbO5eHUrtc969VxQ-1 Received: by mail-wr1-f72.google.com with SMTP id k1-20020adfb341000000b0024215e0f486so3495720wrd.21 for ; Wed, 14 Dec 2022 03:22:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yxc01zNwMiugjthmgVOlTrtXQnLfLvXjRGMFtbZZLpc=; b=owZMPNFH1PwBXWMwz7Qj2mnZTdEXe/6EhOiSA+Y9ZZGKDmXRssY1z73d6WyrhkQklC mCu4Vj6R2OsOiWY9LT2SAa9ADMnJQWsxwODQepT9cDAbGFZ8imNO5wV0/h5fd2lVgiP4 a7039+Rb9KLgVN31kqQf/1StYxR4Wq50VBalQlVaCz3u2uav1QGlHb/4nV36CBIuTUSR lku+IlU8mZFp4l0XIYOcT8gH/U0YctS42X+RfdaTVZdLGKjtSDoER5gar/7ucHACcnUo 3huM+NXY9j8mnnYsCge+jpIQHxk1HAufV0bCAh9WxGVRi6g79RpiNgaigXHB3PH+go/I gSIg== X-Gm-Message-State: ANoB5pl0oo67wPfgSjF+VjT62WTZ1j3SxON5D1yILs5tL6LS/CBjSZXS nfHaCOaJ7MnPljtSds/xQNN8z6UsRsMIrGhGH+4nwLhwtIniSr8/hsrzh3zIl0GkfSgpUmM4GJV NMujqz+M6A8g= X-Received: by 2002:a05:600c:1da2:b0:3cf:5fd2:87a0 with SMTP id p34-20020a05600c1da200b003cf5fd287a0mr17488495wms.40.1671016973461; Wed, 14 Dec 2022 03:22:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf4UNUk6/OXN07sN3FMRll3MrS2ehO8GnTfEO+JQv3BigUvXvNgLJLKqkas5vWijxjr/1KiucA== X-Received: by 2002:a05:600c:1da2:b0:3cf:5fd2:87a0 with SMTP id p34-20020a05600c1da200b003cf5fd287a0mr17488468wms.40.1671016973157; Wed, 14 Dec 2022 03:22:53 -0800 (PST) Received: from ?IPV6:2003:cb:c703:7700:dd7c:92f8:481f:b96b? (p200300cbc7037700dd7c92f8481fb96b.dip0.t-ipconnect.de. [2003:cb:c703:7700:dd7c:92f8:481f:b96b]) by smtp.gmail.com with ESMTPSA id o3-20020a05600c510300b003cfa3a12660sm8504320wms.1.2022.12.14.03.22.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Dec 2022 03:22:52 -0800 (PST) Message-ID: <10bd4fc0-4fc0-bd98-6926-7d721a3bb12e@redhat.com> Date: Wed, 14 Dec 2022 12:22:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH mm-unstable RFC 00/26] mm: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE on all architectures with swap PTEs 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, Albert Ou , Anton Ivanov , Borislav Petkov , Brian Cain , Christophe Leroy , Chris Zankel , Dave Hansen , "David S. Miller" , Dinh Nguyen , Geert Uytterhoeven , Greg Ungerer , Guo Ren , Helge Deller , "H. Peter Anvin" , Huacai Chen , Ingo Molnar , Ivan Kokshaysky , "James E.J. Bottomley" , Johannes Berg , Matt Turner , Max Filippov , Michael Ellerman , Michal Simek , Nicholas Piggin , Palmer Dabbelt , Paul Walmsley , Richard Henderson , Richard Weinberger , Rich Felker , Russell King , Stafford Horne , Stefan Kristiansson , Thomas Bogendoerfer , Thomas Gleixner , Vineet Gupta , WANG Xuerui , Yoshinori Sato References: <20221206144730.163732-1-david@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20221206144730.163732-1-david@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 79540100012 X-Rspam-User: X-Stat-Signature: xdaq9kuxphs4in1whf9rc1bznocfquay X-HE-Tag: 1671016978-916090 X-HE-Meta: U2FsdGVkX19rXlCEofFXkvCmnh1ES+TTYoveby7WlycCwdoZ1WdDzsv42qRBVPcCFjLWmGkvJfEjp/WSfjoN/yqvrIBxgtC+3tX2M9RxP6zWhgsTOx7udSIqwtidiWrA2MwocH8emF5mz0d0saDDAwpcENTHEUng8CASmHfUhYJ9h2jAn0lMbAFtpi0wUiwyDKEQ3/xUp+D8CrXKr/tJu+nqG5JJjhx6PPeAZzSXlZwX5tMR6CPsIbrC3uZM81ovnZqJDYtS3vS+iRun65aRTzpxK+YYMMQZATiL3kg+9sx0p6z8KXvkn9jMit1U0vv338TjR60N3uJIVJBpQLQa5uYeuuJlT2yajVg2DPxoLkO632WMnrkcxbg9asMuRg/ffsGbYlL/OXXSG9T1FUbm7G2fKhmg2UWTL2EixVCCZy9ZmxM1h4VQv0gT5l1aId8BEqEMgwlnD7b17+koef2iu7g3QzZpRvaMtv8VsxSZ2Fr98YGQwvVsqfFjWS0eLQSHGZ9/bw+f2B8HpPAyQzPQrrPX+1bM28aeIEI551Uuwh8EBOqpfWH9YjjR193Yh4BBSEsHeUpCCy925oRb7uEanSndKwD8WLzlPLjBIc0kJTnBFZKv3GpzFuFq3xhq0TLObMC/R3oHwUN0DD1STpJufyE8h6gk9ZWVPk4RiR2zvXbK7QYgb0I9MSxrBpX8+Hd1e9Kv5N3Ac4zdJ5Ggb0mMRMcxzM4IH7tTzWNs0IYanbYA8YbPUxb0t384wpSqEdjjk0LvhPtVOvdlToYsJBNwedP6V9T0E91D4SAHQA43upC+C4E67WyuWn1L/x7pOKv7PoYL5WBnA76We4CI82FmqRuFoPHivPP0MXXIlD18Hn55v5l3H+9smx8oQ1ZQ7z1HVxzQo8YyQqooP71vZIg9QlPBXA9t1N7OwwsB7piS9w++7zuhzYOkVv9uDrOz1Zm/IF628p/Sp8kLtWRVVrp Y4zNdqkC fREjfhYRH+i2E9z2bMf1tsk5o2mGBo73LtFleYc6LxuBW8zyFxPsRqxrqJiB6q8Bpw1LU5Dh+jkAYfVSPiugLf3MHn7IXwAXk2pG9rxQxb3WFac49lF8wG9g2GxmzyZbhCzQnvCJaN0q6OufDMLK5nyl3+wD7TKps3RZ71xdRVxz55yuEuj2BJo3h7wndfQHberhn1w841dt/J8+SFCS0ekAIRwGAp/snDzxhXQP48oB6T5I= 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: On 06.12.22 15:47, David Hildenbrand wrote: > This is the follow-up on [1]: > [PATCH v2 0/8] mm: COW fixes part 3: reliable GUP R/W FOLL_GET of > anonymous pages > > After we implemented __HAVE_ARCH_PTE_SWP_EXCLUSIVE on most prominent > enterprise architectures, implement __HAVE_ARCH_PTE_SWP_EXCLUSIVE on all > remaining architectures that support swap PTEs. > > This makes sure that exclusive anonymous pages will stay exclusive, even > after they were swapped out -- for example, making GUP R/W FOLL_GET of > anonymous pages reliable. Details can be found in [1]. > > This primarily fixes remaining known O_DIRECT memory corruptions that can > happen on concurrent swapout, whereby we can lose DMA reads to a page > (modifying the user page by writing to it). > > To verify, there are two test cases (requiring swap space, obviously): > (1) The O_DIRECT+swapout test case [2] from Andrea. This test case tries > triggering a race condition. > (2) My vmsplice() test case [3] that tries to detect if the exclusive > marker was lost during swapout, not relying on a race condition. > > > For example, on 32bit x86 (with and without PAE), my test case fails > without these patches: > $ ./test_swp_exclusive > FAIL: page was replaced during COW > But succeeds with these patches: > $ ./test_swp_exclusive > PASS: page was not replaced during COW > > > Why implement __HAVE_ARCH_PTE_SWP_EXCLUSIVE for all architectures, even > the ones where swap support might be in a questionable state? This is the > first step towards removing "readable_exclusive" migration entries, and > instead using pte_swp_exclusive() also with (readable) migration entries > instead (as suggested by Peter). The only missing piece for that is > supporting pmd_swp_exclusive() on relevant architectures with THP > migration support. > > As all relevant architectures now implement __HAVE_ARCH_PTE_SWP_EXCLUSIVE,, > we can drop __HAVE_ARCH_PTE_SWP_EXCLUSIVE in the last patch. > > > RFC because some of the swap PTE layouts are really tricky and I really > need some feedback related to deciphering these layouts and "using yet > unused PTE bits in swap PTEs". I tried cross-compiling all relevant setups > (phew, I might only miss some power/nohash variants), but only tested on > x86 so far. As I was messing with sparc64 either way and got debian to boot under QEMU, I verified that the sparc64 change also seems to work as expected (under sun4u). -- Thanks, David / dhildenb