Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp110000ybx; Thu, 31 Oct 2019 16:52:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqx614lRc/CnkMAKUj+34WFMv+n6jp8F8vfRWwo9msSU6Oy7KJ8uw6Ous0zBMPOUvUkMuvQw X-Received: by 2002:a17:906:49cd:: with SMTP id w13mr5465515ejv.311.1572565936803; Thu, 31 Oct 2019 16:52:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572565936; cv=none; d=google.com; s=arc-20160816; b=OiMP4vbEnTBZT+DkdsZceRz3va0kYkn31U/lms8CKdvSKQOMSuZNAjw5LWMcd3INrH /ROQipqQ60qCXkDYrRFbcXtIyC6xpIJ5tP1VqYO/xD2NTe3QhfYU8JHe8VbpisS72XT8 udCn6nqb0KZohda6pPaLs/FXuldCFwPIgXCdU0d6NeNxJ+CXlSNeOmJ6PhfY3ihsOPD2 IbzJnwVZ7Oocr9yoiKld68ji9m0Y3/GOAq2H34ruWmNdGaRKmsbqBNrH6Pif3cq96ICo ThCGDFxlDf7mvGa80Ij0T8QipAnTH2jT8ALia7dm4Zx7YiwOJNTrHuPqzFiI8+5CwikW 9XUA== 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; bh=ZIFvpYuMCRI0ajDPI4v4xz3Ja98encG0JmVfcvqQBFw=; b=igRU+prFGUMqxP4c6rC8mMZxXlLac2ssk8QP7smDXb/yofS7oB6zHTPsDTW2Xe1rjW T4+xOdpE3yXTpl4UJvysr3+QQVWA/whrZKljFqhYIdNLVsEiNdSAyasFoCxwhQVz7LKi RUtfLPfGuXOVJhmZKkFG2x0aZlQ3O+BVBenm0ykUtIIi1oDFB4jdar0B0BNP3fyLetqZ IEs60YFqLjtgIP3DmzqS7vXerTCsEE7yId19Jsq3zWJwBRq++QAGOy9Pb6U+/6MTqO0S S0M7ytv3iYU45uNeNT2f+O+NUr7dDnizPQfxUNvomToCJpsbPeq5LWrNKmEv2Gzlg52D UbLw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s15si6384336eds.217.2019.10.31.16.51.53; Thu, 31 Oct 2019 16:52:16 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729756AbfJaXsc (ORCPT + 99 others); Thu, 31 Oct 2019 19:48:32 -0400 Received: from mail104.syd.optusnet.com.au ([211.29.132.246]:40133 "EHLO mail104.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728380AbfJaXq2 (ORCPT ); Thu, 31 Oct 2019 19:46:28 -0400 Received: from dread.disaster.area (pa49-180-67-183.pa.nsw.optusnet.com.au [49.180.67.183]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 944467EA8F9; Fri, 1 Nov 2019 10:46:21 +1100 (AEDT) Received: from discord.disaster.area ([192.168.253.110]) by dread.disaster.area with esmtp (Exim 4.92.3) (envelope-from ) id 1iQK8x-0007C2-3o; Fri, 01 Nov 2019 10:46:19 +1100 Received: from dave by discord.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1iQK8x-00041L-1j; Fri, 01 Nov 2019 10:46:19 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/28] xfs: Improve metadata buffer reclaim accountability Date: Fri, 1 Nov 2019 10:45:54 +1100 Message-Id: <20191031234618.15403-5-david@fromorbit.com> X-Mailer: git-send-email 2.24.0.rc0 In-Reply-To: <20191031234618.15403-1-david@fromorbit.com> References: <20191031234618.15403-1-david@fromorbit.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=G6BsK5s5 c=1 sm=1 tr=0 a=3wLbm4YUAFX2xaPZIabsgw==:117 a=3wLbm4YUAFX2xaPZIabsgw==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=MeAgGD-zjQ4A:10 a=20KFwNOVAAAA:8 a=1dk79d6Hl8FtNpQQbMkA:9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Chinner The buffer cache shrinker frees more than just the xfs_buf slab objects - it also frees the pages attached to the buffers. Make sure the memory reclaim code accounts for this memory being freed correctly, similar to how the inode shrinker accounts for pages freed from the page cache due to mapping invalidation. We also need to make sure that the mm subsystem knows these are reclaimable objects. We provide the memory reclaim subsystem with a a shrinker to reclaim xfs_bufs, so we should really mark the slab that way. We also have a lot of xfs_bufs in a busy system, spread them around like we do inodes. Signed-off-by: Dave Chinner --- fs/xfs/xfs_buf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 1e63dd3d1257..d34e5d2edacd 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -324,6 +324,9 @@ xfs_buf_free( __free_page(page); } + if (current->reclaim_state) + current->reclaim_state->reclaimed_slab += + bp->b_page_count; } else if (bp->b_flags & _XBF_KMEM) kmem_free(bp->b_addr); _xfs_buf_free_pages(bp); @@ -2061,7 +2064,8 @@ int __init xfs_buf_init(void) { xfs_buf_zone = kmem_zone_init_flags(sizeof(xfs_buf_t), "xfs_buf", - KM_ZONE_HWALIGN, NULL); + KM_ZONE_HWALIGN | KM_ZONE_SPREAD | KM_ZONE_RECLAIM, + NULL); if (!xfs_buf_zone) goto out; -- 2.24.0.rc0