From patchwork Wed Feb 24 20:02:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12102509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E600C433E0 for ; Wed, 24 Feb 2021 20:02:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0E77A64E09 for ; Wed, 24 Feb 2021 20:02:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E77A64E09 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A1B168D000A; Wed, 24 Feb 2021 15:02:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 99EE78D0007; Wed, 24 Feb 2021 15:02:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88DD08D000A; Wed, 24 Feb 2021 15:02:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id 6C39C8D0007 for ; Wed, 24 Feb 2021 15:02:51 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 34414185044A8 for ; Wed, 24 Feb 2021 20:02:51 +0000 (UTC) X-FDA: 77854234542.16.6B55999 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf12.hostedemail.com (Postfix) with ESMTP id 032952BC7 for ; Wed, 24 Feb 2021 20:02:44 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 6B95D64F20; Wed, 24 Feb 2021 20:02:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1614196969; bh=aN4ApV2pMzQ/PNBdet6SPu7L+unhlAHyg8vhrUrR6sg=; h=Date:From:To:Subject:In-Reply-To:From; b=UrE/NdWpXL5rQp3U9EZioVPHE2XOZu8aY8D2TSkINtWY9QMmpFMEynO4ggDAjviya 2KnnefqIWEFg9MLr5nYZpdOCnrpVRWa5aPYjbu3DBz90sLdmGOzcTP+AigEIjZYZJ3 x0c5tD6TUvUC/NhE7zLnFCACE8MlbENSolbZWqys= Date: Wed, 24 Feb 2021 12:02:48 -0800 From: Andrew Morton To: akpm@linux-foundation.org, guoyang2@huawei.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, npiggin@suse.de, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, zhangshaokun@hisilicon.com Subject: [patch 048/173] fs/buffer.c: add checking buffer head stat before clear Message-ID: <20210224200248.86pqR4gin%akpm@linux-foundation.org> In-Reply-To: <20210224115824.1e289a6895087f10c41dd8d6@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Stat-Signature: bxqopwifqyta6sjgouw9ahi7zq1hgok5 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 032952BC7 Received-SPF: none (linux-foundation.org>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614196964-158478 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: From: Yang Guo Subject: fs/buffer.c: add checking buffer head stat before clear clear_buffer_new() is used to clear buffer new stat. When PAGE_SIZE is 64K, most buffer heads in the list are not needed to clear. clear_buffer_new() has an enpensive atomic modification operation, Let's add checking buffer head before clear it as __block_write_begin_int does which is good for performance. Link: https://lkml.kernel.org/r/1612332890-57918-1-git-send-email-zhangshaokun@hisilicon.com Signed-off-by: Yang Guo Signed-off-by: Shaokun Zhang Cc: Alexander Viro Cc: Nick Piggin Signed-off-by: Andrew Morton --- fs/buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/buffer.c~fs-bufferc-add-checking-buffer-head-stat-before-clear +++ a/fs/buffer.c @@ -2083,7 +2083,8 @@ static int __block_commit_write(struct i set_buffer_uptodate(bh); mark_buffer_dirty(bh); } - clear_buffer_new(bh); + if (buffer_new(bh)) + clear_buffer_new(bh); block_start = block_end; bh = bh->b_this_page;