From patchwork Fri Oct 25 14:14:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13850762 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 EE7BCD0C615 for ; Fri, 25 Oct 2024 14:15:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 703286B008A; Fri, 25 Oct 2024 10:15:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B2FA6B0092; Fri, 25 Oct 2024 10:15:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57AA56B0095; Fri, 25 Oct 2024 10:15:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3849D6B008A for ; Fri, 25 Oct 2024 10:15:12 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 12117409AD for ; Fri, 25 Oct 2024 14:15:01 +0000 (UTC) X-FDA: 82712320740.08.3B3A35B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 0EDC94002E for ; Fri, 25 Oct 2024 14:14:53 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JKt78Sor; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729865670; a=rsa-sha256; cv=none; b=0nGVopj0C9UfZH9C7FS3qyYXIImVRAVHa81LslXeiUqOLDBPE/ZXle2Q6TxCvQOK/6xHoU fd+bLLJXVdSjcKzp8oQ3HuKKIItHVAVv/FEVHd75o3dxcpct2T6o28XsiKZoCOMjMxDlPy brMWEPBZWrm3/+ZFCgRacplQPvTEiiY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JKt78Sor; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729865670; 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=Ff6XQKworBBc6g+g+GISIC2w5/BR0dZAOdIhNYuIBxY=; b=6MRyZ5AEe1TTPu117AFd4zQeeYlE1JYhsO4tyodcnX4JzdF9oLSCFM+Q9XkbG/M6vniQmr vxwmguC4RtLVd7EomigIf8r9tUxdNePLt4spLWNSzJ0OfVhyj3/n1vUACrDOsdPKbhQe89 xLuiiBs1myQn/2q0GPMCDql2e994Z7c= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729865709; 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=Ff6XQKworBBc6g+g+GISIC2w5/BR0dZAOdIhNYuIBxY=; b=JKt78SorW3qqUZQeBVC5DJX0WJ30/nGl41b5qyF6giECejaEzmRfZc8b1KjllQ/N4mlqpw R5fGNAMUUtXV5d9s4SMJ1iN7wVphJKg/EPSGYetQJ7Cwv1LyW8OedR/UWsFnlf6ZUWwHWd CUfzN6sx2H6lGL/uJM1pRsP0ABbLcDs= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-277-hdlqc4_INZygg1ik9ibmHw-1; Fri, 25 Oct 2024 10:15:05 -0400 X-MC-Unique: hdlqc4_INZygg1ik9ibmHw-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D061719560A6; Fri, 25 Oct 2024 14:15:02 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.22.65.27]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B94FE1955F30; Fri, 25 Oct 2024 14:14:54 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-s390@vger.kernel.org, virtualization@lists.linux.dev, linux-doc@vger.kernel.org, kvm@vger.kernel.org, David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Huth , Cornelia Huck , Janosch Frank , Claudio Imbrenda , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Eric Farman , Andrew Morton , Jonathan Corbet Subject: [PATCH v3 0/7] virtio-mem: s390 support Date: Fri, 25 Oct 2024 16:14:45 +0200 Message-ID: <20241025141453.1210600-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Rspam-User: X-Stat-Signature: uw1bnnzhq6opnbs4dywfez45q84gn8mn X-Rspamd-Queue-Id: 0EDC94002E X-Rspamd-Server: rspam02 X-HE-Tag: 1729865693-718366 X-HE-Meta: U2FsdGVkX1+qCVvKONTY6178f0fNGxRc2LhtzEYZbrD9NZuICktjjkooPERQnvmghc3JPvFYxhqfugLje09/DQaEMttkfbCUk6kFZLXOXVEhl/110zx62kTywnCma0YheKwfRgKhi99/n34dG3iJkdb7ee8Xthjnaz7gbUoIipVqpfBKzGbSD6gGPhCuMiJuW2dRIJC2tXBPMomjEY+cY+uYTiS4KTLW3ICy/NCYTj+h/kJio3IL6QutDb5SflF7t1gsi5g179E3HyjQHur59dpXVPFiiZSRG1O0MoGjp3bN5QdmxnRkgMcWaSJVYZD0dFQsBHt6PuprjNlaTppawkyPqAzA0TROZZYpKb6nnYYAdYAinmWvu4FeMeIwxzvVe4qVc4aXtmhqn/sZmpLWCkNDRCAVrZhWcC7Usn3ELeSDeTYiT+nkfIWchMG+B9SkLt9xuyOahrOUkIF600bAPMq83H3CbLxBG5joDEAf+c1xjYGGY4g4S90igjSGi/2VVNUc3hGtivuE2VfzF/ffPjK7+cAywtLBl6+H9p911dmb3L7atK8F2AY33K/SaLhH/06+7SSRQd+dIR90l1T2zcZZY9KllcNSDvNs29Qz9jrZo3Ezjsbud6CADcOX52s3iQ4z2Y6fBuIL8FqebPETWV0BqZttouId4y3kCD2GIFkZgLJ2FvZnI/B6VtbcRgkoTCO+JEq9XV0rN0pmwCs3jT/tqZ+ydNHYL/TeXU7ATrfyMYfHTsEpfhNSDkGnGB0i95x4RSOIEpwv+BpVrVhXPZGp5T0ADOiRoMcs3wl3ag2PQJsn1xpOZsBE18TNLtIVUHYs1hGq0+F6De9NLFMEV927D1jG3ScXDQbDhCCabIeqFn69tSLX5+FTvyqBAjLiaXCKlOAt/jCnuUl/Gqush2SzqcQlD8UHNGz2x9Vwj4k9dYlpc0stTn4qq0FbKFFLY/ZxW+7EpIAnkRi/Rud L0Ctq2gx A8mqOJLYMicgwisNvYpqerUWe9Fr138lAyLYahysyeToUnM8kWw+a+q9hwZkhBua258ZwAo1kjYYNguPNv+tV2erNT0K2S9CAmm0GsZWJo1DVY+s5hl8fMB5yNFaDUKyIfIGYf9BmfbzjTICpx3euktX+Oc+frqboK64UXsBBAJZ9Uw1TyNwSFeAmykqHCZb0KN/+K+NJtfqoBVQBN/VVxIWxxztiGj8t4dIi7Is8j+2ayxjRGxoNqpPKy9YDqDEW03Bo7NiIfFkqcCh8y0fVv8sBcsj/CaZmS5Sp8ONxPeblX89sz8KEXZEcZK2jXT1cpX2kcB/icEgvqOkw8bIkJfXOR8uNeZGFa5uc4jZls4AUVdUL2+oHKZUKq/tW7a1YbBC2ZfVRxIo4UfI+Ek6EEUwQAZFuAcV//zKr3aEielOzUxItySRN9izmm9qtK24TtU8IgWJRDz8WB7Q/NeWToRm52V1bfop7dO0sAx0xson5uTGCIqJ5mqUS3+5fVmsUn83x7DHrdIkPNQeijtCuuSmeTyDpue6pFKZUDAqqbbVmec8L5O2X/vqj4HfsosEIhg9F42ANDngRT3ZorLKoz4X0Po8f+tPHCUVMvclxiOwf7t9w1dwGJrYAFNu94MceB/6X 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: Let's finally add s390 support for virtio-mem; my last RFC was sent 4 years ago, and a lot changed in the meantime. The latest QEMU series is available at [1], which contains some more details and a usage example on s390 (last patch). There is not too much in here: The biggest part is querying a new diag(500) STORAGE_LIMIT hypercall to obtain the proper "max_physmem_end". The last three patches are not strictly required but certainly nice-to-have. Note that -- in contrast to standby memory -- virtio-mem memory must be configured to be automatically onlined as soon as hotplugged. The easiest approach is using the "memhp_default_state=" kernel parameter or by using proper udev rules. More details can be found at [2]. I have reviving+upstreaming a systemd service to handle configuring that on my todo list, but for some reason I keep getting distracted ... I tested various things, including: * Various memory hotplug/hotunplug combinations * Device hotplug/hotunplug * /proc/iomem output * reboot * kexec * kdump: make sure we properly enter the "kdump mode" in the virtio-mem driver kdump support for virtio-mem memory on s390 will be sent out separately. v2 -> v3 * "s390/kdump: make is_kdump_kernel() consistently return "true" in kdump environments only" -> Sent out separately [3] * "s390/physmem_info: query diag500(STORAGE LIMIT) to support QEMU/KVM memory devices" -> No query function for diag500 for now. -> Update comment above setup_ident_map_size(). -> Optimize/rewrite diag500_storage_limit() [Heiko] -> Change handling in detect_physmem_online_ranges [Alexander] -> Improve documentation. * "s390/sparsemem: provide memory_add_physaddr_to_nid() with CONFIG_NUMA" -> Added after testing on systems with CONFIG_NUMA=y v1 -> v2: * Document the new diag500 subfunction * Use "s390" instead of "s390x" consistently [1] https://lkml.kernel.org/r/20241008105455.2302628-1-david@redhat.com [2] https://virtio-mem.gitlab.io/user-guide/user-guide-linux.html [3] https://lkml.kernel.org/r/20241023090651.1115507-1-david@redhat.com Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: Christian Borntraeger Cc: Sven Schnelle Cc: Thomas Huth Cc: Cornelia Huck Cc: Janosch Frank Cc: Claudio Imbrenda Cc: "Michael S. Tsirkin" Cc: Jason Wang Cc: Xuan Zhuo Cc: "Eugenio PĂ©rez" Cc: Eric Farman Cc: Andrew Morton Cc: Jonathan Corbet David Hildenbrand (7): Documentation: s390-diag.rst: make diag500 a generic KVM hypercall Documentation: s390-diag.rst: document diag500(STORAGE LIMIT) subfunction s390/physmem_info: query diag500(STORAGE LIMIT) to support QEMU/KVM memory devices virtio-mem: s390 support lib/Kconfig.debug: default STRICT_DEVMEM to "y" on s390 s390/sparsemem: reduce section size to 128 MiB s390/sparsemem: provide memory_add_physaddr_to_nid() with CONFIG_NUMA Documentation/virt/kvm/s390/s390-diag.rst | 35 +++++++++++++---- arch/s390/boot/physmem_info.c | 47 ++++++++++++++++++++++- arch/s390/boot/startup.c | 7 +++- arch/s390/include/asm/physmem_info.h | 3 ++ arch/s390/include/asm/sparsemem.h | 10 ++++- drivers/virtio/Kconfig | 12 +++--- lib/Kconfig.debug | 2 +- 7 files changed, 98 insertions(+), 18 deletions(-) base-commit: ae90f6a6170d7a7a1aa4fddf664fbd093e3023bc Acked-by: Christian Borntraeger Tested-by: Sumanth Korikkar