Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3920057imu; Mon, 10 Dec 2018 09:53:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/VRZTa8vKmrKlXXfVnO8o8TQVHlXXv8poLR8+4U4EzLhLjEwqcPCiFjenDH0OHz4oVCfCnM X-Received: by 2002:a63:9749:: with SMTP id d9mr8867686pgo.415.1544464399755; Mon, 10 Dec 2018 09:53:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544464399; cv=none; d=google.com; s=arc-20160816; b=diuKEPQoYcF8JrPzSc5FsHjBUGim7/BGXIsfcAZC2i7cduq+Pt5H1Yrc5E42UolfRc GrYSV/bvkKydjlYkc8Kd+j22/6J5R0tbODO3gHxbUODqUZ3x2PRsBUObXANh1YNEn9Zb gfwujBnIpZDOzCORWmK90B12lfDUCF923IByZpFgcPMts6glAlsr5EwYPyA4cayWqVS3 uEFkzuHX7AfnQpX+Kic9dSjUP6E4ptdV2tLsl5lWpWLYpowLe9j1H0Qn3eil5nO1yAZW 5qr7YcLdWsZUGJh50VYD+ubJEP6FLYv720kWBP6p7ohLWB6Til4XXX66liIdLPatTvh9 SGYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=GcKDkEpvvH2tisiFRMdkNvgEYqHbT8wRbqq8Np/bp3c=; b=OQIeeem4sS/QWxIzvLUH4NIlUlaKZazeuNMzsJH88t4gg7uH9Ank/gytGjy5padiaw SoktYZ+hFCYARxB33a/1uYIQC87QpT4Sf7/VPtdSWWbEkR8LRSR3n/GkNaCmPKpnLZyG 1wWFEmBDiQIWd8R+5qRSERZthfYSKdnTb+d3Mam44+H5GGJZTcSBA2latMEU4TDzXSpp cmgPBSVRPjECv+mQu/zedjVkrbUDXZBI7tqsh8s8rXkksKzcP/LjzK1Kq0A54zxE9MpT 9CZMp1dycVaNn+gRNVA+CHHTCxotUASi3TwUDTn2+cDZE1juOEabap4vCCBTWA0ZaKjn T4Jw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 w7si11322514pfw.200.2018.12.10.09.53.04; Mon, 10 Dec 2018 09:53:19 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728816AbeLJRPi (ORCPT + 99 others); Mon, 10 Dec 2018 12:15:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55354 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728471AbeLJRNi (ORCPT ); Mon, 10 Dec 2018 12:13:38 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64BE6804E3; Mon, 10 Dec 2018 17:13:38 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18420101962A; Mon, 10 Dec 2018 17:13:35 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id A6FB7224275; Mon, 10 Dec 2018 12:13:30 -0500 (EST) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: vgoyal@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com, sweil@redhat.com, swhiteho@redhat.com Subject: [PATCH 41/52] fuse: Reschedule dax free work if too many EAGAIN attempts Date: Mon, 10 Dec 2018 12:13:07 -0500 Message-Id: <20181210171318.16998-42-vgoyal@redhat.com> In-Reply-To: <20181210171318.16998-1-vgoyal@redhat.com> References: <20181210171318.16998-1-vgoyal@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 10 Dec 2018 17:13:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fuse_dax_free_memory() can be very cpu intensive in corner cases. For example, if one inode has consumed all the memory and a setupmapping request is pending, that means inode lock is held by request and worker thread will not get lock for a while. And given there is only one inode consuming all the dax ranges, all the attempts to acquire lock will fail. So if there are too many inode lock failures (-EAGAIN), reschedule the worker with a 10ms delay. Signed-off-by: Vivek Goyal --- fs/fuse/file.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index dbe3410a94d7..709747458335 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -3909,7 +3909,7 @@ int fuse_dax_free_one_mapping(struct fuse_conn *fc, struct inode *inode, int fuse_dax_free_memory(struct fuse_conn *fc, unsigned long nr_to_free) { struct fuse_dax_mapping *dmap, *pos, *temp; - int ret, nr_freed = 0; + int ret, nr_freed = 0, nr_eagain = 0; u64 dmap_start = 0, window_offset = 0; struct inode *inode = NULL; @@ -3918,6 +3918,12 @@ int fuse_dax_free_memory(struct fuse_conn *fc, unsigned long nr_to_free) if (nr_freed >= nr_to_free) break; + if (nr_eagain > 20) { + queue_delayed_work(system_long_wq, &fc->dax_free_work, + msecs_to_jiffies(10)); + return 0; + } + dmap = NULL; spin_lock(&fc->lock); @@ -3955,8 +3961,10 @@ int fuse_dax_free_memory(struct fuse_conn *fc, unsigned long nr_to_free) } /* Could not get inode lock. Try next element */ - if (ret == -EAGAIN) + if (ret == -EAGAIN) { + nr_eagain++; continue; + } nr_freed++; } return 0; -- 2.13.6