Received: by 10.223.164.221 with SMTP id h29csp2499938wrb; Mon, 23 Oct 2017 08:29:40 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QGdKMhwvPEc1GdLB/p8/vXb7I1uE8kAZN+RTX1Q3NbHkpS2st3pidBFIea3gqIX+kkXD/W X-Received: by 10.98.58.92 with SMTP id h89mr13684062pfa.106.1508772579875; Mon, 23 Oct 2017 08:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508772579; cv=none; d=google.com; s=arc-20160816; b=nzmI2gH4+KdfSwREiAPwUBi6aQmLrU+5bc6LUni/bOuhCaTkmmSqyepb4flTgEr+vL kb2DEzmAWMxRH3+aM/CfYbZWl5bWdtxWiVym0qniycGF47Z1pPumfBtzNkhS6yCZZfO9 T6r5E76e0iL4gqxhMyHD01HCFf0uo8Q5zdf5w/E640PCKIhPk6TKxQ2HAfMfCWeOhrMI GaSSi0r9Wv29w3TjltklJlNHY+6vzZPQ1ygXFss/vivwSMo+wTafj14OK+TQuhW3/l/u ZKj4zqXCbeAYz0fFG8nH404Tcn7Uk8nYJ43x/OhHHSYT2gqJsDORa/jW1YPhvizDH5Bb S5jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=bf1mBU9fUp2O2L5SMxyXMYFdr8BRYHdZU2BV5IDtwCU=; b=DTmjLBy1m4zwpy184PTr15//rdBhza8B/HMPqjknbsExb7fiKUldcsgH3UeFlmoqp9 LisUd7HNp4om59ZZ2+nsFOSSl+h1RN4p+5kZc3lyjRp8wldzn9MM4WuqNm1qFEKJK4b1 HdoiRxWNJ3FPOUVh/aIPNKwyWzGwp7m2dJFFTNSnUi/8MkyqXaUj4UzxpeGc/paciU+r qNO9fQWVi491hTnYWfhZUw2pYTdgagS2wQ/Yj3US4GINWWO4PxgBWOoDDe8m/F00pcrG cDfoEfHTkPRCJbP1IZT4y8N0AcwElvKo8AKCSdnSH4xeyghbe3RI2U+wVtVD3Y98PhC1 xTgA== 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 g12si4144459plo.435.2017.10.23.08.29.25; Mon, 23 Oct 2017 08:29:39 -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 S932330AbdJWP3G (ORCPT + 99 others); Mon, 23 Oct 2017 11:29:06 -0400 Received: from mga02.intel.com ([134.134.136.20]:5712 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751260AbdJWP3F (ORCPT ); Mon, 23 Oct 2017 11:29:05 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Oct 2017 08:29:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,423,1503385200"; d="scan'208";a="1028304188" Received: from kemi-desktop.sh.intel.com ([10.239.13.103]) by orsmga003.jf.intel.com with ESMTP; 23 Oct 2017 08:29:01 -0700 From: Kemi Wang To: Jan Kara , Jens Axboe , Darrick J Wong , Kemi Wang , Eric Biggers , Andreas Gruenbacher , Jeff Layton Cc: Dave , Andi Kleen , Tim Chen , Ying Huang , Aaron Lu , Linux Kernel Subject: [PATCH] buffer: Avoid setting buffer bits that are already set Date: Mon, 23 Oct 2017 23:27:24 +0800 Message-Id: <1508772444-27879-1-git-send-email-kemi.wang@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- include/linux/buffer_head.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index c8dae55..e1799f7 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -84,7 +84,8 @@ struct buffer_head { #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) \ { \ -- 2.7.4 From 1583055235298785086@xxx Fri Nov 03 14:25:19 +0000 2017 X-GM-THRID: 1581143703946085917 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread