From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751336AbdJXAyD (ORCPT ); Mon, 23 Oct 2017 20:54:03 -0400 Received: from mga11.intel.com ([192.55.52.93]:56909 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751259AbdJXAyB (ORCPT ); Mon, 23 Oct 2017 20:54:01 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,424,1503385200"; d="scan'208";a="1209214627" Subject: Re: [PATCH] buffer: Avoid setting buffer bits that are already set To: Jens Axboe , Jan Kara , Darrick J Wong , Eric Biggers , Andreas Gruenbacher , Jeff Layton Cc: Dave , Andi Kleen , Tim Chen , Ying Huang , Aaron Lu , Linux Kernel References: <1508772444-27879-1-git-send-email-kemi.wang@intel.com> From: kemi Message-ID: Date: Tue, 24 Oct 2017 08:52:22 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017年10月24日 00:19, Jens Axboe wrote: > On 10/23/2017 10:27 AM, Kemi Wang wrote: >> It's expensive to set buffer flags that are already set, because that >> causes a costly cache line transition. >> >> A common case is setting the "verified" flag during ext4 writes. >> This patch checks for the flag being set first. >> >> With the AIM7/creat-clo benchmark testing on a 48G ramdisk based-on ext4 >> file system, we see 3.3%(15431->15936) improvement of aim7.jobs-per-min on >> a 2-sockets broadwell platform. >> >> What the benchmark does is: it forks 3000 processes, and each process do >> the following: >> a) open a new file >> b) close the file >> c) delete the file >> until loop=100*1000 times. >> >> The original patch is contributed by Andi Kleen. > > We discussed this recently, in reference to this commit: > > commit 7fcbbaf18392f0b17c95e2f033c8ccf87eecde1d > Author: Jens Axboe > Date: Thu May 22 11:54:16 2014 -0700 > > mm/filemap.c: avoid always dirtying mapping->flags on O_DIRECT > > which made a massive difference, as the changelog details. > > blk-mq uses this extensively as well, where possible. The problem is > that it always has to be explained, hence the recent discussion was > around perhaps adding > > set_bit_if_not_set() > clear_bit_if_set() > > or similar functions, to document in a single location why this matters. > Additionally, some archs may be able to implement that in an efficient > manner. > > You can add my reviewed-by to the below, Thanks. I'll see if I can find some > time to implement the above in a nice way. Agree. Maybe something like test_and_set_bit() would be more suitable. In the mean time, you may > want to consider adding a comment to the function explaining why you > have done it that way. > Sure.