From: John Kacur <jkacur@redhat.com>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Sven-Thorsten Dietrich <sdietrich@suse.de>
Subject: Re: [PATCH] x86: Remove the bkl from msr_open()
Date: Wed, 7 Oct 2009 22:15:36 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.00.0910072214290.15183@localhost.localdomain> (raw)
In-Reply-To: <1254944602-7382-1-git-send-email-fweisbec@gmail.com>
On Wed, 7 Oct 2009, Frederic Weisbecker wrote:
> Remove the big kernel lock from msr_open() as it doesn't protect
> anything there.
>
> The only racy event that can happen here is a concurrent cpu shutdown.
>
> So let's look at what could be racy during/after the above event:
>
> - The cpu_online() check is racy, but the bkl doesn't help about
> that anyway it disables preemption but we may be chcking another
> cpu than the current one.
> Also the cpu can still become offlined between open and read calls.
>
> - The cpu_data(cpu) returns a safe pointer too. It won't be released on
> cpu offlining. But some fields can be changed from
> arch/x86/kernel/smpboot.c:remove_siblinginfo() :
>
> - phys_proc_id
> - cpu_core_id
>
> Those are not read from msr_open(). What we are checking is the
> x86_capability that is left untouched on offlining.
>
> So this removal looks safe.
>
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: John Kacur <jkacur@redhat.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Sven-Thorsten Dietrich <sdietrich@suse.de>
> ---
> arch/x86/kernel/msr.c | 16 ++++++----------
> 1 files changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
> index 6a3cefc..5534499 100644
> --- a/arch/x86/kernel/msr.c
> +++ b/arch/x86/kernel/msr.c
> @@ -174,21 +174,17 @@ static int msr_open(struct inode *inode, struct file *file)
> {
> unsigned int cpu = iminor(file->f_path.dentry->d_inode);
> struct cpuinfo_x86 *c = &cpu_data(cpu);
> - int ret = 0;
>
> - lock_kernel();
> cpu = iminor(file->f_path.dentry->d_inode);
>
> - if (cpu >= nr_cpu_ids || !cpu_online(cpu)) {
> - ret = -ENXIO; /* No such CPU */
> - goto out;
> - }
> + if (cpu >= nr_cpu_ids || !cpu_online(cpu))
> + return -ENXIO; /* No such CPU */
> +
> c = &cpu_data(cpu);
> if (!cpu_has(c, X86_FEATURE_MSR))
> - ret = -EIO; /* MSR not supported */
> -out:
> - unlock_kernel();
> - return ret;
> + return -EIO; /* MSR not supported */
> +
> + return 0;
> }
>
> /*
> --
> 1.6.2.3
>
>
This case looks very similar to the cpuid_open one.
Reviewed-by: John Kacur <jkacur@redhat.com>
next prev parent reply other threads:[~2009-10-07 20:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-07 18:19 [PATCH RFC] BKL not necessary in cpuid_open John Kacur
2009-10-07 19:12 ` Frederic Weisbecker
2009-10-07 19:14 ` Sven-Thorsten Dietrich
2009-10-07 19:31 ` John Kacur
2009-10-07 20:00 ` Sven-Thorsten Dietrich
2009-10-07 19:43 ` [PATCH] x86: Remove the bkl from msr_open() Frederic Weisbecker
2009-10-07 20:15 ` John Kacur [this message]
2009-10-07 21:10 ` [tip:x86/cpu] x86, msr: " tip-bot for Frederic Weisbecker
2009-10-07 20:13 ` [PATCH RFC] BKL not necessary in cpuid_open Frederic Weisbecker
2009-10-07 21:01 ` Thomas Gleixner
2009-10-07 21:44 ` Frederic Weisbecker
2009-10-07 21:58 ` John Kacur
2009-10-10 21:18 ` Frederic Weisbecker
2009-10-07 22:43 ` [tip:x86/cpu] x86, cpuid: Remove the bkl from cpuid_open() tip-bot for John Kacur
2009-10-09 16:05 ` [PATCH RFC] BKL not necessary in cpuid_open Arnd Bergmann
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=alpine.LFD.2.00.0910072214290.15183@localhost.localdomain \
--to=jkacur@redhat.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=sdietrich@suse.de \
--cc=tglx@linutronix.de \
/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