From patchwork Tue Jun 27 11:22:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13294366 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 09A1BC001B1 for ; Tue, 27 Jun 2023 11:22:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97E338D0007; Tue, 27 Jun 2023 07:22:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9079B8D0003; Tue, 27 Jun 2023 07:22:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70CF28D0007; Tue, 27 Jun 2023 07:22:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 571898D0003 for ; Tue, 27 Jun 2023 07:22:42 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2C311A092F for ; Tue, 27 Jun 2023 11:22:42 +0000 (UTC) X-FDA: 80948290164.22.D43987D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 654101A000C for ; Tue, 27 Jun 2023 11:22:40 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="b/a92jyL"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of david@redhat.com designates 170.10.133.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=1687864960; 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:in-reply-to:references:references:dkim-signature; bh=T3lZgYf4GUx7yLsElB4csYTB1LQXvieCj0NGb4r43Kk=; b=6U6UTZTvMrWzvaZw4h6M5sCl8LQDO7G7F+biGWMthi1kVYJQLX+plY71588Td0ebATkWu4 LfNmWkj/LEJG72D8urJ4zcme8efaDFATGM1Inb4srgliZpNW88pO6vPolHokXV6cLAOdwm lQYFMfMH1cV5ZdTDR4nxow6E2KD/JPM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="b/a92jyL"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687864960; a=rsa-sha256; cv=none; b=jJC1bhmTo/iLfF92/FdL6R4Mi8O648octsemkgVKzZhe/RlxRxqfxMmQaFGlRdeGAJAV1n nzl96DZEHU+2FwbviOjlAA/jAMlk4zIwb7KyROYPUxgY2/+psIW1f+l7tL3BdglMqUPvjs iaaaQGVlXst2CUi0jb5Q6O9egR9eqEI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687864959; 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=T3lZgYf4GUx7yLsElB4csYTB1LQXvieCj0NGb4r43Kk=; b=b/a92jyLnP5/ODfL+PGt7EB4l/b1ULIakSdTlpvOwlCbKFkKeTLLJ723acem4M1V3VZOrO AMs7hkOf6FAnfn89uHZPGDju4aGDyrgX9x1EerSevl7xCgdbg72xZGYT9TvJ/PggaaNFQt F43OJiVtBT1jrUPoFopHzr4/T7llAVg= 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-354-SGCc500YMA6d6vSpb4530Q-1; Tue, 27 Jun 2023 07:22:36 -0400 X-MC-Unique: SGCc500YMA6d6vSpb4530Q-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 A4EBE1C07588; Tue, 27 Jun 2023 11:22:35 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.192.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5588200A3AD; Tue, 27 Jun 2023 11:22:33 +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 4/5] virtio-mem: set the timeout for offline_and_remove_memory() to 10 seconds Date: Tue, 27 Jun 2023 13:22:19 +0200 Message-Id: <20230627112220.229240-5-david@redhat.com> In-Reply-To: <20230627112220.229240-1-david@redhat.com> References: <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: 654101A000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: bgsuu4dix1ci4nj8izfcms66t755ut18 X-HE-Tag: 1687864960-128858 X-HE-Meta: U2FsdGVkX18OPbBCQaeGroMUENmcg22bMQ/4IovELVI260odazuw3w2viXqNRAdaXSyXuvvlAiLnV8FXyZWcAkMi0x+IbGSbr7LYg/JPjiZC85wgr5v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z1KDhwhNw== 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: Currently we use the default (30 seconds), let's reduce it to 10 seconds. In BBM, we barely deal with blocks larger than 1/2 GiB, and after 10 seconds it's most probably best to give up on that memory block and try another one (or retry this one later). In the common fake-offline case where we effectively fake-offline memory using alloc_contig_range() first (SBM or BBM with bbm_safe_unplug=on), we expect offline_and_remove_memory() to be blazingly fast and never take anywhere close to 10seconds -- so this should only affect BBM with bbm_safe_unplug=off. While at it, update the parameter description and the relationship to unmovable pages. Signed-off-by: David Hildenbrand --- drivers/virtio/virtio_mem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index f8792223f1db..7468b4a907e3 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -41,7 +41,7 @@ MODULE_PARM_DESC(bbm_block_size, static bool bbm_safe_unplug = true; module_param(bbm_safe_unplug, bool, 0444); MODULE_PARM_DESC(bbm_safe_unplug, - "Use a safe unplug mechanism in BBM, avoiding long/endless loops"); + "Use a safe/fast unplug mechanism in BBM, failing faster on unmovable pages"); /* * virtio-mem currently supports the following modes of operation: @@ -738,7 +738,7 @@ static int virtio_mem_offline_and_remove_memory(struct virtio_mem *vm, "offlining and removing memory: 0x%llx - 0x%llx\n", addr, addr + size - 1); - rc = offline_and_remove_memory(addr, size, 0); + rc = offline_and_remove_memory(addr, size, 10 * MSEC_PER_SEC); if (!rc) { atomic64_sub(size, &vm->offline_size); /*