From patchwork Fri Feb 26 16:46:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 63087 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp827334lbc; Fri, 26 Feb 2016 09:09:51 -0800 (PST) X-Received: by 10.98.16.86 with SMTP id y83mr3547512pfi.45.1456506591547; Fri, 26 Feb 2016 09:09:51 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z63si21019562pfi.63.2016.02.26.09.09.51; Fri, 26 Feb 2016 09:09:51 -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; 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; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422692AbcBZRJt (ORCPT + 30 others); Fri, 26 Feb 2016 12:09:49 -0500 Received: from mail-pf0-f178.google.com ([209.85.192.178]:34584 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754003AbcBZRJs (ORCPT ); Fri, 26 Feb 2016 12:09:48 -0500 Received: by mail-pf0-f178.google.com with SMTP id x65so55018769pfb.1 for ; Fri, 26 Feb 2016 09:09:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=uiy9lxK47kXnnwKHGZQ6lJ7xGNrvf6WtcB3+k5JszmI=; b=Nysggp0C/R40AL28CuuiVf5QW3PIgooiXa044OxuP7inQvLmFILXvejmgOFDEEdfsL glsDE3/zMaIwftE0r++5WougFhI+mBdywjpCAbsRvP74ZGkBy/Roj556Z9mCCsZb7PZo S2eNsFsC+bnLONE/Vsmnpsfoe1EKQ95+YxpnY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uiy9lxK47kXnnwKHGZQ6lJ7xGNrvf6WtcB3+k5JszmI=; b=cMyKy1Rd/UNBo2mW+C/9Or9iKhfTz/8kkzlokOo+Hk/tqy1HJ0s3gnCuTpL9VVkXTs pwlFKG7Iw8tcRvUXz2+iPFCiSbnalSo82hXbJ0xSmbrpd3OzqRSonBK80DnsMOZQh/3D KbjKdFqxngnEwO3l4jKpQdc+Kvu7KGTyVSanNENO0TXwwo2kJ3DXpx3BJEYw8DKH1OFl OnI8j/h0wL6qUIqAvIFWdT8LFtuZDl61dhlL9PaFMy2tt73dTe0qvYnZkelkdPgxaDbl wuPHZGXrMKbC4oju1z3BQhCOl48iqvf72+WR5fTrKD1CfUW52cKwXeBXiLYQ/wYUkeok yWwg== X-Gm-Message-State: AD7BkJIk/PP+4M92L8WL19SFTnjXlTxBYztrnvynK5mLR+EZHBGN3yt9cyGVyAzL2esdyDNA X-Received: by 10.98.93.211 with SMTP id n80mr3594223pfj.61.1456506587892; Fri, 26 Feb 2016 09:09:47 -0800 (PST) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id n28sm20633611pfa.45.2016.02.26.09.09.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Feb 2016 09:09:47 -0800 (PST) From: Yang Shi To: tj@kernel.org, jack@suse.cz, axboe@fb.com, fengguang.wu@intel.com, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org Subject: [RFC PATCH] writeback: move list_lock down into the for loop Date: Fri, 26 Feb 2016 08:46:25 -0800 Message-Id: <1456505185-21566-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The list_lock was moved outside the for loop by commit e8dfc30582995ae12454cda517b17d6294175b07 ("writeback: elevate queue_io() into wb_writeback())", however, the commit log says "No behavior change", so it sounds safe to have the list_lock acquired inside the for loop as it did before. Leave tracepoints outside the critical area since tracepoints already have preempt disabled. Signed-off-by: Yang Shi --- Tested with ltp on 8 cores Cortex-A57 machine. fs/fs-writeback.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.0.2 diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 1f76d89..9b7b5f6 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -1623,7 +1623,6 @@ static long wb_writeback(struct bdi_writeback *wb, work->older_than_this = &oldest_jif; blk_start_plug(&plug); - spin_lock(&wb->list_lock); for (;;) { /* * Stop writeback when nr_pages has been consumed @@ -1661,15 +1660,19 @@ static long wb_writeback(struct bdi_writeback *wb, oldest_jif = jiffies; trace_writeback_start(wb, work); + + spin_lock(&wb->list_lock); if (list_empty(&wb->b_io)) queue_io(wb, work); if (work->sb) progress = writeback_sb_inodes(work->sb, wb, work); else progress = __writeback_inodes_wb(wb, work); - trace_writeback_written(wb, work); wb_update_bandwidth(wb, wb_start); + spin_unlock(&wb->list_lock); + + trace_writeback_written(wb, work); /* * Did we write something? Try for more @@ -1693,15 +1696,14 @@ static long wb_writeback(struct bdi_writeback *wb, */ if (!list_empty(&wb->b_more_io)) { trace_writeback_wait(wb, work); + spin_lock(&wb->list_lock); inode = wb_inode(wb->b_more_io.prev); - spin_lock(&inode->i_lock); spin_unlock(&wb->list_lock); + spin_lock(&inode->i_lock); /* This function drops i_lock... */ inode_sleep_on_writeback(inode); - spin_lock(&wb->list_lock); } } - spin_unlock(&wb->list_lock); blk_finish_plug(&plug); return nr_pages - work->nr_pages;