From patchwork Tue Oct 23 16:43:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 10653441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9937914BD for ; Tue, 23 Oct 2018 16:44:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B7B72A134 for ; Tue, 23 Oct 2018 16:44:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F7DD2A13D; Tue, 23 Oct 2018 16:44:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44BF32A134 for ; Tue, 23 Oct 2018 16:44:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1AA066B000D; Tue, 23 Oct 2018 12:44:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 132B56B000E; Tue, 23 Oct 2018 12:44:03 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EED6F6B0010; Tue, 23 Oct 2018 12:44:02 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by kanga.kvack.org (Postfix) with ESMTP id BA36F6B000D for ; Tue, 23 Oct 2018 12:44:02 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id u14-v6so1116662ybi.3 for ; Tue, 23 Oct 2018 09:44:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:dkim-signature:from:to:cc:subject :thread-topic:thread-index:date:message-id:accept-language :content-language:spamdiagnosticoutput:spamdiagnosticmetadata :content-transfer-encoding:mime-version; bh=PR5w1w1S9NvX8+Jm2ceUxWCy5jJcE4KIzFqrvHni6Dw=; b=dSfY+I9g/9Z8Gf0jnN3dNWtBe6hAkSZA7d5YqrfovmvA/BQZkWEgJPj5tZ5rOneTQw v6XhcTOKzG8pMaWjz4bx3vZ4vP+B/C5Ct1xe0pm6m1p3GEmdu6CaxFRYrAsftLuD65FI n9vSiITOcsRaIgj49H479fCRqw2th+hAOVAd/tBQEOMfH3JgJct+P8grqSh4DCMf0OzS Iy+rDjJPu/bohhdFVoUlOW5IBpch9ZqscpsiCTlP37DADg+7c+Zo7nCKF1kSNdNZEkwG 9d5PtEoimu0s8BK/tk0IeLSqiylqFuPRLH5sR+LNGtrMuQa0C86zAVX2gL0IkFg1MJEa 5rlw== X-Gm-Message-State: ABuFfoj9gHUhRar78Zkl2n0EItmsvv4AZAnYt7RzpodhruoJBXLXsXMj yqeZqP8L6lM3+Pn8I7okW+QtbBr+wZOD0yss8tjox/aFWPiyCtsleaaMWvzCmA35hllVg2KWDmH DDozKQnA0uMMQQ+cv0N3JX0/6vjswfhQLIfQIkjeA9+kXKYEopwbldDTBr5W3/FKI1w== X-Received: by 2002:a81:a243:: with SMTP id z64-v6mr35357572ywg.42.1540313042347; Tue, 23 Oct 2018 09:44:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV632oGYf0PLTM4Pm1uzXbid6ATgOfyoykSfpXLq0e+ni50c28emuRnQHFhMIUnM3Pc5XGg4m X-Received: by 2002:a81:a243:: with SMTP id z64-v6mr35357539ywg.42.1540313041801; Tue, 23 Oct 2018 09:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540313041; cv=none; d=google.com; s=arc-20160816; b=FxDcyRYkLYSabnIcau9W+O6fpqnMxUPbqMzln91kL0UfYMC/txDqjG1n7s45XEO2nX mxW+W7McBoateWc5LQrQfZiC5QXXrICjDiNsAxg+4hHe61+QGdZN/LDNiYsgAHn2LMgd P7DLnK00IgtcYLRAh/uCm6FonjdX79scVQrmCrYO7mLmkKRckFD7ivH18pjR2EfWIgvX kzeIeal4+o61vkk71dVJQ0vcuvJJa8T622aFb/wo4GWnXSQESH/Yg1idP6UnsgEZCIcU cLSgAAv4t7LH6JZEcDWaeXnP7YZa+7cu5dIAqqjEvEq3VbU027Xzf+lGmjModApRfnH4 vQog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:spamdiagnosticmetadata :spamdiagnosticoutput:content-language:accept-language:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :dkim-signature; bh=PR5w1w1S9NvX8+Jm2ceUxWCy5jJcE4KIzFqrvHni6Dw=; b=b4vtP7iqWAxnaxlGNtLM9qpMW2sCkIcqqTKHWELmuNcZbLIIT4cTPa/XHWdsEdgnzH vL8D/O6qssEnk053Kj74rt2HOZLeVYt1M6GbtDR3Z2mXacAbAIZKj2Sbu6shmowB0aFX 7ibS4/Lfyla4AbjUWVmdw4Xwak9QzmRvRPwyopuN7fhrE2hVMM1zLaijVT1EuF07GO4O pkEU/VKAJ72eqg9g9jrHHFMzFQrzcJ+VaS0dlMC89gsRzLTGQht8AHchyoWxntebPKbR bzvLIRELNprNWoKsDDYIjFmLW2uXHNnBzak/n48OiFVB+jgu8lztIlRobsTjJ1ceKjPI HmTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=HPlhpbO2; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=VxA7IoVl; spf=pass (google.com: domain of prvs=383402ec31=guro@fb.com designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=383402ec31=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com. [67.231.145.42]) by mx.google.com with ESMTPS id 131-v6si1081410ybk.15.2018.10.23.09.44.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 09:44:01 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=383402ec31=guro@fb.com designates 67.231.145.42 as permitted sender) client-ip=67.231.145.42; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=HPlhpbO2; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=VxA7IoVl; spf=pass (google.com: domain of prvs=383402ec31=guro@fb.com designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=383402ec31=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9NGgkPt012080; Tue, 23 Oct 2018 09:43:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=facebook; bh=PR5w1w1S9NvX8+Jm2ceUxWCy5jJcE4KIzFqrvHni6Dw=; b=HPlhpbO2g+Y+XwbWnsU4yHKlqV4j/t3ocnCEj6PJ9kTJbrsj2zJaH+ElNDhZRs8KRVC7 uC8fle5tUSIZd1RPRoeovrCp3+VMgYeP7oUsGxmttTYRwRamlH3PCvGqHnrdLEIdcVbM 6eA6hKQBgSZvEZmzf0V3UELDPNZQDHHeMFs= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2na6emg77h-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 23 Oct 2018 09:43:37 -0700 Received: from frc-hub05.TheFacebook.com (2620:10d:c021:18::175) by frc-hub05.TheFacebook.com (2620:10d:c021:18::175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1531.3; Tue, 23 Oct 2018 09:43:34 -0700 Received: from FRC-CHUB01.TheFacebook.com (2620:10d:c021:18::10) by frc-hub05.TheFacebook.com (2620:10d:c021:18::175) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1531.3 via Frontend Transport; Tue, 23 Oct 2018 09:43:34 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.21) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 23 Oct 2018 12:43:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PR5w1w1S9NvX8+Jm2ceUxWCy5jJcE4KIzFqrvHni6Dw=; b=VxA7IoVlsAii+VGgChgcX6JT9NK538+GNPqobeFaUAYN6yxW8S5v2gRhnF/t3ObC3+QGoLxXzzz9LrHSuegLUAXxQ4naigcqIWhf3SrQlpGWK/vt4kP2GPCfoyawS+s/NYAKM8C01/m4B/L/+bH5ES0Is8Ee39pnQPdO6bLjmKg= Received: from BY2PR15MB0167.namprd15.prod.outlook.com (10.163.64.141) by BY2PR15MB0759.namprd15.prod.outlook.com (10.164.171.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.30; Tue, 23 Oct 2018 16:43:29 +0000 Received: from BY2PR15MB0167.namprd15.prod.outlook.com ([fe80::8e8:753:f746:ed14]) by BY2PR15MB0167.namprd15.prod.outlook.com ([fe80::8e8:753:f746:ed14%2]) with mapi id 15.20.1250.028; Tue, 23 Oct 2018 16:43:29 +0000 From: Roman Gushchin To: "linux-mm@kvack.org" CC: "linux-kernel@vger.kernel.org" , Kernel Team , Roman Gushchin , Michal Hocko , Rik van Riel , Randy Dunlap , Andrew Morton Subject: [RFC PATCH] mm: don't reclaim inodes with many attached pages Thread-Topic: [RFC PATCH] mm: don't reclaim inodes with many attached pages Thread-Index: AQHUau+GsFRIu7vNQ0mBGnFYa9WgUw== Date: Tue, 23 Oct 2018 16:43:29 +0000 Message-ID: <20181023164302.20436-1-guro@fb.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MWHPR02CA0007.namprd02.prod.outlook.com (2603:10b6:300:4b::17) To BY2PR15MB0167.namprd15.prod.outlook.com (2a01:111:e400:58e0::13) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2620:10d:c090:200::6:bf0] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BY2PR15MB0759;20:fdOyDHHSjgJskpO7YLB5o14kkEAT9ZpEwbJn6Z6J4h5xMBpNDv0n+CVNYWkEZrzTfo6xT1QBGmDphuHQuTPW6Js8UzGlNmCgaHVmzOvQ4oY8qFjqfHsQfQlZZg2JrllkrrOr20+ozY6/AiyTnRvGe5r859AB2xKhGGpdiRMppxg= x-ms-office365-filtering-correlation-id: 5f202612-01d7-4284-2bf8-08d63906a8c5 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:BY2PR15MB0759; x-ms-traffictypediagnostic: BY2PR15MB0759: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(85827821059158)(67672495146484); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823302103)(3002001)(3231355)(11241501184)(944501410)(52105095)(10201501046)(93006095)(93001095)(148016)(149066)(150057)(6041310)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BY2PR15MB0759;BCL:0;PCL:0;RULEID:;SRVR:BY2PR15MB0759; x-forefront-prvs: 0834BAF534 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(366004)(346002)(136003)(396003)(376002)(189003)(199004)(476003)(36756003)(46003)(1076002)(81156014)(14454004)(25786009)(2616005)(8936002)(386003)(106356001)(6916009)(2900100001)(4326008)(54906003)(2351001)(316002)(2906002)(97736004)(6512007)(575784001)(478600001)(53936002)(86362001)(186003)(5640700003)(99286004)(7736002)(486006)(52116002)(102836004)(6436002)(6506007)(6486002)(71200400001)(5250100002)(68736007)(8676002)(71190400001)(2501003)(5024004)(14444005)(81166006)(256004)(5660300001)(6116002)(305945005)(105586002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR15MB0759;H:BY2PR15MB0167.namprd15.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: fb.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: EFht1TZby7aqqtXOxj0JTXiYqz2M6HPKsQ6dgJTMyLgQLD0jUDHf7sAs3kkzN50m71wPrIZRC2fYd3fgynNPavgVsq/nDszBkh5coFpIVCL14/CfujMeV4PZGNTjzvgn7VYJg3mdINPisq39MwxZGSNVkEMtK5+UYWJ9E66XWNiFKtCnAC4vTqYE8N2OXTLBojbuSfB9t9jYSnCbKf4gKVzryc4JB8RxAljTrT88gHr/8UzgAKP9glX8eEeH5UH6JN6hGTEiHoq/t0MdDp5aGjbQ2UMYtxHtff59LK6cMt1Ki7U7jJnfP9Sys4tB+b7LssAqiMq+lPJKw/AqoaamAjp+qh8S1T7mjW/iT/sSmZM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 5f202612-01d7-4284-2bf8-08d63906a8c5 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2018 16:43:29.0460 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR15MB0759 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-23_04:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe 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: X-Virus-Scanned: ClamAV using ClamSMTP Spock reported that the 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. Reported-by: Spock Signed-off-by: Roman Gushchin Cc: Michal Hocko Cc: Rik van Riel Cc: Randy Dunlap Cc: Andrew Morton --- fs/inode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 73432e64f874..0cd47fe0dbe5 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -730,8 +730,11 @@ static enum lru_status inode_lru_isolate(struct list_head *item, 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;