From patchwork Thu Oct 18 11:22:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10647033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2FDC217DE for ; Thu, 18 Oct 2018 11:23:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2253F285FC for ; Thu, 18 Oct 2018 11:23:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1592E28609; Thu, 18 Oct 2018 11:23:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A57B3285FC for ; Thu, 18 Oct 2018 11:23:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727439AbeJRTXj (ORCPT ); Thu, 18 Oct 2018 15:23:39 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55720 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727398AbeJRTXj (ORCPT ); Thu, 18 Oct 2018 15:23:39 -0400 Received: by mail-wm1-f65.google.com with SMTP id 206-v6so5054943wmb.5 for ; Thu, 18 Oct 2018 04:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=R/eOFTud1tIooO7xs2xZfy5CIIK3Qpqq2qnBbdXYUXU=; b=f6OBxmSgWmc46egR9FLEU85rI+75yR/by7vVepnWqiNDP6g69ehDVKLZ5xWoZDqzoM TvpRxzDjpZUpu73gLhkWwuuWARUPsCKmE3yHz0q2xtzlfPpGsqdnHi0JHafDmCNgrsUs rP0GF9Jl0maXSzPwPg9u4aV7OidpAm1qEgPSN3P3d/rTAnWNlm425ex0XgpuWGhCVvPi Lk9O6EdCb7ni19ZrWlShBqXgQWzzkKeucfFISJDHvwD8s/dzLkTS52J2aJHduIo0Su4K 7lY+A6Fb70X4BMtW1vxAlL0VW6nVKoVdxsxNiTcBbFTJ8xfLhx/5B9duCCawXChA41y0 44yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=R/eOFTud1tIooO7xs2xZfy5CIIK3Qpqq2qnBbdXYUXU=; b=YKMiUG0ROnVFK4HBbY0lda4P59m6uvaSag89oga+FkFCTBUv6Y7YUGp3WUJPrQ1kCF r2a6pc6dzKXHx3Go5OXJyAjPSv+iEgaf29DeN1aY7jNZa1dx0hG1l2G81Bs/y48CkrQm UIYpivF8tyJ8JPFbBXLcZ311BkpfwfuONkTp6yfnORKFo/smINqJp1vDHfytxZTTBanv q1rMiYtmsy7Vat3IyXhduRIEtSQn2XJwwCPmNb1u7nEVFx7UTwALHmXTOqoFPAdWYig0 71/GsBuzsOLVdXx0KZ50+GLF9HmzsmSAhdszpW9jiAGPnL+D8Gk5wIJtle7HZ7WGQJ7Y nLdg== X-Gm-Message-State: ABuFfojwUl2zuGu3lg3j6zly9M4uwOTkl0fnKj4IFyquPOuvZOeQAxPT WgzcqJgZYdr3SWy+UXXGfPxmrg88 X-Google-Smtp-Source: ACcGV60Q9AEyjsyxFCYYFUEHcjxUtee8mxAAPqgE8IZ8uBev27rqXj6jNBQna52/L1QJbEzin9S9og== X-Received: by 2002:a1c:7c16:: with SMTP id x22-v6mr6808280wmc.16.1539861782754; Thu, 18 Oct 2018 04:23:02 -0700 (PDT) Received: from localhost.localdomain ([94.230.83.227]) by smtp.gmail.com with ESMTPSA id z7-v6sm22743208wrg.52.2018.10.18.04.23.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Oct 2018 04:23:01 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: Al Viro , linux-fsdevel@vger.kernel.org Subject: [PATCH] fs: group frequently accessed fields of struct super_block together Date: Thu, 18 Oct 2018 14:22:55 +0300 Message-Id: <20181018112255.5418-1-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 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 Kernel test robot reported [1] a 6% performance regression in a concurrent unlink(2) workload on commit 60f7ed8c7c4d ("fsnotify: send path type events to group with super block marks"). The performance test was run with no fsnotify marks at all on the data set, so the only extra instructions added by the offending commit are tests of the super_block fields s_fsnotify_{marks,mask} and these tests happen on almost every single inode access. When adding those fields to the super_block struct, we did not give much thought of placing them on a hot cache lines (we just placed them at the end of the struct). Re-organize struct super_block to try and keep some frequently accessed fields on the same cache line. Move the frequently accessed fields s_fsnotify_{marks,mask} near the frequently accessed fields s_fs_info,s_time_gran, while filling a 64bit alignment hole after s_time_gran. Move the seldom accessed fields s_id,s_uuid,s_max_links,s_mode near the seldom accessed fields s_vfs_rename_mutex,s_subtype. Rong Chen confirmed that this patch solved the reported problem. [1] https://lkml.org/lkml/2018/9/30/206 Reported-by: kernel test robot Tested-by: kernel test robot Fixes: 1e6cb72399 ("fsnotify: add super block object type") Signed-off-by: Amir Goldstein --- include/linux/fs.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 25a449f37bb1..baec0b3ff53f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1393,17 +1393,24 @@ struct super_block { struct sb_writers s_writers; + /* START frequently accessed fields block */ + void *s_fs_info; /* Filesystem private info */ + + /* Granularity of c/m/atime in ns (cannot be worse than a second) */ + u32 s_time_gran; +#ifdef CONFIG_FSNOTIFY + __u32 s_fsnotify_mask; + struct fsnotify_mark_connector __rcu *s_fsnotify_marks; +#endif + /* END frequently accessed fields block */ + + /* START seldom accessed fields block */ char s_id[32]; /* Informational name */ uuid_t s_uuid; /* UUID */ - void *s_fs_info; /* Filesystem private info */ unsigned int s_max_links; fmode_t s_mode; - /* Granularity of c/m/atime in ns. - Cannot be worse than a second */ - u32 s_time_gran; - /* * The next field is for VFS *only*. No filesystems have any business * even looking at it. You had been warned. @@ -1415,6 +1422,7 @@ struct super_block { * in /proc/mounts will be "type.subtype" */ char *s_subtype; + /* END seldom accessed fields block */ const struct dentry_operations *s_d_op; /* default d_op for dentries */ @@ -1464,11 +1472,6 @@ struct super_block { spinlock_t s_inode_wblist_lock; struct list_head s_inodes_wb; /* writeback inodes */ - -#ifdef CONFIG_FSNOTIFY - __u32 s_fsnotify_mask; - struct fsnotify_mark_connector __rcu *s_fsnotify_marks; -#endif } __randomize_layout; /* Helper functions so that in most cases filesystems will