From nobody Sun Feb 8 10:48:53 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C39BEC0015E for ; Thu, 13 Jul 2023 14:57:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232094AbjGMO5O (ORCPT ); Thu, 13 Jul 2023 10:57:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232185AbjGMO5I (ORCPT ); Thu, 13 Jul 2023 10:57:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A7EF2736 for ; Thu, 13 Jul 2023 07:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689260163; 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: in-reply-to:in-reply-to:references:references; bh=tvagZqP7r7JhOH2HSmKVW5dMeNgJcBr/tywkzsCuQEE=; b=A7w+xqn0O/UJ5p9zcT/RyhNdgkV2iHLGUc94tQsJvw+HLWijwypNicycYpfr1+0r9Icsgr HbpC11K+zoPidJw4RCSlYBKJyCEW6gizaTXtKZJER+tUISXa/uz1DTXAHbNUGDHwX2T11/ HSgKRIi9Lr0s2UWkVcBZsYrOaqqz/8Q= Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-13-nm4gKlnDNE-L9galCwEr3g-1; Thu, 13 Jul 2023 10:55:59 -0400 X-MC-Unique: nm4gKlnDNE-L9galCwEr3g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 640A63815F7E; Thu, 13 Jul 2023 14:55:59 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.245]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0225F66D7; Thu, 13 Jul 2023 14:55:57 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, virtualization@lists.linux-foundation.org, David Hildenbrand , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo Subject: [PATCH v1 2/4] virtio-mem: convert most offline_and_remove_memory() errors to -EBUSY Date: Thu, 13 Jul 2023 16:55:49 +0200 Message-ID: <20230713145551.2824980-3-david@redhat.com> In-Reply-To: <20230713145551.2824980-1-david@redhat.com> References: <20230713145551.2824980-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Just like we do with alloc_contig_range(), let's convert all unknown errors to -EBUSY, but WARN so we can look into the issue. For example, offline_pages() could fail with -EINTR, which would be unexpected in our case. Signed-off-by: David Hildenbrand --- drivers/virtio/virtio_mem.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index ed15d2a4bd96..1a76ba2bc118 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -741,11 +741,15 @@ static int virtio_mem_offline_and_remove_memory(struc= t virtio_mem *vm, * immediately instead of waiting. */ virtio_mem_retry(vm); - } else { - dev_dbg(&vm->vdev->dev, - "offlining and removing memory failed: %d\n", rc); + return 0; } - return rc; + dev_dbg(&vm->vdev->dev, "offlining and removing memory failed: %d\n", rc); + /* + * We don't really expect this to fail, because we fake-offlined all + * memory already. But it could fail in corner cases. + */ + WARN_ON_ONCE(rc !=3D -ENOMEM && rc !=3D -EBUSY); + return rc =3D=3D -ENOMEM ? -ENOMEM : -EBUSY; } =20 /* --=20 2.41.0