Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp167741lqp; Thu, 4 Apr 2024 09:38:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUf4mrY1S6Ws/LSKygSHOFaaQLRMKUUSgGirjNTYnW93YnkIpN48LMnEk5qZM+RNkBBskbJsrXcVmiLPXW86qCwP6g8nStLZoOSqYNo8Q== X-Google-Smtp-Source: AGHT+IEAptHQxGTxTFMsqLHJe9dvlIlQCo+MAPJXhZjrJF+udtS0VU7rCtpK8Yezd2/g4AISiZ4h X-Received: by 2002:a17:906:40da:b0:a46:cef3:4aba with SMTP id a26-20020a17090640da00b00a46cef34abamr2259937ejk.75.1712248690134; Thu, 04 Apr 2024 09:38:10 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r20-20020a170906549400b00a4a33a2d861si8159731ejo.752.2024.04.04.09.38.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 09:38:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131830-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@redhat.com header.s=mimecast20190719 header.b=IArdbN3s; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-131830-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131830-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B7B511F22FF2 for ; Thu, 4 Apr 2024 16:37:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AC9312D1FA; Thu, 4 Apr 2024 16:37:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IArdbN3s" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 715FE12BEBC for ; Thu, 4 Apr 2024 16:37:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712248637; cv=none; b=bFUdipZss6Il+HFBbyDQ77C5Z9F1NW8496bwe1V+t/LEleYg5wSb4RjLmLzSDhk7teChUhmS23QN1T2kEK+2X9GXX6mspcIglSJM+45ennSAc3lKjfE6cBqFXrupSnDAkegJBwoW/t8tjoiy4XCVLwTBHcZMMWrwVKXcs2E68TQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712248637; c=relaxed/simple; bh=SXHj9/wEFGN76Sp3lJeZ2bNl1eT6+d7ErWDVUzf0EaY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=AlcZ4xQMgG6LA7zzXxTt7VyLM7PRaLV6vqH9zOjdvBjFb0QCtjN11T1CQtsRFTpFfJpHUvCC5T2+57ElIoNtHnTm/tCNHSrLFAHIhHR801Swq6eWepyvIYlIegl8O/1fs4Q25tflGystf2gPaSke/7EBcIUi4NXkpqO3btaQXRY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IArdbN3s; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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(-) -- 2.44.0