public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Yong Zhang <yong.zhang0@gmail.com>
To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Keika Kobayashi <kobayashi.kk@ncos.nec.co.jp>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>
Subject: [PATCH 1/2] proc/insterrupts: make it cpu hotplug safe
Date: Wed, 27 Jul 2011 12:56:22 +0800	[thread overview]
Message-ID: <1311742583-18633-1-git-send-email-yong.zhang0@gmail.com> (raw)
In-Reply-To: <20110726163424.GC2576@osiris.boeblingen.de.ibm.com>

KOSAKI Motonhiro noticed that the reader of /proc/interrupts
could be preempted by cpu hotplug, thus the reader can get
broken result due to show_interrupts() iterate every online
cpu without any protection.

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Keika Kobayashi <kobayashi.kk@ncos.nec.co.jp>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 fs/proc/interrupts.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
index 05029c0..d5642a6 100644
--- a/fs/proc/interrupts.c
+++ b/fs/proc/interrupts.c
@@ -4,6 +4,7 @@
 #include <linux/irqnr.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/cpu.h>
 
 /*
  * /proc/interrupts
@@ -35,14 +36,21 @@ static const struct seq_operations int_seq_ops = {
 
 static int interrupts_open(struct inode *inode, struct file *filp)
 {
+	get_online_cpus();
 	return seq_open(filp, &int_seq_ops);
 }
 
+static int interrupts_release(struct inode *inode, struct file *filp)
+{
+	put_online_cpus();
+	return seq_release(inode, filp);
+}
+
 static const struct file_operations proc_interrupts_operations = {
 	.open		= interrupts_open,
 	.read		= seq_read,
 	.llseek		= seq_lseek,
-	.release	= seq_release,
+	.release	= interrupts_release,
 };
 
 static int __init proc_interrupts_init(void)
-- 
1.7.4.1

       reply	other threads:[~2011-07-27  4:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20110726163424.GC2576@osiris.boeblingen.de.ibm.com>
2011-07-27  4:56 ` Yong Zhang [this message]
2011-07-27  4:56   ` [PATCH 2/2] [S390] irq: fix show_interrupts() vs cpu hotplug Yong Zhang
2011-07-27  6:06     ` Heiko Carstens
2011-07-27  5:20   ` [PATCH 1/2] proc/insterrupts: make it cpu hotplug safe KOSAKI Motohiro
2011-07-27  5:47     ` Yong Zhang
2011-07-27  5:55       ` KOSAKI Motohiro
2011-07-27  6:05   ` Heiko Carstens

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=1311742583-18633-1-git-send-email-yong.zhang0@gmail.com \
    --to=yong.zhang0@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=kobayashi.kk@ncos.nec.co.jp \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    /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