Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp45366pxb; Tue, 2 Feb 2021 22:18:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyO2imfJE5BspB03xZipcrE6mIP3Ooh2CqcEfO1J/4wAv6mEd9C8SFJ2Pg1V5UFymuNCHvz X-Received: by 2002:aa7:d60f:: with SMTP id c15mr1469406edr.291.1612333116178; Tue, 02 Feb 2021 22:18:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612333116; cv=none; d=google.com; s=arc-20160816; b=gSwQTUV0NBNPuU1TFuDKIcptUzVF6WShnNSuFvcUNLwUzxINAjfZl777a7UMCs5Vc2 puxh1Fo1EFAFxcV0cS4ClaAb+KkqmkHzhrR30nhNnE2lWlNSI0Rn3OtzLXCnrZH/+QIx o0m3Jk6K3ldm9GfDsGsZfQwTSfTUNunHOWZqcDgOw/xzPump3zO/9I7soTK4GXeDLYRC +C6QZmB1JICgksvIusjR0jyXml2EeCD9zKRn+gMNfjsxD245d0IXpjyY+416Zqt908Lu 5zIytYSyNNaIwq/9zqTSgruQ9BvZyYnCAKorrjOCFHJ2j52pRFjgWFElOuGY69q3PGVW D8xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=XzuX3xTRtcHZ19S8mjyXa7ohD5vroVgxZgSEy8uQelg=; b=GRF9a71w/7t8KeETaWnQ8+lXXJD/Du/OMA3vCM+Pdm3S1tXq5SNtYr/1BFf0rFJVDl kFef7yfI5tAFT+B9wP/r3r4BEF44w7n5+HYlN2nPUKX8wm+xt6WQYkI0S9zvRiFsQ0Gd cOMDLfrrwfp2ECuEY9w+DTwztBD2d1hmoItHHPJOyMuN9nwAyLK8HZewql2M5GljheEg 3litehvQnFzceJoA2wj47Pv/8ZGoZCaUsFkLJOO2f7q2fxS0DJ3tqOIa9AHG9hZhbEVP TbqCFFubM82gY6h3twfQjqs7L2v1clmroCXwIS+qzilX6gALM6CHnejmOVoa7m+zjfIM ACCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si603782eja.434.2021.02.02.22.17.56; Tue, 02 Feb 2021 22:18:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231186AbhBCGQL (ORCPT + 99 others); Wed, 3 Feb 2021 01:16:11 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:12112 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbhBCGQL (ORCPT ); Wed, 3 Feb 2021 01:16:11 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DVrwy6ZSrz163Tj; Wed, 3 Feb 2021 14:14:10 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Wed, 3 Feb 2021 14:15:19 +0800 From: Shaokun Zhang To: , CC: Yang Guo , Alexander Viro , Andrew Morton , Nick Piggin , Shaokun Zhang Subject: [PATCH] fs/buffer.c: Add checking buffer head stat before clear Date: Wed, 3 Feb 2021 14:14:50 +0800 Message-ID: <1612332890-57918-1-git-send-email-zhangshaokun@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Guo 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. Cc: Alexander Viro Cc: Andrew Morton Cc: Nick Piggin Signed-off-by: Yang Guo Signed-off-by: Shaokun Zhang --- fs/buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/buffer.c b/fs/buffer.c index 32647d2011df..f1c3a5b27a90 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2083,7 +2083,8 @@ static int __block_commit_write(struct inode *inode, struct page *page, 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; -- 2.7.4