Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6553373ybx; Mon, 11 Nov 2019 10:51:05 -0800 (PST) X-Google-Smtp-Source: APXvYqwRetrWCLYGiUAKihKSAGrpHsY+L/1FNiX2d5Oq8G9XHYsO9luHjNa/GSRusTPn/d3/suAp X-Received: by 2002:a50:fc8e:: with SMTP id f14mr28285289edq.83.1573498265289; Mon, 11 Nov 2019 10:51:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498265; cv=none; d=google.com; s=arc-20160816; b=FCTJKIK9zJsgZVDC/39kYBD7Cbj5TKXV636mGPAH16BjRiWFDVkClS+sEHtUP/vy++ Hwt7NUFj+6fcXS1lpqb8XXfPCrYUarP/HENwhgkZjmnrrpcH/HMVI9ziLFMZQjy8Mak5 Grs/25qqxMCUKIvw+SkTuVTShw5v9VBIMPMwvzwc9gQYTLNHnlW+M8eLFB5SGH4MXA9u ZLWpk4W5ffQsX1aFM6iYTN4RcZd4aXEjEJEse3+aZsr6ES+lSKxnRuXWohj7Vbj1DC+S XfYbvgu5o7+KRS4AidkrdoNcW7VN+tofEFVj7DHU1aM6zVjEyQGSP57r4Kuv3HZWi6U1 L41A== 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=vUbJIWXNXM8farc6V4c4yn3XKDrJDnZ5A8OvQPJVZSY=; b=e4luVq14LgN6c9hjK2gd/Tfg60GYXWrYCtPIFCI0PntamF0kRg+J6pFAHwPngAwVyr tCc82yLbn/rMZQqFgB2JSf/OA4en0gqIUtlA8SoASzIWYz0e/dQKfIWWHXlpYxJp0dnq zfSGi0U90dXUXl8kltcMQylfHXzivbBakrJbc1tuSoS/b0a8DR8TdauL5lTJlWYDDQ3R XvaPEPmvzWQyDbGiCDMsTXrsH9CzZCGdaUgQWt5Qck1v/PGT8UutuzJ3QOxy7PxVbvS6 mTqcurezH3DIvcTf7BbR0NhNbXTXo6BIiQcF6CcXJHZJZ7qUfwXN+TUdAZEw1GgyPdK7 NvXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="B/mtzFXU"; 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 k43si11881989edb.150.2019.11.11.10.50.41; Mon, 11 Nov 2019 10:51:05 -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="B/mtzFXU"; 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 S1729446AbfKKSr0 (ORCPT + 99 others); Mon, 11 Nov 2019 13:47:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:40156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730103AbfKKSrW (ORCPT ); Mon, 11 Nov 2019 13:47:22 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 6B13B204FD; Mon, 11 Nov 2019 18:47:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573498042; bh=ZZD3P9bX6jJOAa0xFQLXVAuNjTf37Uhk8BgWgKMRGgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B/mtzFXUIPLYGfKv3tplIrYu4L/dTSj8aRXBxarGWfARpFgSK0vWSERj4JtT70rXH HOjLsGPKrk6N2HNGTbMigvmTUCLxi65ooVtvQHiDOtyTrw+mrpROUddufy9KDvaQR3 J9C4cXGJ+NLqKo6vVnn+fvmy3ci3L0uM1e7vnSSU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konstantin Khlebnikov , Jan Kara , Tejun Heo , Jens Axboe , Johannes Weiner , Andrew Morton , Linus Torvalds Subject: [PATCH 4.19 124/125] mm/filemap.c: dont initiate writeback if mapping has no dirty pages Date: Mon, 11 Nov 2019 19:29:23 +0100 Message-Id: <20191111181456.247399096@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Konstantin Khlebnikov commit c3aab9a0bd91b696a852169479b7db1ece6cbf8c upstream. Functions like filemap_write_and_wait_range() should do nothing if inode has no dirty pages or pages currently under writeback. But they anyway construct struct writeback_control and this does some atomic operations if CONFIG_CGROUP_WRITEBACK=y - on fast path it locks inode->i_lock and updates state of writeback ownership, on slow path might be more work. Current this path is safely avoided only when inode mapping has no pages. For example generic_file_read_iter() calls filemap_write_and_wait_range() at each O_DIRECT read - pretty hot path. This patch skips starting new writeback if mapping has no dirty tags set. If writeback is already in progress filemap_write_and_wait_range() will wait for it. Link: http://lkml.kernel.org/r/156378816804.1087.8607636317907921438.stgit@buzz Signed-off-by: Konstantin Khlebnikov Reviewed-by: Jan Kara Cc: Tejun Heo Cc: Jens Axboe Cc: Johannes Weiner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/filemap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/mm/filemap.c +++ b/mm/filemap.c @@ -438,7 +438,8 @@ int __filemap_fdatawrite_range(struct ad .range_end = end, }; - if (!mapping_cap_writeback_dirty(mapping)) + if (!mapping_cap_writeback_dirty(mapping) || + !mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) return 0; wbc_attach_fdatawrite_inode(&wbc, mapping->host);