From patchwork Fri Jun 7 09:09:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13689519 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 D756BC27C53 for ; Fri, 7 Jun 2024 09:09:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69F9B6B009B; Fri, 7 Jun 2024 05:09:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64F086B00A9; Fri, 7 Jun 2024 05:09:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 516BF6B00A6; Fri, 7 Jun 2024 05:09:57 -0400 (EDT) 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 37BEF6B00A9 for ; Fri, 7 Jun 2024 05:09:57 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DB69514121A for ; Fri, 7 Jun 2024 09:09:56 +0000 (UTC) X-FDA: 82203520392.06.FB49DCB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 4F264A000D for ; Fri, 7 Jun 2024 09:09:54 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=apjgsSaV; spf=pass (imf15.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=1717751394; 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: references:dkim-signature; bh=QzQrIOtS4DHvHPJ4+HHeRZGer7eituw1+x4QYHDabqc=; b=gUpYYYaOxkAkcp4hII/ltmfkeLZ6wkVgCIVrwCFDczDugUGT/0Ld9NyvTTUMG00JGXUuQt G8c96fJjrYdp00yDlDQjYLi5J490dmDEq/wUG5HgP9l4NhDTvJ8Xo+1ekM4R+rTwFEUG2r bhgSDdKp3Mf272IxRAVDxEL0ulZAz3M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717751394; a=rsa-sha256; cv=none; b=JapgWQ/2p+9EcuFhg3G1LuEq2VFaZ4HPpc18KZAxSUXcaSIajso8Z+ojlo0G91Osnl1wGS XDP5PSPtqxP4K+t3YfFOLy6GN9GcGlynhi6P+fHsHPteLSo4oORrZFhyxkAXScl5Eg7hEa 7BPaajltRr4w+9yqOk+4PiJZCjtpaO8= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=apjgsSaV; spf=pass (imf15.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=1717751393; 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=QzQrIOtS4DHvHPJ4+HHeRZGer7eituw1+x4QYHDabqc=; b=apjgsSaVHQadLx5qVTZszyI2RYwx+SMwdqJU2TFNWxPjDg3XmGMWTdZvSWgS0nOgjgYxUB BTklcN2zxQZgxRoBolHY7KM+ajs8/LqY+AUKO/m+5KAxt+lKfNLoUhAc2a5nqYvlZocdv+ u75I2vqR0I1l1W3UEex0k3D6VMRBe3I= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-FnEQzJIXPkGraVrUGETiZw-1; Fri, 07 Jun 2024 05:09:47 -0400 X-MC-Unique: FnEQzJIXPkGraVrUGETiZw-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 F2F3680B5C7; Fri, 7 Jun 2024 09:09:45 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D69F37E5; Fri, 7 Jun 2024 09:09:40 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-hyperv@vger.kernel.org, virtualization@lists.linux.dev, xen-devel@lists.xenproject.org, kasan-dev@googlegroups.com, David Hildenbrand , Andrew Morton , Mike Rapoport , Oscar Salvador , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Alexander Potapenko , Marco Elver , Dmitry Vyukov Subject: [PATCH v1 0/3] mm/memory_hotplug: use PageOffline() instead of PageReserved() for !ZONE_DEVICE Date: Fri, 7 Jun 2024 11:09:35 +0200 Message-ID: <20240607090939.89524-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Rspam-User: X-Stat-Signature: br5f7dbdr7wqraoiiiputbwmn9wmw89k X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K/3n6r1b/diFC9niajzG896zpK4qYiJuxcA1gXl4ZGvigXT99DNOVBnZIaKgI1nQGzyitNSWbGT835S8lWpEUCa9PM83yHa25mb3xzpOez7/1iNlrn9hCz61e2aofihSXXXpvXvHOQCYFxR8b4SaTiCQfM670DwfWoksg2OAwvHsC0I2VO1qQlgP2Mv88VqIxzkRZtwR5ubzfOUhWNPCoVHf0Ccg1Wq2DT9GyOA7+Ow/duilfKH6kRP++mPShugsGAi04osbcYwuS9ZS1cxgma0CA+lYgNA2v8UVwsREts+Dmxi3M9K8QZ77L/cERhnqgky1YHIv2hbaG1D4LDiyEeK5soatvbHMbTUEs5NgqvPQBr4Md1oIp4rqSV5nQUC+wjlWBa/sVFeqXfwwa+pbRJ6y2x8WSs/NOhcNyECMH+u9rQwBuUZ+qEVj7pHtntY0482NOHMy75AR4K69AUzEXWhPOiLtOpxE9If6AP6jjxS+aQqkUNZC4xDewrtu5oId1khYDGcXltlQqfMeXPohsXHQi/C8fgXB54cHf1vYkvBdFYV6zoREPqZ+4eTPZ 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: This can be a considered a long-overdue follow-up to some parts of [1]. The patches are based on [2], but they are not strictly required -- just makes it clearer why we can use adjust_managed_page_count() for memory hotplug without going into details about highmem. We stop initializing pages with PageReserved() in memory hotplug code -- except when dealing with ZONE_DEVICE for now. Instead, we use PageOffline(): all pages are initialized to PageOffline() when onlining a memory section, and only the ones actually getting exposed to the system/page allocator will get PageOffline cleared. This way, we enlighten memory hotplug more about PageOffline() pages and can cleanup some hacks we have in virtio-mem code. What about ZONE_DEVICE? PageOffline() is wrong, but we might just stop using PageReserved() for them later by simply checking for is_zone_device_page() at suitable places. That will be a separate patch set / proposal. This primarily affects virtio-mem, HV-balloon and XEN balloon. I only briefly tested with virtio-mem, which benefits most from these cleanups. [1] https://lore.kernel.org/all/20191024120938.11237-1-david@redhat.com/ [2] https://lkml.kernel.org/r/20240607083711.62833-1-david@redhat.com Cc: Andrew Morton Cc: Mike Rapoport Cc: Oscar Salvador Cc: "K. Y. Srinivasan" Cc: Haiyang Zhang Cc: Wei Liu Cc: Dexuan Cui Cc: "Michael S. Tsirkin" Cc: Jason Wang Cc: Xuan Zhuo Cc: "Eugenio PĂ©rez" Cc: Juergen Gross Cc: Stefano Stabellini Cc: Oleksandr Tyshchenko Cc: Alexander Potapenko Cc: Marco Elver Cc: Dmitry Vyukov David Hildenbrand (3): mm: pass meminit_context to __free_pages_core() mm/memory_hotplug: initialize memmap of !ZONE_DEVICE with PageOffline() instead of PageReserved() mm/memory_hotplug: skip adjust_managed_page_count() for PageOffline() pages when offlining drivers/hv/hv_balloon.c | 5 ++-- drivers/virtio/virtio_mem.c | 29 +++++++++--------- drivers/xen/balloon.c | 9 ++++-- include/linux/memory_hotplug.h | 4 +-- include/linux/page-flags.h | 20 +++++++------ mm/internal.h | 3 +- mm/kmsan/init.c | 2 +- mm/memory_hotplug.c | 31 +++++++++---------- mm/mm_init.c | 14 ++++++--- mm/page_alloc.c | 55 +++++++++++++++++++++++++++------- 10 files changed, 108 insertions(+), 64 deletions(-) base-commit: 19b8422c5bd56fb5e7085995801c6543a98bda1f prerequisite-patch-id: ca280eafd2732d7912e0c5249dc0df9ecbef19ca prerequisite-patch-id: 8f43ebc81fdf7b9b665b57614e9e569535094758