From: Li Zhong <zhong@linux.vnet.ibm.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
x86@kernel.org, a.p.zijlstra@chello.nl, paulus@samba.org,
mingo@elte.hu, acme@ghostprotocols.net
Subject: [PATCH 1/2 x86] fix page faults by nmi handler in nmi if kmemcheck is enabled
Date: Mon, 20 Feb 2012 14:04:39 +0800 [thread overview]
Message-ID: <1329717879.3448.30.camel@ThinkPad-T61> (raw)
In-Reply-To: <1329717665.3448.28.camel@ThinkPad-T61>
This patch tries to
change the nmi handler name from a pointer to an array.
use __get_free_pages instead of kzalloc if CONFIG_KMEMCHECK is
enabled.
Signed-off-by: Li Zhong <zhong@linux.vnet.ibm.com>
---
arch/x86/kernel/nmi.c | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 47acaf3..84aa03a 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -36,7 +36,7 @@ struct nmiaction {
struct list_head list;
nmi_handler_t handler;
unsigned int flags;
- char *name;
+ char name[NMI_MAX_NAMELEN];
};
struct nmi_desc {
@@ -169,16 +169,18 @@ int register_nmi_handler(unsigned int type,
nmi_handler_t handler,
if (!handler)
return -EINVAL;
+#ifdef CONFIG_KMEMCHECK
+ action = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+ get_order(sizeof(*action)));
+#else
action = kzalloc(sizeof(struct nmiaction), GFP_KERNEL);
+#endif
if (!action)
goto fail_action;
action->handler = handler;
action->flags = nmiflags;
- action->name = kstrndup(devname, NMI_MAX_NAMELEN, GFP_KERNEL);
- if (!action->name)
- goto fail_action_name;
-
+ strncpy(action->name, devname, sizeof(action->name));
retval = __setup_nmi(type, action);
if (retval)
@@ -187,9 +189,11 @@ int register_nmi_handler(unsigned int type,
nmi_handler_t handler,
return retval;
fail_setup_nmi:
- kfree(action->name);
-fail_action_name:
+#ifdef CONFIG_KMEMCHECK
+ free_pages((unsigned long)action, get_order(sizeof(*action)));
+#else
kfree(action);
+#endif
fail_action:
return retval;
@@ -202,8 +206,11 @@ void unregister_nmi_handler(unsigned int type,
const char *name)
a = __free_nmi(type, name);
if (a) {
- kfree(a->name);
+#ifdef CONFIG_KMEMCHECK
+ free_pages((unsigned long)a, get_order(sizeof(*a)));
+#else
kfree(a);
+#endif
}
}
--
1.7.5.4
next prev parent reply other threads:[~2012-02-20 6:05 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-20 6:01 [PATCH 0/2 x86] fix some page faults in nmi if kmemcheck is enabled Li Zhong
2012-02-20 6:04 ` Li Zhong [this message]
2012-02-20 6:07 ` [PATCH 2/2 x86] fix page faults by perf events " Li Zhong
2012-02-20 11:00 ` [PATCH 0/2 x86] fix some page faults " Peter Zijlstra
2012-02-21 1:42 ` Li Zhong
2012-02-21 10:17 ` Peter Zijlstra
2012-02-23 9:53 ` Li Zhong
2012-02-27 10:58 ` Peter Zijlstra
2012-02-28 2:45 ` Li Zhong
2012-03-02 19:44 ` Don Zickus
2012-03-05 1:49 ` Li Zhong
2012-03-05 10:05 ` [PATCH v2 x86 1/2] fix page faults by nmiaction " Li Zhong
2012-03-05 10:29 ` Wim Van Sebroeck
2012-03-06 1:46 ` Li Zhong
2012-03-05 15:54 ` Don Zickus
2012-03-05 17:55 ` Peter Zijlstra
2012-03-05 17:49 ` Peter Zijlstra
2012-03-05 21:45 ` Don Zickus
2012-03-06 10:09 ` [PATCH v3 " Li Zhong
2012-03-06 10:27 ` Vegard Nossum
2012-03-09 9:52 ` Li Zhong
2012-03-06 15:00 ` Don Zickus
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=1329717879.3448.30.camel@ThinkPad-T61 \
--to=zhong@linux.vnet.ibm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox