Received: by 10.223.164.221 with SMTP id h29csp2841562wrb; Thu, 2 Nov 2017 19:31:54 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TmmgjMR15LEln9nYR9z+Cwe9lcGoz9L/9QHqHvFgNEHD9DZg9iuZrmmj+sKuyDAToJNZOu X-Received: by 10.84.133.227 with SMTP id f90mr5427479plf.402.1509676314872; Thu, 02 Nov 2017 19:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509676314; cv=none; d=google.com; s=arc-20160816; b=uOiVJ3SFkrMn2WXrHc7E0OsiBdGADq8CQqJAKkVVOu0sZrNQcy4ycjfX2JfsAK88Y5 3B5ukzxw6yV2x8x72ARU+GPQj+wIrQoTJODeX8aWKa4JpSfI/0R8Ij4Rovk7qUv7rkY0 o00ACmigffhagQHxqLGgT72RysJpAvOrlVcFnc9rX7WVak+iaYrXcEkd5gyK5Dv7ztKN weRYYKeAh8EU6QEQyPctLSFxX2RaL5lr1yCcL6JKuakjhqbDFc6laemzPubE1Ya9OBDh APbPMBtIaAN2JMRZsROEfL3GtQH1WNhAVk9QyhqHzsOBEaQRBaltLkP6KkqZyMo73BGK qSTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=06ktywakiQIVm+upvTWieQZm6371IFH1X3gUbuFlcQ4=; b=yyO9yTsaNAuG5b4ktJKEpAGKGnM7wNoSkCkchTjr8EXepd7CPaqkbgeGtbROINS9P2 elYqL9jMJoFgWC5gwAn28cUcGKVjpmWyWBIw+XnhuwNxrJfzBQu4S+e49c9PKfkYSmDc J1pDlHT8LBbzR9MKUf5rq1TztLdpy/lf6Dnee/4p//TgbrKXUCD+U4Yn0Ei5+WuAzd+7 oGiyqfr4JptJoF60P5EH8QJBcquFWPWkwy2WFKBBPEeYclrW6+ShlQ/KOMq31Vxd6Ucl BJy0uRycKQr/Z0OfTq91aOjU7PjcllPJgYDxe8RjtcU18JLgBMNt/uNHmncSn18MwN/f SwBw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si3519972pli.120.2017.11.02.19.31.41; Thu, 02 Nov 2017 19:31:54 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965034AbdKCCbD (ORCPT + 96 others); Thu, 2 Nov 2017 22:31:03 -0400 Received: from mga14.intel.com ([192.55.52.115]:48178 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964922AbdKCCbC (ORCPT ); Thu, 2 Nov 2017 22:31:02 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Nov 2017 19:30:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,336,1505804400"; d="scan'208";a="1213670416" Received: from kemi-desktop.sh.intel.com (HELO [10.239.13.3]) ([10.239.13.3]) by fmsmga001.fm.intel.com with ESMTP; 02 Nov 2017 19:30:56 -0700 Subject: Re: [PATCH v2] buffer: Avoid setting buffer bits that are already set To: Jan Kara , Jens Axboe , Darrick J Wong , Eric Biggers , Andreas Gruenbacher , Jeff Layton Cc: Dave , Andi Kleen , Tim Chen , Ying Huang , Aaron Lu , Linux Kernel References: <1508807802-9691-1-git-send-email-kemi.wang@intel.com> From: kemi Message-ID: Date: Fri, 3 Nov 2017 10:29:13 +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: <1508807802-9691-1-git-send-email-kemi.wang@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017年10月24日 09:16, 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. > > Signed-off-by: Andi Kleen > Signed-off-by: Kemi Wang > Tested-by: Kemi Wang > Reviewed-by: Jens Axboe > --- Seems that this patch is still not merged. Anything wrong with that? thanks > include/linux/buffer_head.h | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h > index c8dae55..211d8f5 100644 > --- a/include/linux/buffer_head.h > +++ b/include/linux/buffer_head.h > @@ -80,11 +80,14 @@ struct buffer_head { > /* > * macro tricks to expand the set_buffer_foo(), clear_buffer_foo() > * and buffer_foo() functions. > + * To avoid reset buffer flags that are already set, because that causes > + * a costly cache line transition, check the flag first. > */ > #define BUFFER_FNS(bit, name) \ > static __always_inline void set_buffer_##name(struct buffer_head *bh) \ > { \ > - set_bit(BH_##bit, &(bh)->b_state); \ > + 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) \ > { \ > From 1582147121266335589@xxx Tue Oct 24 13:51:14 +0000 2017 X-GM-THRID: 1582062716863867471 X-Gmail-Labels: Inbox,Category Forums