From patchwork Mon Apr 24 16:41:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 9696767 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ED51D60224 for ; Mon, 24 Apr 2017 16:40:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA43C267EC for ; Mon, 24 Apr 2017 16:40:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD4CB28346; Mon, 24 Apr 2017 16:40:58 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47490267EC for ; Mon, 24 Apr 2017 16:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S974873AbdDXQkp (ORCPT ); Mon, 24 Apr 2017 12:40:45 -0400 Received: from mail-eopbgr50103.outbound.protection.outlook.com ([40.107.5.103]:57281 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S974841AbdDXQkf (ORCPT ); Mon, 24 Apr 2017 12:40:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=LSeE/OCc+uA9qAbeBU5Wlqu9lo0hDyQOMP3IMbyBRg8=; b=Y0F40hJhJ9SSP5lyxTfjQw+7PlZ8n5E/5vL/V4zERlw5bLPvR0A1EJ/laQ9tKY4ZsgP8HbqzML4zPhYs0gqIAvjYyhXa1A65l9sIAlOH3Mmfppyd4VJj23S6N1pQ+rnwJbESTr7As8AwLeO5Nb7Z7ZIcC65lks3OW1hCUstlfa0= Authentication-Results: zeniv.linux.org.uk; dkim=none (message not signed) header.d=none;zeniv.linux.org.uk; dmarc=none action=none header.from=virtuozzo.com; Received: from localhost.sw.ru (195.214.232.6) by AM4PR0801MB2723.eurprd08.prod.outlook.com (2603:10a6:200:14::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.13; Mon, 24 Apr 2017 16:40:28 +0000 From: Andrey Ryabinin To: Alexander Viro CC: Andrey Ryabinin , Konrad Rzeszutek Wilk , Ross Zwisler , Andrew Morton , Jan Kara , Jens Axboe , Johannes Weiner , Alexey Kuznetsov , Christoph Hellwig , Nikolay Borisov , , , Subject: [PATCH v2 3/4] mm/truncate: bail out early from invalidate_inode_pages2_range() if mapping is empty Date: Mon, 24 Apr 2017 19:41:34 +0300 Message-ID: <20170424164135.22350-4-aryabinin@virtuozzo.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170424164135.22350-1-aryabinin@virtuozzo.com> References: <20170414140753.16108-1-aryabinin@virtuozzo.com> <20170424164135.22350-1-aryabinin@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: AM4PR0101CA0014.eurprd01.prod.exchangelabs.com (2603:10a6:200:2e::24) To AM4PR0801MB2723.eurprd08.prod.outlook.com (2603:10a6:200:14::25) X-MS-Office365-Filtering-Correlation-Id: 14201025-847c-4699-e163-08d48b309f0d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:AM4PR0801MB2723; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0801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mPL+kHKfOHLbZgyC66e4=; 20:Ps4j4+hmjE3zkD73d7s2NpRuMKNGJW5vtDBxDRwlSP+8IBYrfZZLLB2WLn44daXauM7ohPmQEg+pJnfCfYqHCfiNz59vRWen8WuAQSgdNIhuvCXugR4sr9yaPl+ulf6XY/lTbwMwEo2FPAVmDSoTDHuLoRIqHWirbvMNvzkxQ/o5waahr03rc+Qq2CWxLFUUpumQzFy5jjwkubZxok3blmOsgZIYHCUytax6/vK8qvIKU+/C+EKiRB2OGAeWyNriTC69On6VPChtSCPuat6a49kVfLQihyHfUAiHO4vnLIFUSwDOL8OZCyi/coG+56EyGlu2mHpZoh55+RGydlc7u3/JgcyKYpovPz+8Qc0Saaqt8reNRUa1XvXyrZg/HkSaEqQWhO9fRl0HBlW0Q3NeCMSrUZnENgNCBnhtDN/h64M= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(146099531331640); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123562025)(20161123555025)(20161123564025)(6072148); SRVR:AM4PR0801MB2723; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0801MB2723; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0801MB2723; 4:qLXzZJPkhOfntIiBmQz173KQloLOKLe63xNBB7yNEfSnSTpw2sbi11XMY5ydeKC85imBO7sBarOulywDTAXCLQnOGcditAV3KsWxjorxFK2Sd4pa+YsQZXqd6MSHqJCOZg8OqlwYDRp6oiXm7XD6DRgZoSbp7b1TXfFu+iwBHGUE5hhrhAAIIPdq3BammNTFeJhw0YcVKoH1BbGcGptYLOf7L6YQIOhGkVKLJRKCeQzfTS8cJhFdeZrXFK5LobELLCTcVlqPwex1LNvLa8mUgQnJxNjA1hC9TPmPakpcBgg3J1F7yobif47qM9AMkFbg2g1TS0LKXsi6EOpFx5Z1IUfkd3RfmNEZCOhEHyHkwbM7ea5ceSCCTpsMVg1u6sc67n0rUMqKmJssEkZZbvL94paOEZ5BdlnonbkJ5YCZqzKhWZRipDFHTpmrYQxu0mC1Szq+sX/qp4WKGgGndGoO2K955wfRnic5amLXl+xoCR7tkl7NTjrTanvcluzLNVxsCjJ+fZAFWhBJz5BqCdh9TuVJcVL9GaaOufUWa6lw1NRPrX9PHnmYCTGudXBfgn62mATZIBhQqSGigVSFF+miSwxzs4H1kjqzMHy8ISStbBAa4Sa4v25x4kudzPEwUoXSPYqdtoq9zD4v8SkRfgb2oBuWpN4BxLLf7HVoBCrlPd9QQ51AsYgMOYayxyk2ChBDKObADdy6ylSP/3AbX0XqadxNFA/cW8lpGzHiS/PuaOeMg8cjY7SSTXEuoFcjO0GuCY5FIudC/SkNnqK6HXjm6g== X-Forefront-PRVS: 0287BBA78D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(39410400002)(39400400002)(39840400002)(39450400003)(1076002)(3846002)(7416002)(38730400002)(36756003)(110136004)(50226002)(4326008)(6116002)(50986999)(76176999)(53936002)(25786009)(86362001)(575784001)(6506006)(189998001)(6486002)(2950100002)(2906002)(6512007)(33646002)(50466002)(48376002)(6916009)(5660300001)(6666003)(5003940100001)(54906002)(42186005)(7736002)(47776003)(81166006)(66066001)(8676002)(76506005)(53416004)(305945005)(15760500002); DIR:OUT; SFP:1102; SCL:1; SRVR:AM4PR0801MB2723; H:localhost.sw.ru; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR0801MB2723; 23:FCof1mbNkJ5bbM7lofO5B/uGjlK32AlgdDgM1qu?= =?us-ascii?Q?YpInQMyRHhRJiIDcTETLSwgbimLJ9kzh+2JzvS+cFA7I13WkyAjjOyxjGV1E?= =?us-ascii?Q?s4Fp3ILZ1oXRE+VoJDHx7fX1OiKPizTgbG3ru6c84LG9/yHLLDoSAjTjRN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DByOjsjn9l/Dfe7U/jFGjgLtMyNJezGGY2xEjpw2+Rvuj?= =?us-ascii?Q?q/2yQK4OPe9f813SH2THE137hSJRmiupB0teCZjS7JBK/2qBbp2/WwOdwZAc?= =?us-ascii?Q?TsFvVpY6qMlAYmpvzUGHnuyIRFoCR0o7T?= X-Microsoft-Exchange-Diagnostics: 1; AM4PR0801MB2723; 6:CSBBBW1Mnsde12ZDU0eham4UarqQZ2WWOc+KXSkdn+WfHd01/NvO9JFu73fylKlI36a29QQgIH+pOvVP9a9nPTN/sa3Fz8lNFR5SZenxOK7DkKE4WUNo2+EFhQkimtJAPZADNsZEyS37qIP/OTcsHkQI4vmRCPykP7G7FUOTfmElh6q3P5k1O+TrMgL98tcAp85qIRwJ/7krZZ+pNPd06ixuQRsmfV+H6GclGBRF4CJq48b7q7a0qhd6A8JBDqPHc2WsEj10B5Qy1g4qI9V851qV/eSwYUoBgP/es66gPAhfXP8Tq6S4K/uPEdY8DYdVgXv1rWkJnSYZgvFuau/XzrUAy2JgzQMNrR/4pWdnnE5NSjQRGxsoNflY73CyoYq5OQRA7OwlX4uAhCEyKiiLrpwbPad+DpifNZ27y/szcocKr7zw2/jBwD+3p6jWl6BeyVki/rhR3maTVPkM3yzBaawJa7qnc1UHk/utcinNaiolLim9akAtNOtPCqL9MXMleZMc7644M2ACswIYhFvoiw==; 5:gpzMqD+IEo8WF3/jycxDkut3fVb7q+YdDvuuEcDzs6ePoMomLm4B3ijZgHhXrPZ8m0iql42P9LOwIr9QoXhs0RfTNdZ9Gcz6b+SZjTjdkfi5XozAvVIqtQs9Aj+7w9pGHGhwFESnpD3zPFAKGfHeAA==; 24:p0C+uBJYTeAJrCwJ/fST/N/1dhboes0A6zQw/bBhdJc/bMP/skhw3r3VecjB7bykqz6nSA5wazREW58xCXv5KWF39VjFVb2pd4k18sQjkkI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM4PR0801MB2723; 7:Gnpx+4qufqgQyEghzUzgIj+OQbIPG16vvJwUOcJ0qtIlD9FcjfapYQAT17BPFZknRdeXYDtn7I2sdOaseZ4bTdnBQqg7KIqke/EZml7nUdeI38Zi9JS6NmWurJprKKP/LLagfZi8hUfBk6PIMw/35j9ML2ATOEon7ztg/fY69Sm6fLZCdBNarda7h+L5Qu8dljRJEFN4/5YlJm7tR99bKskEVAn+NuuI9+ntYju4EvFel/x7J4q2kgTZA4MKQ/DR19UYuc6V3w2CfewuWXOwYBBVISdJSzTU+xNKwHoD/jQCjdh8YJldZHy5vK++Rlt9ZDhlXBBwWVpZ2sXcSc2p4A==; 20:uK8wDUbhuE/3C0VI+nFR31+fkqBCGt7gitN+ZHbWCct2j4vqmW+PZek2BZTMumSjbdnLk36YdCnyyON8/t+vpaM1ArjS3xa3pzs5LUmtnPhhwhmD34cB3gjg6iYIlhh6rYg0XwOY+NNLMa+lPZ8dkl0NPy22UGhBWll0TsibXak= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2017 16:40:28.4253 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0801MB2723 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If mapping is empty (both ->nrpages and ->nrexceptional is zero) we can avoid pointless lookups in empty radix tree and bail out immediately after cleancache invalidation. Signed-off-by: Andrey Ryabinin Acked-by: Konrad Rzeszutek Wilk Reviewed-by: Jan Kara --- mm/truncate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/truncate.c b/mm/truncate.c index 6263aff..8f12b0e 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -624,6 +624,9 @@ int invalidate_inode_pages2_range(struct address_space *mapping, int did_range_unmap = 0; cleancache_invalidate_inode(mapping); + if (mapping->nrpages == 0 && mapping->nrexceptional == 0) + return 0; + pagevec_init(&pvec, 0); index = start; while (index <= end && pagevec_lookup_entries(&pvec, mapping, index,