From: Ingo Molnar <mingo@elte.hu>
To: Jaswinder Singh Rajput <jaswinder@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
x86 maintainers <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [git-pull -tip V2] x86: cpu architecture debug code
Date: Tue, 10 Mar 2009 13:28:06 +0100 [thread overview]
Message-ID: <20090310122806.GE5794@elte.hu> (raw)
In-Reply-To: <1236684201.3301.11.camel@localhost.localdomain>
* Jaswinder Singh Rajput <jaswinder@kernel.org> wrote:
> Added more features, now it supports:
> 1. TSS (GPR, Segment, Eflags)
> 2. Control Regs
> 3. DT (IDT, GDT, LDT, TR)
> 4. Debug regs
> 5. LAPIC
> 6. MSRs
looks pretty good!
A few small details:
> +#include <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/smp.h>
> +#include <linux/regset.h>
> +#include <linux/sched.h>
> +#include <linux/debugfs.h>
> +#include <linux/seq_file.h>
> +#include <asm/desc.h>
> +#include <asm/cpu_debug.h>
Please use the include files style as can be seen in
arch/x86/mm/fault.c. The reason why we do it is to reduce
conflicts when files are modified by multiple topic branches at
once.
> + vendor = per_cpu(cpu_model, cpu) >> 16;
> + modelflag = per_cpu(cpu_modelflag, cpu);
> + index = get_cpu_range_count(cpu);
> + for (i = 0; i < index; i++) {
please put a newline before loops in such cases, to make it
stand out some more.
> +/* This function can also be called with seq = NULL for printk */
> +static void print_msr(struct seq_file *seq, unsigned cpu, unsigned flag)
> +{
> + int i, range;
> + u32 low, high;
> + unsigned msr, msr_min, msr_max;
> + struct cpu_private *priv;
please try to order local variables like this:
> + unsigned msr, msr_min, msr_max;
> + struct cpu_private *priv;
> + u32 low, high;
> + int i, range;
(this is done for similar reasons as the include files section
ordering)
this affects other functions in the file too.
> +static const struct seq_operations cpu_seq_ops = {
> + .start = cpu_seq_start,
> + .next = cpu_seq_next,
> + .stop = cpu_seq_stop,
> + .show = cpu_seq_show,
> +};
Please use consistent vertical alignment wherever possible
thoughout the file, i.e.:
> + .start = cpu_seq_start,
> + .next = cpu_seq_next,
> + .stop = cpu_seq_stop,
> + .show = cpu_seq_show,
(note this applies to other places too in this same file.)
> +static int cpu_seq_open(struct inode *inode, struct file *file)
> +{
> + int err;
> + struct seq_file *seq;
> + struct cpu_private *priv = inode->i_private;
> +
> + err = seq_open(file, &cpu_seq_ops);
> + mutex_lock(&cpu_debug_lock);
> + if (!err) {
> + seq = file->private_data;
> + seq->private = priv;
> + }
> + mutex_unlock(&cpu_debug_lock);
what is the purpose of the locking here? What other codepath
can race with this?
> + priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> + if (priv == NULL)
> + return -ENOMEM;
> +
> + mutex_lock(&cpu_debug_lock);
> + priv->cpu = cpu;
> + priv->type = type;
> + priv->reg = reg;
> + priv->file = file;
> + per_cpu(priv_arr[type], cpu) = priv;
> + per_cpu(cpu_priv_count, cpu)++;
> + mutex_unlock(&cpu_debug_lock);
what's the purpose of the locking here and why does it cover
more than just the per_cpu() related critical section?
Ingo
next prev parent reply other threads:[~2009-03-10 12:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-10 11:23 [git-pull -tip V2] x86: cpu architecture debug code Jaswinder Singh Rajput
2009-03-10 12:28 ` Ingo Molnar [this message]
2009-03-10 15:09 ` Jaswinder Singh Rajput
2009-03-10 15:20 ` Ingo Molnar
2009-03-10 16:09 ` Jaswinder Singh Rajput
2009-03-10 17:45 ` Ingo Molnar
2009-03-10 23:55 ` Jaswinder Singh Rajput
2009-03-11 10:53 ` Ingo Molnar
2009-03-11 11:25 ` Jaswinder Singh Rajput
2009-03-11 11:34 ` Ingo Molnar
2009-03-13 7:34 ` Jeremy Fitzhardinge
2009-03-13 8:07 ` Jaswinder Singh Rajput
2009-03-11 11:54 ` Jaswinder Singh Rajput
2009-03-11 12:45 ` Jaswinder Singh Rajput
2009-03-11 12:50 ` Ingo Molnar
2009-03-11 13:13 ` Ingo Molnar
2009-03-11 13:43 ` Jaswinder Singh Rajput
2009-03-11 13:48 ` Ingo Molnar
2009-03-13 7:37 ` Jeremy Fitzhardinge
2009-03-10 17:48 ` [tip:x86/debug] " Jaswinder Singh Rajput
2009-03-10 19:53 ` [git-pull -tip V2] " Valdis.Kletnieks
2009-03-10 22:00 ` Ingo Molnar
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=20090310122806.GE5794@elte.hu \
--to=mingo@elte.hu \
--cc=hpa@zytor.com \
--cc=jaswinder@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.