From patchwork Sat Aug 15 18:38:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 7021321 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 74397C05AC for ; Sat, 15 Aug 2015 18:45:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7356D206A3 for ; Sat, 15 Aug 2015 18:45:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 860592069F for ; Sat, 15 Aug 2015 18:45:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754182AbbHOSpm (ORCPT ); Sat, 15 Aug 2015 14:45:42 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:42193 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754089AbbHOSpl (ORCPT ); Sat, 15 Aug 2015 14:45:41 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out02.mta.xmission.com with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1ZQgSb-0001sm-9d; Sat, 15 Aug 2015 12:45:41 -0600 Received: from 67-3-205-173.omah.qwest.net ([67.3.205.173] helo=x220.int.ebiederm.org.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1ZQgSa-0003BG-Kf; Sat, 15 Aug 2015 12:45:41 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Linux Containers Cc: linux-fsdevel@vger.kernel.org, Al Viro , Andy Lutomirski , "Serge E. Hallyn" , Richard Weinberger , Andrey Vagin , Jann Horn , Willy Tarreau , Omar Sandoval , Miklos Szeredi , Linus Torvalds , "J. Bruce Fields" References: <871tncuaf6.fsf@x220.int.ebiederm.org> <87mw5xq7lt.fsf@x220.int.ebiederm.org> <87a8yqou41.fsf_-_@x220.int.ebiederm.org> <874moq9oyb.fsf_-_@x220.int.ebiederm.org> <871tfkawu9.fsf_-_@x220.int.ebiederm.org> <87egjk9i61.fsf_-_@x220.int.ebiederm.org> <20150810043637.GC14139@ZenIV.linux.org.uk> <877foymrwt.fsf@x220.int.ebiederm.org> <87wpwyjxwc.fsf_-_@x220.int.ebiederm.org> <87fv3mjxsc.fsf_-_@x220.int.ebiederm.org> <20150815061617.GG14139@ZenIV.linux.org.uk> <874mk08l3g.fsf@x220.int.ebiederm.org> <87a8ts763c.fsf_-_@x220.int.ebiederm.org> Date: Sat, 15 Aug 2015 13:38:49 -0500 In-Reply-To: <87a8ts763c.fsf_-_@x220.int.ebiederm.org> (Eric W. Biederman's message of "Sat, 15 Aug 2015 13:35:19 -0500") Message-ID: <87egj45rd2.fsf_-_@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-XM-AID: U2FsdGVkX1+JQ+d9H9bB3Wadm4bGjFmh5xMlJ6jWWms= X-SA-Exim-Connect-IP: 67.3.205.173 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,LOTS_OF_MONEY, RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;Linux Containers X-Spam-Relay-Country: X-Spam-Timing: total 237 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 4.3 (1.8%), b_tie_ro: 3.1 (1.3%), parse: 1.02 (0.4%), extract_message_metadata: 12 (4.9%), get_uri_detail_list: 1.36 (0.6%), tests_pri_-1000: 6 (2.5%), tests_pri_-950: 1.28 (0.5%), tests_pri_-900: 1.09 (0.5%), tests_pri_-400: 21 (9.0%), check_bayes: 20 (8.4%), b_tokenize: 6 (2.5%), b_tok_get_all: 7 (2.8%), b_comp_prob: 1.68 (0.7%), b_tok_touch_all: 3.5 (1.5%), b_finish: 0.71 (0.3%), tests_pri_0: 183 (76.9%), tests_pri_500: 5 (2.2%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH review 5/7] dcache: Only read d_flags once in d_is_dir X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cache the value of __d_entry_type in d_is_dir and test if it equal to DCACHE_DIRECTORY_TYPE or DCACHE_AUTODIR_TYPE. The generated assembly goes from: movl (%rdi), %eax # MEM[(volatile __u32 *)dentry_3(D)], tmp73 andl $7340032, %eax #, tmp73 cmpl $2097152, %eax #, tmp73 je .L1091 #, movl (%rdi), %eax # MEM[(volatile __u32 *)dentry_3(D)], tmp74 andl $7340032, %eax #, tmp74 cmpl $3145728, %eax #, tmp74 je .L1091 #, to: movl (%rdi), %eax # MEM[(volatile __u32 *)dentry_3(D)], tmp71 andl $6291456, %eax #, tmp71 cmpl $2097152, %eax #, tmp71 jne .L1091 #, Which with only one read of d_flags, one comparison and one jump is dramatically better code. As __d_entry_type is not written to allow the compiler to optimize away anything that it does, when it is possible and reasonable to optimize things away the optimization needs to be performend manually. Signed-off-by: "Eric W. Biederman" --- include/linux/dcache.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 5b69856b45a2..82eb50aaf446 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -443,7 +443,8 @@ static inline bool d_is_autodir(const struct dentry *dentry) static inline bool d_is_dir(const struct dentry *dentry) { - return d_can_lookup(dentry) || d_is_autodir(dentry); + unsigned type = __d_entry_type(dentry); + return (type == DCACHE_DIRECTORY_TYPE) || (type == DCACHE_AUTODIR_TYPE); } static inline bool d_is_symlink(const struct dentry *dentry)