From patchwork Thu May 5 19:51:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 9027131 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7C0DCBF29F for ; Thu, 5 May 2016 19:53:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 98A28202EC for ; Thu, 5 May 2016 19:53:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A7C6F202E9 for ; Thu, 5 May 2016 19:53:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757016AbcEETxh (ORCPT ); Thu, 5 May 2016 15:53:37 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:37771 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757353AbcEETwD (ORCPT ); Thu, 5 May 2016 15:52:03 -0400 Received: by mail-wm0-f50.google.com with SMTP id a17so44881115wme.0 for ; Thu, 05 May 2016 12:52:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=Yzv0mSxfrB3Rjr8w9E0YhYKC7ntE7vIdwOKpLS5mEeU=; b=qPqAVML5se3bzmOLwRwWHTp9Du2prByhW6QQuOcF4nBWIoI0Ys3Aeo2U/ubjPi4E7z esq3pA2ACzhWWWqpUZl/j+Ane5VY5KMZqj2CLrDRG6hjBgplx42ZkxTAUHGHeo8v7o1A OQiTgudYqgfwEOJ0scTI7awyiVHQfm2FTFhlQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=Yzv0mSxfrB3Rjr8w9E0YhYKC7ntE7vIdwOKpLS5mEeU=; b=Q4Ibcs0f2f0vzMCQ+pUeu5jlZQflr6QFMvELoBw1eBf6wKSINREO5l09nk125VDw4E KgSpCi5VBb4LXERr40t8OMTO7foTptzyUxy2c1zq96CVJFjg3KA9LL70fslvGnjPH/HV XL0b50TO6tOgV/fcfQ1WB9timg++L9PSBMoK/amFrrPTU93O/QMCGKdFNFQ+VbqV9n5G QU2kgdrnnzc7oZ7eoR5BDvHG6UeDH7ZMzU7reK/qjEEMPHeka5bcZGtJR9aJfy4lCVBY YaBPcDpvCvX9/in3UlHBoUNd8YtI7v9PR77tOlH2izAtQvn3S09ukD6T5T2WEttTE8Gx KgSQ== X-Gm-Message-State: AOPr4FXh/8pYO0NKv7/LLpK3YqT43I+ydjE/dGTkgJEsPBr9G0VhunfzVTRCV8ZBJ44JmA== X-Received: by 10.194.87.72 with SMTP id v8mr17911721wjz.68.1462477921296; Thu, 05 May 2016 12:52:01 -0700 (PDT) Received: from veci.piliscsaba.szeredi.hu (pool-dsl-2c-0018.externet.hu. [217.173.44.24]) by smtp.gmail.com with ESMTPSA id t206sm4718399wmt.21.2016.05.05.12.52.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 May 2016 12:52:00 -0700 (PDT) Date: Thu, 5 May 2016 21:51:50 +0200 From: Miklos Szeredi To: Jens Axboe Cc: Howard Cochran , Jakob Unterwurzacher , Tejun Heo , Ashish Sangwan , Sedat Dilek , Linux-Fsdevel , Kernel Mailing List Subject: [PATCH v4.6-rc] writeback: Fix performance regression in wb_over_bg_thresh() Message-ID: <20160505195150.GC10623@veci.piliscsaba.szeredi.hu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Jens, This fix seems to have been missed; it should go into v4.6. Please apply. Thanks, Miklos From: Howard Cochran Subject: writeback: Fix performance regression in wb_over_bg_thresh() Date: Thu, 10 Mar 2016 01:12:39 -0500 Commit 947e9762a8dd ("writeback: update wb_over_bg_thresh() to use wb_domain aware operations") unintentionally changed this function's meaning from "are there more dirty pages than the background writeback threshold" to "are there more dirty pages than the writeback threshold". The background writeback threshold is typically half of the writeback threshold, so this had the effect of raising the number of dirty pages required to cause a writeback worker to perform background writeout. This can cause a very severe performance regression when a BDI uses BDI_CAP_STRICTLIMIT because balance_dirty_pages() and the writeback worker can now disagree on whether writeback should be initiated. For example, in a system having 1GB of RAM, a single spinning disk, and a "pass-through" FUSE filesystem mounted over the disk, application code mmapped a 128MB file on the disk and was randomly dirtying pages in that mapping. Because FUSE uses strictlimit and has a default max_ratio of only 1%, in balance_dirty_pages, thresh is ~200, bg_thresh is ~100, and the dirty_freerun_ceiling is the average of those, ~150. So, it pauses the dirtying processes when we have 151 dirty pages and wakes up a background writeback worker. But the worker tests the wrong threshold (200 instead of 100), so it does not initiate writeback and just returns. Thus, balance_dirty_pages keeps looping, sleeping and then waking up the worker who will do nothing. It remains stuck in this state until the few dirty pages that we have finally expire and we write them back for that reason. Then the whole process repeats, resulting in near-zero throughput through the FUSE BDI. The fix is to call the parameterized variant of wb_calc_thresh, so that the worker will do writeback if the bg_thresh is exceeded which was the behavior before the referenced commit. Fixes: 947e9762a8dd ("writeback: update wb_over_bg_thresh() to use wb_domain aware operations") Signed-off-by: Howard Cochran Acked-by: Tejun Heo Signed-off-by: Miklos Szeredi Cc: # v4.2+ --- mm/page-writeback.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1910,7 +1910,8 @@ bool wb_over_bg_thresh(struct bdi_writeb if (gdtc->dirty > gdtc->bg_thresh) return true; - if (wb_stat(wb, WB_RECLAIMABLE) > __wb_calc_thresh(gdtc)) + if (wb_stat(wb, WB_RECLAIMABLE) > + wb_calc_thresh(gdtc->wb, gdtc->bg_thresh)) return true; if (mdtc) { @@ -1924,7 +1925,8 @@ bool wb_over_bg_thresh(struct bdi_writeb if (mdtc->dirty > mdtc->bg_thresh) return true; - if (wb_stat(wb, WB_RECLAIMABLE) > __wb_calc_thresh(mdtc)) + if (wb_stat(wb, WB_RECLAIMABLE) > + wb_calc_thresh(mdtc->wb, mdtc->bg_thresh)) return true; }