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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D4F5CA9EBB for ; Thu, 24 Oct 2019 12:11:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 590F220856 for ; Thu, 24 Oct 2019 12:11:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ma9Nwa8U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 590F220856 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0B4DE6B000A; Thu, 24 Oct 2019 08:11:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08D6E6B000C; Thu, 24 Oct 2019 08:11:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBD9D6B000D; Thu, 24 Oct 2019 08:11:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id BF4146B000A for ; Thu, 24 Oct 2019 08:11:17 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 5DCED641D for ; Thu, 24 Oct 2019 12:11:17 +0000 (UTC) X-FDA: 76078562994.14.wren79_b3236a161236 X-HE-Tag: wren79_b3236a161236 X-Filterd-Recvd-Size: 9050 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Thu, 24 Oct 2019 12:11:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571919076; 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; bh=TooFwxaibKWioSMXkjdsd9KqTbD0P4TIgojllh09QfQ=; b=Ma9Nwa8U05TUyp2WPPo4CE5GEWVGVIG2OxIJOLhEYrr0o0eadQ2gEg1OK6TjwceiwxlWJe Hw0QzFUtbdvRE2d0aI1M838h87d/IdoynG3ITnZzx9yN2M+tyQvgmWRa2zD3KUZTBh/boQ 3cIVSTLrd6gVuUIO6+JXSFutQFQ+SWs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-70-Mt5vh3dPMhmZKGgS4b6ZRA-1; Thu, 24 Oct 2019 08:10:06 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 410A4801E5C; Thu, 24 Oct 2019 12:10:01 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-141.ams2.redhat.com [10.36.116.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id 314413CCA; Thu, 24 Oct 2019 12:09:39 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Michal Hocko , Andrew Morton , kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, linux-hyperv@vger.kernel.org, devel@driverdev.osuosl.org, xen-devel@lists.xenproject.org, x86@kernel.org, Alexander Duyck , Alexander Duyck , Alex Williamson , Allison Randal , Andy Lutomirski , "Aneesh Kumar K.V" , Anshuman Khandual , Anthony Yznaga , Benjamin Herrenschmidt , Borislav Petkov , Boris Ostrovsky , Christophe Leroy , Cornelia Huck , Dan Williams , Dave Hansen , Haiyang Zhang , "H. Peter Anvin" , Ingo Molnar , "Isaac J. Manjarres" , Jim Mattson , Joerg Roedel , Johannes Weiner , Juergen Gross , KarimAllah Ahmed , Kees Cook , "K. Y. Srinivasan" , "Matthew Wilcox (Oracle)" , Matt Sickler , Mel Gorman , Michael Ellerman , Michal Hocko , Mike Rapoport , Mike Rapoport , Nicholas Piggin , Oscar Salvador , Paolo Bonzini , Paul Mackerras , Paul Mackerras , Pavel Tatashin , Pavel Tatashin , Peter Zijlstra , Qian Cai , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Sasha Levin , Sean Christopherson , Stefano Stabellini , Stephen Hemminger , Thomas Gleixner , Vitaly Kuznetsov , Vlastimil Babka , Wanpeng Li , YueHaibing Subject: [PATCH v1 00/10] mm: Don't mark hotplugged pages PG_reserved (including ZONE_DEVICE) Date: Thu, 24 Oct 2019 14:09:28 +0200 Message-Id: <20191024120938.11237-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: Mt5vh3dPMhmZKGgS4b6ZRA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: This is the result of a recent discussion with Michal ([1], [2]). Right now we set all pages PG_reserved when initializing hotplugged memmaps. This includes ZONE_DEVICE memory. In case of system memory, PG_reserved is cleared again when onlining the memory, in case of ZONE_DEVICE memory never. In ancient times, we needed PG_reserved, because there was no way to tell whether the memmap was already properly initialized. We now have SECTION_IS_ONLINE for that in the case of !ZONE_DEVICE memory. ZONE_DEVICE memory is already initialized deferred, and there shouldn't be a visible change in that regard. One of the biggest fears were side effects. I went ahead and audited all users of PageReserved(). The details can be found in "mm/memory_hotplug: Don't mark pages PG_reserved when initializing the memmap". This patch set adapts all relevant users of PageReserved() to keep the existing behavior in respect to ZONE_DEVICE pages. The biggest part part that needs changes is KVM, to keep the existing behavior (that's all I care about in this series). Note that this series is able to rely completely on pfn_to_online_page(). No new is_zone_device_page() calles are introduced (as requested by Dan). We are currently discussing a way to mark also ZONE_DEVICE memmaps as active/initialized - pfn_active() - and lightweight locking to make sure memmaps remain active (e.g., using RCU). We might later be able to convert some suers of pfn_to_online_page() to pfn_active(). Details can be found in [3], however, this represents yet another cleanup/fix we'll perform on top of this cleanup. I only gave it a quick test with DIMMs on x86-64, but didn't test the ZONE_DEVICE part at all (any tips for a nice QEMU setup?). Also, I didn't test the KVM parts (especially with ZONE_DEVICE pages or no memmap at all). Compile-tested on x86-64 and PPC. Based on next/master. The current version (kept updated) can be found at: https://github.com/davidhildenbrand/linux.git online_reserved_cleanup RFC -> v1: - Dropped "staging/gasket: Prepare gasket_release_page() for PG_reserved changes" - Dropped "staging: kpc2000: Prepare transfer_complete_cb() for PG_reserved changes" - Converted "mm/usercopy.c: Prepare check_page_span() for PG_reserved changes" to "mm/usercopy.c: Update comment in check_page_span() regarding ZONE_DEVICE" - No new users of is_zone_device_page() are introduced. - Rephrased comments and patch descriptions. [1] https://lkml.org/lkml/2019/10/21/736 [2] https://lkml.org/lkml/2019/10/21/1034 [3] https://www.spinics.net/lists/linux-mm/msg194112.html Cc: Michal Hocko Cc: Dan Williams Cc: kvm-ppc@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: kvm@vger.kernel.org Cc: linux-hyperv@vger.kernel.org Cc: devel@driverdev.osuosl.org Cc: xen-devel@lists.xenproject.org Cc: x86@kernel.org Cc: Alexander Duyck David Hildenbrand (10): mm/memory_hotplug: Don't allow to online/offline memory blocks with holes KVM: x86/mmu: Prepare kvm_is_mmio_pfn() for PG_reserved changes KVM: Prepare kvm_is_reserved_pfn() for PG_reserved changes vfio/type1: Prepare is_invalid_reserved_pfn() for PG_reserved changes powerpc/book3s: Prepare kvmppc_book3s_instantiate_page() for PG_reserved changes powerpc/64s: Prepare hash_page_do_lazy_icache() for PG_reserved changes powerpc/mm: Prepare maybe_pte_to_page() for PG_reserved changes x86/mm: Prepare __ioremap_check_ram() for PG_reserved changes mm/memory_hotplug: Don't mark pages PG_reserved when initializing the memmap mm/usercopy.c: Update comment in check_page_span() regarding ZONE_DEVICE arch/powerpc/kvm/book3s_64_mmu_radix.c | 14 +++++---- arch/powerpc/mm/book3s64/hash_utils.c | 10 +++--- arch/powerpc/mm/pgtable.c | 10 +++--- arch/x86/kvm/mmu.c | 29 ++++++++++------- arch/x86/mm/ioremap.c | 13 ++++++-- drivers/hv/hv_balloon.c | 6 ++++ drivers/vfio/vfio_iommu_type1.c | 10 ++++-- drivers/xen/balloon.c | 7 +++++ include/linux/page-flags.h | 8 +---- mm/memory_hotplug.c | 43 +++++++++++++++++++------- mm/page_alloc.c | 11 ------- mm/usercopy.c | 6 ++-- virt/kvm/kvm_main.c | 10 ++++-- 13 files changed, 111 insertions(+), 66 deletions(-) --=20 2.21.0