Received: by 10.223.164.221 with SMTP id h29csp2550960wrb; Mon, 23 Oct 2017 09:20:37 -0700 (PDT) X-Received: by 10.101.68.69 with SMTP id e5mr12125192pgq.282.1508775637392; Mon, 23 Oct 2017 09:20:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508775637; cv=none; d=google.com; s=arc-20160816; b=EM2M2BLsmljPj2YyShlsGbI8wc0/GODq9gtMt2xcYjiLNcUwHVFOAs2FHcB3Ewb0pM TeR/CORwHMxvrjnaK21FXbqKfq9JBOdkk4Q5BXkbfpN/RtGKXDpvWuaKWlycWmgqmVLj NbromZlklcEPQSqZE9coKpvO+bT8CZ+WhAnuGHBoORBOkxsAHMIPad4FqeQPQK2AFdCt FAD/vyJLT9dEqeNOihM3CR5GUr6Mfkv7rrrLmsjOoq0As+lHBbnIbFEB3q83N6ErLeIs LF3SvBDeuzcF9y4dbdWi+j4Pyp1WbzpRS7hd/vWgqqAd3f8EJi7etV0g5Ie1ELC2TH/o 9SrQ== 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:dkim-signature :arc-authentication-results; bh=q9DISx27pk8jam+7qA2tORhxQ1wfGrpa7j8RP5Gfyo0=; b=N5zg5M8Wk/VycHaNKIsuZx+EJ8uF5P47Wt5ys3CsKAISCDD3wUQzhFZ4Z54X/ZEMEe jGzzxuN9w1nbKoCbZYKQ+oc4aeM3tNVrC+3v4Lg8+mYXamvjJ4W6SO0WvI+UbSNv/q7O IyWwPsgB1cjGNTcUC5B5SaHQ29CAcUQEPz+5Rg5LWIGyfV/u8/wjlw4JC+5+jPcCkG3Y rho4bjO3XbpicmlmSvXn6gfZ05R4E+8ijaSaf645BMcnxwYBv3EMXg0D5jjc/yjQU56A r5pSCXGe4+LhBYKawurlt4+CTrv2CQjHp2e6WYOMNIaXbiNIaEGPDFMTKRh4TdIA4/fM YcQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=Ifa1QZ6/; 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 p18si5061800pgc.458.2017.10.23.09.20.22; Mon, 23 Oct 2017 09:20:37 -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; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=Ifa1QZ6/; 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 S1751514AbdJWQTw (ORCPT + 99 others); Mon, 23 Oct 2017 12:19:52 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:54402 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751277AbdJWQTv (ORCPT ); Mon, 23 Oct 2017 12:19:51 -0400 Received: by mail-io0-f194.google.com with SMTP id e89so20706765ioi.11 for ; Mon, 23 Oct 2017 09:19:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=q9DISx27pk8jam+7qA2tORhxQ1wfGrpa7j8RP5Gfyo0=; b=Ifa1QZ6/3lEHNbofAMpQNL6gACluc0vzdjLqt8OFv0ZgDki/klvALpx4sjheRfK3Bb cAVrNmSiOa6lBYcdD5zIZdCfwJ+EnFGPcO37FYMTQRBnwLte87ylp6yXwuNqz757YgFf oZS11/FzpNNM+xYeRBnppXDpPAUWWn8kzAKWLkBFo6cqeaanaFAnVpT6oyfxI1Ju2NbB vPMQ8ryv194mZ53DJa+2KfFbzbkXm0sKh7f9yfdmDBjVfJGZFlyL2bWpweF/A4aD5xwC H+LSQzI8LyqRUeqOgAsQ0HjCzQdSEOSyizl3m2Pqw+Qz8RCfynyWKrATS8volB0Yaubu 8flA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=q9DISx27pk8jam+7qA2tORhxQ1wfGrpa7j8RP5Gfyo0=; b=MARv4Di4F3kypyryTPmFvA0qi98fr2H8GESyyQTQzaCE9Sc31eGtFHbj+Q7jOcnXjC /LvdpaRzdDbszg0gXOlB2v7f5YtYMVhwjFSDYW+AZJrEvdJ3aWBFbES6Pm2BU7agKz2C hphcm4SKq2g0Gty/LDARR86oCsdb7Ovlimwwr2ZyeRtVSVCweR4RML4ehzi19BDSwna+ JWllnB65NVbCTC6sQvw9JvSXK7RpTVVsu5DRQpvsVBPJJGJHoCh66QX9lZtcgn1fTUXq z1AYEeDA/Z4sXfXWuGygrZP2sSglAn/djY6xjzAJ3Nlw5qnYSI/15IXyUMRV61LsyB9z 7m0w== X-Gm-Message-State: AMCzsaWtdc7ZbAARLVzxucYSBToHtdQ5ufg4GBX6NiZMYb48SZTR72tD 1RDjygkrqJd7ATIc3VcQjnzpan9lggI= X-Google-Smtp-Source: ABhQp+RBadjF2LALWr4IHv+FlxjtWPTNfRM5HI399XFGSbO7Ck02ogJXTDifBNCW0sUEu3W1gZnbTQ== X-Received: by 10.107.29.73 with SMTP id d70mr17325468iod.201.1508775590706; Mon, 23 Oct 2017 09:19:50 -0700 (PDT) Received: from [192.168.1.154] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id a31sm2553405itj.7.2017.10.23.09.19.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 09:19:49 -0700 (PDT) Subject: Re: [PATCH] buffer: Avoid setting buffer bits that are already set To: Kemi Wang , 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: Jens Axboe Message-ID: Date: Mon, 23 Oct 2017 11:19:47 -0500 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: <1508772444-27879-1-git-send-email-kemi.wang@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, I'll see if I can find some time to implement the above in a nice way. In the mean time, you may want to consider adding a comment to the function explaining why you have done it that way. -- Jens Axboe From 1582062716863867471@xxx Mon Oct 23 15:29:40 +0000 2017 X-GM-THRID: 1582062716863867471 X-Gmail-Labels: Inbox,Category Forums