From: Cong Wang <xiyou.wangcong@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Dennis1.Chen@amd.com, Cong Wang <xiyou.wangcong@gmail.com>,
Eric Dumazet <eric.dumazet@gmail.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Rusty Russell <rusty@rustcorp.com.au>,
Alexander Viro <viro@zeniv.linux.org.uk>,
NeilBrown <neilb@suse.de>, Kay Sievers <kay.sievers@vrfy.org>,
Joe Perches <joe@perches.com>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH 5/7] module: take rcu_read_lock_sched() for /proc read
Date: Thu, 15 Mar 2012 22:48:59 +0800 [thread overview]
Message-ID: <1331822941-19938-5-git-send-email-xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <1331822941-19938-1-git-send-email-xiyou.wangcong@gmail.com>
In the seq file operations, it still hold module_mutex for just reading
the module list, switch to rcu_read_lock_sched() too.
A new function seq_list_start_rcu() is introduced for this.
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
fs/seq_file.c | 12 ++++++++++++
include/linux/seq_file.h | 2 ++
kernel/module.c | 6 +++---
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 4023d6b..5b01e04 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -674,6 +674,18 @@ struct list_head *seq_list_start(struct list_head *head, loff_t pos)
}
EXPORT_SYMBOL(seq_list_start);
+struct list_head *seq_list_start_rcu(struct list_head *head, loff_t pos)
+{
+ struct list_head *lh = head;
+
+ list_for_each_continue_rcu(lh, head)
+ if (pos-- == 0)
+ return lh;
+
+ return NULL;
+}
+EXPORT_SYMBOL(seq_list_start_rcu);
+
struct list_head *seq_list_start_head(struct list_head *head, loff_t pos)
{
if (!pos)
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 44f1514..7848189 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -130,6 +130,8 @@ int seq_release_private(struct inode *, struct file *);
extern struct list_head *seq_list_start(struct list_head *head,
loff_t pos);
+extern struct list_head *seq_list_start_rcu(struct list_head *head,
+ loff_t pos);
extern struct list_head *seq_list_start_head(struct list_head *head,
loff_t pos);
extern struct list_head *seq_list_next(void *v, struct list_head *head,
diff --git a/kernel/module.c b/kernel/module.c
index 73e1f95..06e7dc5 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3313,8 +3313,8 @@ static char *module_flags(struct module *mod, char *buf)
/* Called by the /proc file system to return a list of modules. */
static void *m_start(struct seq_file *m, loff_t *pos)
{
- mutex_lock(&module_mutex);
- return seq_list_start(&modules, *pos);
+ rcu_read_lock_sched();
+ return seq_list_start_rcu(&modules, *pos);
}
static void *m_next(struct seq_file *m, void *p, loff_t *pos)
@@ -3324,7 +3324,7 @@ static void *m_next(struct seq_file *m, void *p, loff_t *pos)
static void m_stop(struct seq_file *m, void *p)
{
- mutex_unlock(&module_mutex);
+ rcu_read_unlock_sched();
}
static int m_show(struct seq_file *m, void *p)
--
1.7.7.6
next prev parent reply other threads:[~2012-03-15 14:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-15 14:48 [V3 PATCH 1/7] module: replace preempt_disable with rcu_read_lock_sched Cong Wang
2012-03-15 14:48 ` [PATCH 2/7] module: take rcu_read_lock_sched for find_symbol Cong Wang
2012-03-15 14:48 ` [PATCH 3/7] module: take rcu_read_lock_sched for find_module Cong Wang
2012-03-15 16:29 ` Eric Dumazet
2012-03-15 14:48 ` [PATCH 4/7] module: take rcu_read_lock_sched in module_kallsyms_on_each_symbol() Cong Wang
2012-03-15 14:48 ` Cong Wang [this message]
2012-03-15 16:18 ` [PATCH 5/7] module: take rcu_read_lock_sched() for /proc read Eric Dumazet
2012-03-15 14:49 ` [PATCH 6/7] module: add two missing synchronize_sched() Cong Wang
2012-03-15 16:26 ` Eric Dumazet
2012-03-15 14:49 ` [PATCH 7/7] module: avoid exporting module_mutex Cong Wang
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=1331822941-19938-5-git-send-email-xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=Dennis1.Chen@amd.com \
--cc=akpm@linux-foundation.org \
--cc=eric.dumazet@gmail.com \
--cc=joe@perches.com \
--cc=kay.sievers@vrfy.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@suse.de \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rusty@rustcorp.com.au \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®