Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1074849ybl; Thu, 12 Dec 2019 09:14:57 -0800 (PST) X-Google-Smtp-Source: APXvYqztxuDW/ngeVqX0nKdEYUrY8r+oFf+Eii/PMk04Kb2tZUzBOhvD+nvrYFxe6LFp+6TtWB3r X-Received: by 2002:aca:d502:: with SMTP id m2mr5540175oig.41.1576170897341; Thu, 12 Dec 2019 09:14:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576170897; cv=none; d=google.com; s=arc-20160816; b=vUZtVdXJV2Zfqc5iBhqihQQ+DbXxxgbZc/R49dmt4STRCpF2z7OP+ydMpyuQNhFfyN kuPpNPTLhEH7/BDFHc1yooHJZrbrf0WmKYlKupasjEQ9jr0xWEOnqReX0RFUi7nEb2j/ quz1HS/YeRaGflclgbDImC6ALKgfhKPHdWv6b6F01tBY/8CCWdpAmTcsehhE1My0asaW 9GV7ZGAeoKlwFnp82mIcVyGLea/3NzSPSLlZ6E5mxyFkFsEqGmuRY/K7pzcUg0KNosP6 R7WE72hRJ7lO1SPRKlm7Bxl6OlUaMd5P/4B3fUo2/zgms9BBIH2eM4jFNu6+jm1/SHdy ZcOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wdeNKnrtxM4ObNLac44ljwb18ODcIBAtiRL+hFA1/ZQ=; b=v0o/LmkPW7U0H3nsdEmYv6ojncx/SZICcmypFTIQVth5JK67LSz/HIs/9Vuc+5p2x3 z6xZTAw0H2qf/K7gZ8BsKEbHWVnwrwxJVjdUoga4+Nvtv6TB8iudoHtkqwLU1rXRzjIx K+qzhn3JjK6wn3/ScfHZit6qhdfzuGe9NBLxN56wYmgnex1e6Ethw+L6mFrtjjAovhJo QlWh3KZkd1LBUdo2QQINq/ZK5nuo84vNNU5wAg6sS9TQQ/aTX04AyV5ZI3QWtYbaroOE +PxsXoGB7J1szme8395PYm91TP2H+7gZ02U9j/QzMewvcWFwHw25yGhiQWJUjJ/pAosQ f7Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="F1Jq6Qi/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si3385563oih.186.2019.12.12.09.14.44; Thu, 12 Dec 2019 09:14:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="F1Jq6Qi/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730233AbfLLRNX (ORCPT + 99 others); Thu, 12 Dec 2019 12:13:23 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:47957 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730097AbfLLRNX (ORCPT ); Thu, 12 Dec 2019 12:13:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576170802; 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=wdeNKnrtxM4ObNLac44ljwb18ODcIBAtiRL+hFA1/ZQ=; b=F1Jq6Qi/b4eUh4H1fbgLIUDolzOYGJI+bwleBsORkOKlcwKd623q0NmAlHpsj33pXi4wIT qt4L6NZ8GVCjKaOqQz+Dnwp35n0o5zofUc14ciJvRcQl93sVKbpatefIlRoGjUB/rmb6BW QV569DAmCdIollps9LHlTbMWjfUctZg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-36-s80F6KfRNRqjBO-zuYg7Sg-1; Thu, 12 Dec 2019 12:13:17 -0500 X-MC-Unique: s80F6KfRNRqjBO-zuYg7Sg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 06391800D53; Thu, 12 Dec 2019 17:13:16 +0000 (UTC) Received: from t480s.redhat.com (ovpn-117-65.ams2.redhat.com [10.36.117.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0516D5C1C3; Thu, 12 Dec 2019 17:13:07 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, virtio-dev@lists.oasis-open.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, Michal Hocko , Andrew Morton , "Michael S . Tsirkin" , David Hildenbrand , Jason Wang , Oscar Salvador , Igor Mammedov , Dave Young , Dan Williams , Pavel Tatashin , Stefan Hajnoczi , Vlastimil Babka Subject: [PATCH RFC v4 10/13] virtio-mem: Better retry handling Date: Thu, 12 Dec 2019 18:11:34 +0100 Message-Id: <20191212171137.13872-11-david@redhat.com> In-Reply-To: <20191212171137.13872-1-david@redhat.com> References: <20191212171137.13872-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let's start with a retry interval of 30 seconds and double the time until we reach 30 minutes, in case we keep getting errors. Reset the retry interval in case we succeeded. Cc: "Michael S. Tsirkin" Cc: Jason Wang Cc: Oscar Salvador Cc: Michal Hocko Cc: Igor Mammedov Cc: Dave Young Cc: Andrew Morton Cc: Dan Williams Cc: Pavel Tatashin Cc: Stefan Hajnoczi Cc: Vlastimil Babka Signed-off-by: David Hildenbrand --- drivers/virtio/virtio_mem.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index 807d4e393427..3a57434f92ed 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -137,7 +137,9 @@ struct virtio_mem { =20 /* Timer for retrying to plug/unplug memory. */ struct hrtimer retry_timer; -#define VIRTIO_MEM_RETRY_TIMER_MS 30000 + unsigned int retry_timer_ms; +#define VIRTIO_MEM_RETRY_TIMER_MIN_MS 30000 +#define VIRTIO_MEM_RETRY_TIMER_MAX_MS 1800000 =20 /* Memory notifier (online/offline events). */ struct notifier_block memory_notifier; @@ -1537,6 +1539,7 @@ static void virtio_mem_run_wq(struct work_struct *w= ork) =20 switch (rc) { case 0: + vm->retry_timer_ms =3D VIRTIO_MEM_RETRY_TIMER_MIN_MS; break; case -ENOSPC: /* @@ -1552,8 +1555,7 @@ static void virtio_mem_run_wq(struct work_struct *w= ork) */ case -ENOMEM: /* Out of memory, try again later. */ - hrtimer_start(&vm->retry_timer, - ms_to_ktime(VIRTIO_MEM_RETRY_TIMER_MS), + hrtimer_start(&vm->retry_timer, ms_to_ktime(vm->retry_timer_ms), HRTIMER_MODE_REL); break; case -EAGAIN: @@ -1573,6 +1575,9 @@ static enum hrtimer_restart virtio_mem_timer_expire= d(struct hrtimer *timer) retry_timer); =20 virtio_mem_retry(vm); + /* Racy (with reset in virtio_mem_run_wq), we ignore that for now. */ + vm->retry_timer_ms =3D min_t(unsigned int, vm->retry_timer_ms * 2, + VIRTIO_MEM_RETRY_TIMER_MAX_MS); return HRTIMER_NORESTART; } =20 @@ -1746,6 +1751,7 @@ static int virtio_mem_probe(struct virtio_device *v= dev) spin_lock_init(&vm->removal_lock); hrtimer_init(&vm->retry_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); vm->retry_timer.function =3D virtio_mem_timer_expired; + vm->retry_timer_ms =3D VIRTIO_MEM_RETRY_TIMER_MIN_MS; =20 /* register the virtqueue */ rc =3D virtio_mem_init_vq(vm); --=20 2.23.0