From patchwork Thu Apr 4 16:36:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13618056 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 E9441CD1284 for ; Thu, 4 Apr 2024 16:37:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54CF76B0082; Thu, 4 Apr 2024 12:37:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FD286B0098; Thu, 4 Apr 2024 12:37:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C4F56B0099; Thu, 4 Apr 2024 12:37:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 209216B0082 for ; Thu, 4 Apr 2024 12:37:17 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D14561202D9 for ; Thu, 4 Apr 2024 16:37:16 +0000 (UTC) X-FDA: 81972404472.09.0CE5352 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 274AB140011 for ; Thu, 4 Apr 2024 16:37:13 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IArdbN3s; spf=pass (imf26.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=1712248634; 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:references:dkim-signature; bh=2i4EI1wSyDo81mrMl0H/7Wwslnn2XIreCf4ZZweSpD4=; b=vA7EjTvVTbc7vxpY7eulOzUXNMmWtAk3G156yZo/Oo/XNiWcqvgaYEGauq30xrsdRHB4ol HXSSVqYPB7rtBE9nr+EAZlLXrtqveYWMbtiSfIXtw+VK0FjenrtVFJUJOsfmEZq8USQKGC 7GBJ47+sX1xd9h1rcwvBF+c5uNTrJ34= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712248634; a=rsa-sha256; cv=none; b=2XZLA9YCf+PFRMGg5AdFcXvGMcX0mD/TctZQEF5QzkLSGRpuMjYfhmuCQzkgRFi1MJcu5N ZFsCb448vNyAHWHHVI4LqflUzWCTQHWeBhs2NACpfcvgpAEJNTYluupKWhEKi+WNkgZE4d 6ln1QK3Oou3emzRLd80LU2fPmy7ZXTo= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IArdbN3s; spf=pass (imf26.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712248633; 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; bh=2i4EI1wSyDo81mrMl0H/7Wwslnn2XIreCf4ZZweSpD4=; b=IArdbN3sIrWQTd1/4YYuXuZhv3AcmSOYtmJTb2p9OS3JfZe0E88V2vOi/yeQLEI28BCka/ jv6/iRaVMOSM7m1exv13FBRQjxGh3YXVGCc0zDZXUvos1cXuUJ7cxIeQ0BpDRLH93nPKpu n2odXzl7SCHIRUOOOWZypAgJb2KFXqY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-679-AtxE8RxIP922gaPsZUJwcA-1; Thu, 04 Apr 2024 12:37:10 -0400 X-MC-Unique: AtxE8RxIP922gaPsZUJwcA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1FD7B1C0CCAD; Thu, 4 Apr 2024 16:37:08 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B2343C21; Thu, 4 Apr 2024 16:37:03 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, David Hildenbrand , Matthew Wilcox , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Janosch Frank , Claudio Imbrenda , Gerald Schaefer , Thomas Huth Subject: [PATCH v1 0/5] s390: page_mapcount(), page_has_private() and PG_arch_1 Date: Thu, 4 Apr 2024 18:36:37 +0200 Message-ID: <20240404163642.1125529-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Stat-Signature: 3qgp6dyffkkt9t7nicx7s4jqbine4swa X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 274AB140011 X-Rspam-User: X-HE-Tag: 1712248633-767443 X-HE-Meta: U2FsdGVkX19NrUO/Qcl0NR0FtdGRcx93kxBmPy/7IK5nvYjbyYsFe2maKryDlc7zUEaLsjsBVv97Cwu0Z4bo3v2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g5p23xo18GLGvPYZa0KKS/Ipe4lmsBuqbmxClsADU2NNs+mRnPYVjQZC3SlqwPISzsrmdEbbXx8B09ezJBvSkFT5myYJk8OCuUe9jyRVNa3BDX7s= 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: List-Subscribe: List-Unsubscribe: On my journey to remove page_mapcount(), I got hooked up on other folio cleanups that Willy most certainly will enjoy. This series removes the s390x usage of: * page_mapcount() [patches WIP] * page_has_private() [have patches to remove it] ... and makes PG_arch_1 only be set on folio->flags (i.e., never on tail pages of large folios). Further, one "easy" fix upfront. ... unfortunately there is one other issue I spotted that I am not tackling in this series, because I am not 100% sure what we want to do: the usage of page_ref_freeze()/folio_ref_freeze() in make_folio_secure() is unsafe. :( In make_folio_secure(), we're holding the folio lock, the mmap lock and the PT lock. So we are protected against concurrent fork(), zap, GUP, swapin, migration ... The page_ref_freeze()/ folio_ref_freeze() should also block concurrent GUP-fast very reliably. But if the folio is mapped into multiple page tables, we could see concurrent zapping of the folio, a pagecache folios could get mapped/ accessed concurrent, we could see fork() sharing the page in another process, GUP ... trying to adjust the folio refcount while we froze it. Very bad. For anonymous folios, it would likely be sufficient to check that folio_mapcount() == 1. For pagecache folios, that's insufficient, likely we would have to lock the pagecache. To handle folios mapped into multiple page tables, we would have to do what split_huge_page_to_list_to_order() does (temporary migration entries). So it's a bit more involved, and I'll have to leave that to s390x folks to figure out. There are othe reasonable cleanups I think, but I'll have to focus on other stuff. Compile tested, but not runtime tested, I'll appreiate some testing help from people with UV access and experience. Cc: Matthew Wilcox (Oracle) Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: Christian Borntraeger Cc: Sven Schnelle Cc: Janosch Frank Cc: Claudio Imbrenda Cc: Gerald Schaefer Cc: Matthew Wilcox (Oracle) Cc: Thomas Huth David Hildenbrand (5): s390/uv: don't call wait_on_page_writeback() without a reference s390/uv: convert gmap_make_secure() to work on folios s390/uv: convert PG_arch_1 users to only work on small folios s390/uv: update PG_arch_1 comment s390/hugetlb: convert PG_arch_1 code to work on folio->flags arch/s390/include/asm/page.h | 2 + arch/s390/kernel/uv.c | 112 ++++++++++++++++++++++------------- arch/s390/mm/gmap.c | 4 +- arch/s390/mm/hugetlbpage.c | 8 +-- 4 files changed, 79 insertions(+), 47 deletions(-)