Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3108286imu; Mon, 19 Nov 2018 10:43:59 -0800 (PST) X-Google-Smtp-Source: AJdET5cVgXbQ3cHiKg5/QyJdaSJkKcWpkXRN4uBw3BZ1SOxHgVPWh1URr3wRuE9C6idPA4WUdTn9 X-Received: by 2002:a17:902:6bc1:: with SMTP id m1-v6mr23927481plt.34.1542653039760; Mon, 19 Nov 2018 10:43:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653039; cv=none; d=google.com; s=arc-20160816; b=vqksXGCVlZizKBDwzPIvYvZLjN8rCBHhgBWJCyiMMZC0jmgq+puVGF7a0Pb8LaiN9r kMg6NjmQP4H+7qqdnO71GUS5jGiWHno+tXvy33hs23BiSl8t+2tH0V3mxXHC7djQrkcm 208tPzF3TbfbbcyBnG4A0jwe4VbHBdYqpLfkEmXTqYX+aut4xwI6Hv+esaQOmi6f92Bd nFbUcZcc5D0njtJCuXZOjjLXZfxfQ6lXXpiSe5vclKFEpk49UH2DrAFZc2GoP2l311cX xn/ntlFdOQQTvnqcf8Y/DVBDVYJWFAyOt20+jqLda0F0/BeWtrjAilgwWS2acSq2/zT+ 9alQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=D8PlG8BpcaeVEb4Skc17iBZVpbz9Bq+XVOWhxeZuzWQ=; b=W5gDKnfjTTndu4ZaHhJPSsbPaLR99HTxyzbecTBTM7SEZwlNR5uiMT4kSHwB/T5DOH aQWdFRF5vcIOWcgE2j5LzrThllKwSWbGRaMzFHyywWpwkKuzosKREb8sB11+9NjSI5z/ AB8KJ62VXeC8GXxLzkAwS3sv2vGJUZ13ZuxgWcBkb4ByFtWNd7FLsMyESq8p5yrNdkwx XFZukORxFin7LpNUP9Vj9SvNSsyJxV6IhbnHEl94gGmx7y9FFeMnza1NO2s9ru9C4/1z TgQIzBb06P8tcnqDxdruLArm7w/DM+2KNoIwKpqpYolXosnAK3Ty/wbGzneN0IJhoUqm xY9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SiL++vtK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r14si29219018pgh.39.2018.11.19.10.43.44; Mon, 19 Nov 2018 10:43:59 -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=@kernel.org header.s=default header.b=SiL++vtK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732278AbeKTDBw (ORCPT + 99 others); Mon, 19 Nov 2018 22:01:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:33956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730719AbeKTDBv (ORCPT ); Mon, 19 Nov 2018 22:01:51 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C729520989; Mon, 19 Nov 2018 16:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542645462; bh=+oShAXByvRILOqXXDWbQpKhtTskWfah/GmYqoObqqeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SiL++vtK4stLmT8t8uAHv7ZhWHy3qH5QYna5/2QqEjsBnlFVYhNiyXFqRFQWZlF28 +58ihzw3ikPcATmKz+MIqSEK+BCx36N/cQLvPr90+niUadC9tYHRVxjYp5vH7oGVvd qMINqi8yLv6ZKvpEIAhJ+LAIVpmz7xrFIfdTf5n0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roman Gushchin , Spock , Andrew Morton , Michal Hocko , Rik van Riel , Randy Dunlap , Linus Torvalds Subject: [PATCH 4.19 171/205] mm: dont reclaim inodes with many attached pages Date: Mon, 19 Nov 2018 17:27:58 +0100 Message-Id: <20181119162640.474322772@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162616.586062722@linuxfoundation.org> References: <20181119162616.586062722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Roman Gushchin commit a76cf1a474d7dbcd9336b5f5afb0162baa142cf0 upstream. Spock reported that commit 172b06c32b94 ("mm: slowly shrink slabs with a relatively small number of objects") leads to a regression on his setup: periodically the majority of the pagecache is evicted without an obvious reason, while before the change the amount of free memory was balancing around the watermark. The reason behind is that the mentioned above change created some minimal background pressure on the inode cache. The problem is that if an inode is considered to be reclaimed, all belonging pagecache page are stripped, no matter how many of them are there. So, if a huge multi-gigabyte file is cached in the memory, and the goal is to reclaim only few slab objects (unused inodes), we still can eventually evict all gigabytes of the pagecache at once. The workload described by Spock has few large non-mapped files in the pagecache, so it's especially noticeable. To solve the problem let's postpone the reclaim of inodes, which have more than 1 attached page. Let's wait until the pagecache pages will be evicted naturally by scanning the corresponding LRU lists, and only then reclaim the inode structure. Link: http://lkml.kernel.org/r/20181023164302.20436-1-guro@fb.com Signed-off-by: Roman Gushchin Reported-by: Spock Tested-by: Spock Reviewed-by: Andrew Morton Cc: Michal Hocko Cc: Rik van Riel Cc: Randy Dunlap Cc: [4.19.x] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/inode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/fs/inode.c +++ b/fs/inode.c @@ -730,8 +730,11 @@ static enum lru_status inode_lru_isolate return LRU_REMOVED; } - /* recently referenced inodes get one more pass */ - if (inode->i_state & I_REFERENCED) { + /* + * Recently referenced inodes and inodes with many attached pages + * get one more pass. + */ + if (inode->i_state & I_REFERENCED || inode->i_data.nrpages > 1) { inode->i_state &= ~I_REFERENCED; spin_unlock(&inode->i_lock); return LRU_ROTATE;