From patchwork Tue Jun 27 11:22:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13294362 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 832A8EB64DD for ; Tue, 27 Jun 2023 11:22:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E46918D0001; Tue, 27 Jun 2023 07:22:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC2148D0003; Tue, 27 Jun 2023 07:22:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C60B38D0002; Tue, 27 Jun 2023 07:22:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B2C298D0001 for ; Tue, 27 Jun 2023 07:22:35 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7C25BA092F for ; Tue, 27 Jun 2023 11:22:35 +0000 (UTC) X-FDA: 80948289870.23.3FE00E5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id D537010001A for ; Tue, 27 Jun 2023 11:22:33 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZxLsEZkb; spf=pass (imf05.hostedemail.com: domain of david@redhat.com designates 170.10.133.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=1687864953; 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=AXpX6+bIX3VG+BFlIbD8IyCdNffvSiQAQaFthXvYXYA=; b=eCFYfyiObeut1TAgQDElc0DbhXX/tOOoCBsn9KGufXcyOTOMWvKedXETlGU/rLncvdM6ar ++itC6N2vMR9RqsBmrcMrXLvMJhcJxb8iIF+BLqXUfO5I6YShmvHtESbkvew6Ndky2NsFS lGxzamQHGUxTTREuz/Wwu9UuwyxykC4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687864953; a=rsa-sha256; cv=none; b=z4bEgmE5jyelUxaeiP2WAgZ3DYYqIpVIlrnLBxtQ1MFoVoXktWz+jvpmJkbaBBluxMFuUe tY0Ia+0TnjIRQulGTWvWeNUlpZ9V/prIux9LIzcQRIp4OEaSd3bbvW7dyWnaVzxwSR/ZaC Rsaj2yUu18D1c4INcr6Mur2K7J/Br4I= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZxLsEZkb; spf=pass (imf05.hostedemail.com: domain of david@redhat.com designates 170.10.133.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=1687864953; 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=AXpX6+bIX3VG+BFlIbD8IyCdNffvSiQAQaFthXvYXYA=; b=ZxLsEZkbLxclSHSnZ6DUE2YyzaYH9X9UM1eENPo6mqOxRuoExb0CBo0Ffl+PpiZNctm+fm qPsIoH3lVTOgFYtoKNLnyxvrTpburM885jFw4JHwKM8kAYNL5+tljm+MmkDx8S5cNSXoIp vrxREa6fBQONGQRUYJ4VrI91Sl8Ychk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-458-KoLIc-NHPDWNdw4_zSVBwg-1; Tue, 27 Jun 2023 07:22:28 -0400 X-MC-Unique: KoLIc-NHPDWNdw4_zSVBwg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 638D11C07588; Tue, 27 Jun 2023 11:22:27 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.192.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69FFF200A3AD; Tue, 27 Jun 2023 11:22:21 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, virtualization@lists.linux-foundation.org, David Hildenbrand , Andrew Morton , "Michael S. Tsirkin" , John Hubbard , Oscar Salvador , Michal Hocko , Jason Wang , Xuan Zhuo Subject: [PATCH v1 0/5] mm/memory_hotplug: make offline_and_remove_memory() timeout instead of failing on fatal signals Date: Tue, 27 Jun 2023 13:22:15 +0200 Message-Id: <20230627112220.229240-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Rspamd-Queue-Id: D537010001A X-Rspam-User: X-Stat-Signature: 7ki9gueyw7uwqkksxn1jruwpuagrjanr X-Rspamd-Server: rspam03 X-HE-Tag: 1687864953-223504 X-HE-Meta: U2FsdGVkX1/thXYrbQ8tt73GQHO5NEv7OSHq/XesoXiojzrRBgY3Z5RTF7AYgYaMmnBKLV+Bv+5OK+i02poGuYqPjHcYQzP6bsTvQDpD/Q7qyx54Q8ABQBCqx6JTIxX3nzoVBb7wysuMfaK6w3il/BC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+0TUYSqLe/sD9wv0JO7tSHhlXbKVph6pNmCO6mctZOSHOUet301I5EEvnr8dHyWRb1JKiDMe3WFmFs4b6h+vePeRtSCyCr3ReSqg6M4btTJqawBOr/d3SkJmrkQ4l9F3hSJAsISQExrRavUU61Fv1ARreWD+jGzjSzE3MAeuCxdysdFhfxPfHk+biGygKZmjaxGBzP+PtjkmfuP7EC3iEt40oPk2 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: As raised by John Hubbard [1], offline_and_remove_memory() failing on fatal signals can be sub-optimal for out-of-tree drivers: dying user space might be the last one holding a device node open. As that device node gets closed, the driver might unplug the device and trigger offline_and_remove_memory() to unplug previously hotplugged device memory. This, however, will fail reliably when fatal signals are pending on the dying process, turning the device unusable until the machine gets rebooted. That can be optizied easily by ignoring fatal signals. In fact, checking for fatal signals in the case of offline_and_remove_memory() doesn't make too much sense; the check makes sense when offlining is triggered directly via sysfs. However, we actually do want a way to not end up stuck in offline_and_remove_memory() forever. What offline_and_remove_memory() users actually want is fail after some given timeout and not care about fatal signals. So let's implement that, optimizing virtio-mem along the way. Cc: Andrew Morton Cc: "Michael S. Tsirkin" Cc: John Hubbard Cc: Oscar Salvador Cc: Michal Hocko Cc: Jason Wang Cc: Xuan Zhuo [1] https://lkml.kernel.org/r/20230620011719.155379-1-jhubbard@nvidia.com David Hildenbrand (5): mm/memory_hotplug: check for fatal signals only in offline_pages() virtio-mem: convert most offline_and_remove_memory() errors to -EBUSY mm/memory_hotplug: make offline_and_remove_memory() timeout instead of failing on fatal signals virtio-mem: set the timeout for offline_and_remove_memory() to 10 seconds virtio-mem: check if the config changed before (fake) offlining memory drivers/virtio/virtio_mem.c | 22 +++++++++++++-- include/linux/memory_hotplug.h | 2 +- mm/memory_hotplug.c | 50 ++++++++++++++++++++++++++++++++-- 3 files changed, 68 insertions(+), 6 deletions(-) base-commit: 6995e2de6891c724bfeb2db33d7b87775f913ad1