public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Corey Minyard <cminyard@mvista.com>
To: John Levon <levon@movementarian.org>
Cc: "'Zwane Mwaikambo'" <zwane@holomorphy.com>, linux-kernel@vger.kernel.org
Subject: Re: NMI handling rework for x86
Date: Fri, 15 Nov 2002 13:35:16 -0600	[thread overview]
Message-ID: <3DD54C74.2080808@mvista.com> (raw)
In-Reply-To: 20021115192842.GC83229@compsoc.man.ac.uk

[-- Attachment #1: Type: text/plain, Size: 831 bytes --]

John Levon wrote:

>>I have also created a kernel module that loops requesting and releasing 
>>the NMI, and counting the number of NMIs that actually get hit by the 
>>handler that is installed..  This is on a dual 2.8GHZ Pentium 4 machine 
>>with hyperthreading (so 4 processors, sort of).  I have six processes 
>>doing the request/release and some other processes eating CPU on each 
>>processor.  This has been running for almost three hours, about 
>>10,000,000 NMIs have occurred (around 1000/sec).  Around 4700 NMIs have 
>>been caught by the handler, meaning that it was a close race between the 
>>removal and the NMI occurring.  So it looks good.
>>    
>>
>
>Can you send me the test module so I don't have to bother writing one
>myself ?
>
>I'll try to test this weekend
>
Certainly.  It's attached.

Thanks,

-Corey


[-- Attachment #2: test_nmi.c --]
[-- Type: text/plain, Size: 2290 bytes --]

#include <linux/config.h>
#include <linux/module.h>
#include <linux/miscdevice.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/nmi.h>
#include <linux/notifier.h>
#include <asm/atomic.h>

static atomic_t nmi_count = ATOMIC_INIT(0);
static atomic_t request_count = ATOMIC_INIT(0);

static int
do_nmi(void *dev_id, struct pt_regs *regs, int cpu, int handled)
{
	atomic_inc(&nmi_count);
	return NOTIFY_DONE;
}

static ssize_t do_read(struct file *file,
		       char        *buf,
		       size_t      count,
		       loff_t      *ppos)
{
	int rv;
	long last_jiffies = jiffies;
	struct nmi_handler nmi_handler =
	{
		.link     = LIST_HEAD_INIT(nmi_handler.link),
		.dev_name = "nmi_test",
		.dev_id   = NULL,
		.handler  = do_nmi,
		.priority = 0, /* Call us last. */
	};


	printk("NMI test: start test\n");

	for (;;) {
		if (signal_pending(current))
			return -ERESTARTSYS;
		
		rv = request_nmi(&nmi_handler);
		if (rv) {
			printk(KERN_WARNING
			       "NMI test: Can't register nmi handler\n");
			return rv;
		}

//		set_current_state(TASK_INTERRUPTIBLE);
//		schedule_timeout(1);

		release_nmi(&nmi_handler);

		atomic_inc(&request_count);
		if ((jiffies - last_jiffies) >= HZ) {
			last_jiffies = jiffies;
			printk("NMIs = %d, requests=%d\n",
			       atomic_read(&nmi_count),
			       atomic_read(&request_count));
		}
	}
	return 0;
}

static int do_open(struct inode *ino, struct file *filep)
{
	return 0;
}

static int do_close(struct inode *ino, struct file *filep)
{
	printk("NMI test: in close\n");
	return 0;
}

static struct file_operations nmi_test_fops = {
	.owner   = THIS_MODULE,
	.read    = do_read,
	.write   = NULL,
	.ioctl   = NULL,
	.open    = do_open,
	.release = do_close,
};

static struct miscdevice nmi_test_miscdev = {
	130,
	"nmi_test",
	&nmi_test_fops
};

static int __init nmi_test_init(void)
{
	int rv;

	rv = misc_register(&nmi_test_miscdev);
	if (rv < 0) {
		printk("NMI test: Unable to register misc device\n");
		return rv;
	}

	printk(KERN_INFO "NMI test by "
	       "Corey Minyard (minyard@mvista.com)\n");

	return 0;
}

static void __exit nmi_test_exit(void)
{
	/* Make sure no one can call us any more. */
	misc_deregister(&nmi_test_miscdev);
}
module_exit(nmi_test_exit);
module_init(nmi_test_init);
MODULE_LICENSE("GPL");

  reply	other threads:[~2002-11-15 19:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-15  4:30 NMI handling rework for x86 Corey Minyard
2002-11-15  4:40 ` Zwane Mwaikambo
2002-11-15  6:10   ` Dipankar Sarma
2002-11-15  7:40     ` Zwane Mwaikambo
2002-11-15  8:13       ` Dipankar Sarma
2002-11-15  8:18         ` Zwane Mwaikambo
2002-11-15  8:50           ` Dipankar Sarma
2002-11-15 17:41           ` John Levon
2002-11-15 22:46             ` Zwane Mwaikambo
2002-11-15  5:12 ` John Levon
2002-11-15  5:19   ` John Levon
2002-11-15 14:13   ` Corey Minyard
2002-11-15 17:48     ` John Levon
2002-11-15 19:00       ` Corey Minyard
2002-11-15 19:28         ` John Levon
2002-11-15 19:35           ` Corey Minyard [this message]
2002-11-17  2:00         ` John Levon
2002-11-17  2:31           ` Zwane Mwaikambo
2002-11-18 16:48             ` Corey Minyard
2002-11-18 15:34           ` Corey Minyard
2002-11-15  5:20 ` Randy.Dunlap
2002-11-15  9:50 ` Mikael Pettersson

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=3DD54C74.2080808@mvista.com \
    --to=cminyard@mvista.com \
    --cc=levon@movementarian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zwane@holomorphy.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