From: Petr Tesarik <ptesarik@suse.com> To: Juergen Gross <jgross@suse.com>, Josh Triplett <josh@joshtriplett.org>, Ingo Molnar <mingo@redhat.com>, Thomas Gleixner <tglx@linutronix.de>, Eric Biederman <ebiederm@xmission.com>, "H. Peter Anvin" <hpa@zytor.com>, Boris Ostrovsky <boris.ostrovsky@oracle.com>, "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>, Dave Young <dyoung@redhat.com>, Andrew Morton <akpm@linux-foundation.org>, David Vrabel <david.vrabel@citrix.com> Cc: "moderated list:XEN HYPERVISOR INTERFACE" <xen-devel@lists.xenproject.org>, "maintainer:X86 ARCHITECTURE 32-BIT AND 64-BIT" <x86@kernel.org>, "open list:KEXEC" <kexec@lists.infradead.org>, open list <linux-kernel@vger.kernel.org> Subject: [PATCH 1/2] Add a kexec_crash_loaded() function Date: Wed, 13 Jul 2016 14:19:55 +0200 [thread overview] Message-ID: <20160713121955.14969.69080.stgit@hananiah.suse.cz> (raw) In-Reply-To: <20160713121950.14969.78606.stgit@hananiah.suse.cz> Provide a wrapper function to be used by kernel code to check whether a crash kernel is loaded. It returns the same value that can be seen in /sys/kernel/kexec_crash_loaded by userspace programs. I'm exporting the function, because it will be used by Xen, and it is possible to compile Xen modules separately to enable the use of PV drivers with unmodified bare-metal kernels. Signed-off-by: Petr Tesarik <ptesarik@suse.com> --- include/linux/kexec.h | 2 ++ kernel/kexec_core.c | 6 ++++++ kernel/ksysfs.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index e8acb2b..d461d02 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -228,6 +228,7 @@ extern void *kexec_purgatory_get_symbol_addr(struct kimage *image, extern void __crash_kexec(struct pt_regs *); extern void crash_kexec(struct pt_regs *); int kexec_should_crash(struct task_struct *); +int kexec_crash_loaded(void); void crash_save_cpu(struct pt_regs *regs, int cpu); void crash_save_vmcoreinfo(void); void arch_crash_save_vmcoreinfo(void); @@ -324,6 +325,7 @@ struct task_struct; static inline void __crash_kexec(struct pt_regs *regs) { } static inline void crash_kexec(struct pt_regs *regs) { } static inline int kexec_should_crash(struct task_struct *p) { return 0; } +static inline int kexec_crash_loaded(void) { return 0; } #define kexec_in_progress false #endif /* CONFIG_KEXEC_CORE */ diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 56b3ed0..a303dce 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -95,6 +95,12 @@ int kexec_should_crash(struct task_struct *p) return 0; } +int kexec_crash_loaded(void) +{ + return !!kexec_crash_image; +} +EXPORT_SYMBOL_GPL(kexec_crash_loaded); + /* * When kexec transitions to the new kernel there is a one-to-one * mapping between physical and virtual addresses. On processors diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index 152da4a..bf9fc9d 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -101,7 +101,7 @@ KERNEL_ATTR_RO(kexec_loaded); static ssize_t kexec_crash_loaded_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { - return sprintf(buf, "%d\n", !!kexec_crash_image); + return sprintf(buf, "%d\n", kexec_crash_loaded()); } KERNEL_ATTR_RO(kexec_crash_loaded);
WARNING: multiple messages have this Message-ID (diff)
From: Petr Tesarik <ptesarik@suse.com> To: Juergen Gross <jgross@suse.com>, Josh Triplett <josh@joshtriplett.org>, Ingo Molnar <mingo@redhat.com>, Thomas Gleixner <tglx@linutronix.de>, Eric Biederman <ebiederm@xmission.com>, "H. Peter Anvin" <hpa@zytor.com>, Boris Ostrovsky <boris.ostrovsky@oracle.com>, "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>, Dave Young <dyoung@redhat.com>, Andrew Morton <akpm@linux-foundation.org>, David Vrabel <david.vrabel@citrix.com> Cc: "moderated list:XEN HYPERVISOR INTERFACE" <xen-devel@lists.xenproject.org>, "maintainer:X86 ARCHITECTURE 32-BIT AND 64-BIT" <x86@kernel.org>, "open list:KEXEC" <kexec@lists.infradead.org>, open list <linux-kernel@vger.kernel.org> Subject: [PATCH 1/2] Add a kexec_crash_loaded() function Date: Wed, 13 Jul 2016 14:19:55 +0200 [thread overview] Message-ID: <20160713121955.14969.69080.stgit@hananiah.suse.cz> (raw) In-Reply-To: <20160713121950.14969.78606.stgit@hananiah.suse.cz> Provide a wrapper function to be used by kernel code to check whether a crash kernel is loaded. It returns the same value that can be seen in /sys/kernel/kexec_crash_loaded by userspace programs. I'm exporting the function, because it will be used by Xen, and it is possible to compile Xen modules separately to enable the use of PV drivers with unmodified bare-metal kernels. Signed-off-by: Petr Tesarik <ptesarik@suse.com> --- include/linux/kexec.h | 2 ++ kernel/kexec_core.c | 6 ++++++ kernel/ksysfs.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index e8acb2b..d461d02 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -228,6 +228,7 @@ extern void *kexec_purgatory_get_symbol_addr(struct kimage *image, extern void __crash_kexec(struct pt_regs *); extern void crash_kexec(struct pt_regs *); int kexec_should_crash(struct task_struct *); +int kexec_crash_loaded(void); void crash_save_cpu(struct pt_regs *regs, int cpu); void crash_save_vmcoreinfo(void); void arch_crash_save_vmcoreinfo(void); @@ -324,6 +325,7 @@ struct task_struct; static inline void __crash_kexec(struct pt_regs *regs) { } static inline void crash_kexec(struct pt_regs *regs) { } static inline int kexec_should_crash(struct task_struct *p) { return 0; } +static inline int kexec_crash_loaded(void) { return 0; } #define kexec_in_progress false #endif /* CONFIG_KEXEC_CORE */ diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 56b3ed0..a303dce 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -95,6 +95,12 @@ int kexec_should_crash(struct task_struct *p) return 0; } +int kexec_crash_loaded(void) +{ + return !!kexec_crash_image; +} +EXPORT_SYMBOL_GPL(kexec_crash_loaded); + /* * When kexec transitions to the new kernel there is a one-to-one * mapping between physical and virtual addresses. On processors diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index 152da4a..bf9fc9d 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -101,7 +101,7 @@ KERNEL_ATTR_RO(kexec_loaded); static ssize_t kexec_crash_loaded_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { - return sprintf(buf, "%d\n", !!kexec_crash_image); + return sprintf(buf, "%d\n", kexec_crash_loaded()); } KERNEL_ATTR_RO(kexec_crash_loaded); _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2016-07-13 12:20 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-07-13 12:19 [PATCH 0/2] Allow crash dumps with crash_kexec_post_notifiers Petr Tesarik 2016-07-13 12:19 ` Petr Tesarik 2016-07-13 12:19 ` Petr Tesarik [this message] 2016-07-13 12:19 ` [PATCH 1/2] Add a kexec_crash_loaded() function Petr Tesarik 2016-07-13 12:52 ` Josh Triplett 2016-07-13 12:52 ` Josh Triplett 2016-07-13 12:52 ` Josh Triplett 2016-07-13 13:03 ` Petr Tesarik 2016-07-13 13:03 ` Petr Tesarik 2016-07-13 13:03 ` Petr Tesarik 2016-07-13 12:19 ` Petr Tesarik 2016-07-13 12:20 ` [PATCH 2/2] Allow kdump with crash_kexec_post_notifiers Petr Tesarik 2016-07-13 12:20 ` Petr Tesarik 2016-07-13 12:53 ` David Vrabel 2016-07-13 12:53 ` [Xen-devel] " David Vrabel 2016-07-13 12:53 ` David Vrabel 2016-08-01 11:55 ` Jan Beulich 2016-08-01 11:55 ` [Xen-devel] " Jan Beulich 2016-08-01 11:55 ` Jan Beulich [not found] ` <579F54B502000078001013F1@suse.com> 2016-08-01 13:02 ` Petr Tesarik 2016-08-01 13:47 ` Jan Beulich [not found] ` <579F6F2E0200007800101563@suse.com> 2016-08-01 14:15 ` Petr Tesarik 2016-08-01 14:22 ` Jan Beulich 2016-08-01 14:25 ` Konrad Rzeszutek Wilk 2016-08-03 17:55 ` Daniel Kiper [not found] ` <579F773A02000078001015C1@suse.com> 2016-08-01 15:17 ` Petr Tesarik 2016-07-13 12:20 ` Petr Tesarik 2016-07-13 12:27 ` [PATCH 0/2] Allow crash dumps " Petr Tesarik 2016-07-13 12:27 ` Petr Tesarik 2016-07-13 12:27 ` Petr Tesarik
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=20160713121955.14969.69080.stgit@hananiah.suse.cz \ --to=ptesarik@suse.com \ --cc=akpm@linux-foundation.org \ --cc=boris.ostrovsky@oracle.com \ --cc=david.vrabel@citrix.com \ --cc=dyoung@redhat.com \ --cc=ebiederm@xmission.com \ --cc=hpa@zytor.com \ --cc=jgross@suse.com \ --cc=josh@joshtriplett.org \ --cc=kexec@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mingo@redhat.com \ --cc=paulmck@linux.vnet.ibm.com \ --cc=tglx@linutronix.de \ --cc=x86@kernel.org \ --cc=xen-devel@lists.xenproject.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: linkBe 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.