netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin LaHaise <bcrl@lhnet.ca>
To: Eric Dumazet <eric.dumazet@gmail.com>,
	Greg Kroah-Hartman <gregkh@suse.de>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	Octavian Purdila <opurdila@ixiacom.com>,
	netdev@vger.kernel.org, Cosmin Ratiu <cratiu@ixiacom.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] sysfs directory scaling: count number of children dirs
Date: Sun, 1 Nov 2009 11:33:09 -0500	[thread overview]
Message-ID: <20091101163309.GC7911@kvack.org> (raw)
In-Reply-To: <20091101163230.GB7911@kvack.org>

sysfs_count_nlink() is a bottleneck during mass bring up of network 
interfaces.  Eliminate this problem by tracking the number of directories.

Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
diff -u b/fs/sysfs/dir.c b/fs/sysfs/dir.c
--- b/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -70,6 +70,7 @@
 	sd->s_sibling = *pos;
 	sd->s_sibling_prev = prev;
 	*pos = sd;
+	parent_sd->s_nr_children_dir += (sysfs_type(sd) == SYSFS_DIR);
 
 	// rb tree insert
 	new = &(parent_sd->s_dir.child_rb_root.rb_node);
@@ -118,6 +119,7 @@
 	if (sd->s_sibling)
 		sd->s_sibling->s_sibling_prev = prev;
 	
+	sd->s_parent->s_nr_children_dir -= (sysfs_type(sd) == SYSFS_DIR);
 	sd->s_sibling_prev = NULL;
 	rb_erase(&sd->s_rb_node, &sd->s_parent->s_dir.child_rb_root);
 }
diff -u b/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
--- b/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -71,6 +71,8 @@
 	ino_t			s_ino;
 	umode_t			s_mode;
 	struct sysfs_inode_attrs *s_iattr;
+
+	int			s_nr_children_dir;
 };
 
 #define SD_DEACTIVATED_BIAS		INT_MIN
only in patch2:
unchanged:
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -191,14 +191,7 @@ static struct lock_class_key sysfs_inode_imutex_key;
 
 static int sysfs_count_nlink(struct sysfs_dirent *sd)
 {
-	struct sysfs_dirent *child;
-	int nr = 0;
-
-	for (child = sd->s_dir.children; child; child = child->s_sibling)
-		if (sysfs_type(child) == SYSFS_DIR)
-			nr++;
-
-	return nr + 2;
+	return sd->s_nr_children_dir + 2;
 }
 
 static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)

  reply	other threads:[~2009-11-01 16:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-01 16:31 [PATCH 1/3] sysfs directory scaling: rbtree for dirent name lookups Benjamin LaHaise
2009-11-01 16:32 ` [PATCH 2/3] sysfs directory scaling: doubly linked list for dirents Benjamin LaHaise
2009-11-01 16:33   ` Benjamin LaHaise [this message]
2009-11-03  3:50 ` [PATCH 1/3] sysfs directory scaling: rbtree for dirent name lookups Greg KH
2009-11-03  6:14   ` Eric Dumazet
2009-11-03  7:01     ` [PATCH] sysctl: reduce ram usage by 40 % Eric Dumazet
2009-11-03 10:23       ` Eric W. Biederman
2009-11-03 16:07     ` [PATCH 1/3] sysfs directory scaling: rbtree for dirent name lookups Greg KH
2009-11-03 16:38       ` Octavian Purdila
2009-11-03 16:45       ` Benjamin LaHaise
2009-11-03 17:56         ` Greg KH
2009-11-03 22:28       ` Eric W. Biederman
2009-11-03 20:01   ` Benjamin LaHaise
2009-11-03 21:32     ` Eric W. Biederman
2009-11-03 21:43       ` Eric W. Biederman
2009-11-03 21:56         ` Benjamin LaHaise
2009-11-03 22:06           ` Eric Dumazet
2009-11-03 21:52       ` Benjamin LaHaise
2009-11-03 22:18         ` Eric W. Biederman
2009-11-03 10:41 ` Eric W. Biederman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091101163309.GC7911@kvack.org \
    --to=bcrl@lhnet.ca \
    --cc=cratiu@ixiacom.com \
    --cc=ebiederm@xmission.com \
    --cc=eric.dumazet@gmail.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=opurdila@ixiacom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).