From mboxrd@z Thu Jan 1 00:00:00 1970 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=-5.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 78AE6C433E0 for ; Mon, 8 Feb 2021 06:13:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 317C664E51 for ; Mon, 8 Feb 2021 06:13:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229763AbhBHGNQ (ORCPT ); Mon, 8 Feb 2021 01:13:16 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:12460 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbhBHGNE (ORCPT ); Mon, 8 Feb 2021 01:13:04 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DYwdF4CldzjK9j; Mon, 8 Feb 2021 14:11:13 +0800 (CST) Received: from [10.67.77.175] (10.67.77.175) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Mon, 8 Feb 2021 14:12:10 +0800 Subject: Re: [PATCH] fs/buffer.c: Add checking buffer head stat before clear To: Andrew Morton CC: , , Yang Guo , Alexander Viro , Nick Piggin References: <1612332890-57918-1-git-send-email-zhangshaokun@hisilicon.com> <20210205154548.49dd62b161b794b9f29026f1@linux-foundation.org> From: Shaokun Zhang Message-ID: Date: Mon, 8 Feb 2021 14:12:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <20210205154548.49dd62b161b794b9f29026f1@linux-foundation.org> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.77.175] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrew, ÔÚ 2021/2/6 7:45, Andrew Morton дµÀ: > On Wed, 3 Feb 2021 14:14:50 +0800 Shaokun Zhang wrote: > >> 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. > > Did this produce any measurable improvement? It has been tested on Huwei Kunpeng 920 which is ARM64 platform and test commond is below: numactl --cpunodebind=0 --membind=0 fio -name=randwrite -numjobs=16 -filename=/mnt/test1 -rw=randwrite -ioengine=libaio -direct=0 -iodepth=64 -sync=0 -norandommap -group_reporting -runtime=60 -time_based -bs=4k -size=5G The test result before patch: WRITE: bw=930MiB/s (976MB/s), 930MiB/s-930MiB/s (976MB/s-976MB/s), io=54.5GiB (58.5GB), run=60001-60001msec The test result after patch: WRITE: bw=958MiB/s (1005MB/s), 958MiB/s-958MiB/s (1005MB/s-1005MB/s), io=56.1GiB (60.3GB), run=60001-60001msec > > Perhaps we should give clear_buffer_x() the same optimization as > set_buffer_x()? > Good catch, but we check it more about it, if we do it the same as set_buffer_x(), many more codes will be fixed, such as ext4_wait_block_bitmap it has done sanity check using buffer_new and clear_buffer_new will check it again. Thanks, Shaokun > > static __always_inline void set_buffer_##name(struct buffer_head *bh) \ > { \ > if (!test_bit(BH_##bit, &(bh)->b_state)) \ > set_bit(BH_##bit, &(bh)->b_state); \ > } \ > static __always_inline void clear_buffer_##name(struct buffer_head *bh) \ > { \ > clear_bit(BH_##bit, &(bh)->b_state); \ > } \ > > > . >