Skip to contentSkip to conversation

kexec: add a dummy note for each offline cpu

PATCH Superseded Pingfan Liu 5 participants 18 messages Dec 14, 2016 – Dec 15, 2016

Subsystems (6)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 kexec: add a dummy note for each offline cpu

kexec-tools always allocates program headers for each possible cpu. This incurs zero PT_NOTE for offline cpu. We mark this case so that later, the capture kernel can distinguish it from the mistake of allocated program header.
The counterpart of the capture kernel comes in next patch.

---
This unnecessary warning buzz on all archs when there is offline cpu

 include/uapi/linux/elf.h | 1 +
 kernel/kexec_core.c      | 9 +++++++++
 2 files changed, 10 insertions(+)
include/uapi/linux/elf.h +1 -0
index b59ee07..9744f1e 100644
@@ -367,6 +367,7 @@ typedef struct elf64_shdr {
  * using the corresponding note types via the PTRACE_GETREGSET and
  * PTRACE_SETREGSET requests.
  */
+#define NT_DUMMY	0
 #define NT_PRSTATUS	1
 #define NT_PRFPREG	2
 #define NT_PRPSINFO	3
kernel/kexec_core.c +9 -0
index 5616755..aeac16e 100644
@@ -891,9 +891,12 @@ void __crash_kexec(struct pt_regs *regs)
 	if (mutex_trylock(&kexec_mutex)) {
 		if (kexec_crash_image) {
 			struct pt_regs fixed_regs;
+			unsigned int cpu;
 
 			crash_setup_regs(&fixed_regs, regs);
 			crash_save_vmcoreinfo();
+			for_each_cpu_not(cpu, cpu_online_mask)
+				crash_save_cpu(NULL, cpu);
 			machine_crash_shutdown(&fixed_regs);
 			machine_kexec(kexec_crash_image);
 		}
@@ -1040,6 +1043,12 @@ void crash_save_cpu(struct pt_regs *regs, int cpu)
 	buf = (u32 *)per_cpu_ptr(crash_notes, cpu);
 	if (!buf)
 		return;
+	if (regs == NULL) {
+		buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_DUMMY,
+				NULL, 0);
+		final_note(buf);
+		return;
+	}
 	memset(&prstatus, 0, sizeof(prstatus));
 	prstatus.pr_pid = current->pid;
 	elf_core_copy_kernel_regs(&prstatus.pr_reg, regs);
Signature · 7 lines
2.7.4


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

PATCH 2/2 proc/vmcore: check the dummy place holder for offline cpu to avoid warning

kexec-tools always allocates program headers for possible cpus. But when crashing, offline cpus have dummy headers. We do not copy these dummy notes into ELF file, also have no need of warning on them.

---
 fs/proc/vmcore.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
fs/proc/vmcore.c +17 -4
index 8ab782d..bbc9dad 100644
@@ -526,9 +526,10 @@ static u64 __init get_vmcore_size(size_t elfsz, size_t elfnotesegsz,
  */
 static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr)
 {
-	int i, rc=0;
+	int i, j, rc = 0;
 	Elf64_Phdr *phdr_ptr;
 	Elf64_Nhdr *nhdr_ptr;
+	bool warn;
 
 	phdr_ptr = (Elf64_Phdr *)(ehdr_ptr + 1);
 	for (i = 0; i < ehdr_ptr->e_phnum; i++, phdr_ptr++) {
@@ -536,6 +537,7 @@ static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr)
 		u64 offset, max_sz, sz, real_sz = 0;
 		if (phdr_ptr->p_type != PT_NOTE)
 			continue;
+		warn = true;
 		max_sz = phdr_ptr->p_memsz;
 		offset = phdr_ptr->p_offset;
 		notes_section = kmalloc(max_sz, GFP_KERNEL);
@@ -547,7 +549,7 @@ static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr)
 			return rc;
 		}
 		nhdr_ptr = notes_section;
-		while (nhdr_ptr->n_namesz != 0) {
+		for (j = 0; nhdr_ptr->n_namesz != 0; j++) {
 			sz = sizeof(Elf64_Nhdr) +
 				(((u64)nhdr_ptr->n_namesz + 3) & ~3) +
 				(((u64)nhdr_ptr->n_descsz + 3) & ~3);
@@ -559,11 +561,22 @@ static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr)
 			real_sz += sz;
 			nhdr_ptr = (Elf64_Nhdr*)((char*)nhdr_ptr + sz);
 		}
+		if (real_sz != 0)
+			warn = false;
+		if (j == 1) {
+			nhdr_ptr = notes_section;
+			if ((nhdr_ptr->n_type == NT_DUMMY)
+			  && !strncmp(KEXEC_CORE_NOTE_NAME,
+				(char *)nhdr_ptr + sizeof(Elf64_Nhdr),
+				strlen(KEXEC_CORE_NOTE_NAME))) {
+				/* do not copy this dummy note */
+				real_sz = 0;
+			}
+		}
 		kfree(notes_section);
 		phdr_ptr->p_memsz = real_sz;
-		if (real_sz == 0) {
+		if (warn)
 			pr_warn("Warning: Zero PT_NOTE entries found\n");
-		}
 	}
 
 	return 0;
Signature · 7 lines
2.7.4


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#2 lore raw

Re: [PATCH 2/2] [fs] proc/vmcore: check the dummy place holder for offline cpu to avoid warning

Quoted 34 lines · Pingfan Liu

kexec-tools always allocates program headers for possible cpus. But when crashing, offline cpus have dummy headers. We do not copy these dummy notes into ELF file, also have no need of warning on them.

---
 fs/proc/vmcore.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
fs/proc/vmcore.c +3 -1
index 8ab782d..bbc9dad 100644
@@ -526,9 +526,10 @@ static u64 __init get_vmcore_size(size_t elfsz, size_t elfnotesegsz,
  */
 static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr)
 {
-	int i, rc=0;
+	int i, j, rc = 0;
 	Elf64_Phdr *phdr_ptr;
 	Elf64_Nhdr *nhdr_ptr;
+	bool warn;
 
 	phdr_ptr = (Elf64_Phdr *)(ehdr_ptr + 1);
 	for (i = 0; i < ehdr_ptr->e_phnum; i++, phdr_ptr++) {
@@ -536,6 +537,7 @@ static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr)
 		u64 offset, max_sz, sz, real_sz = 0;
 		if (phdr_ptr->p_type != PT_NOTE)
 			continue;
+		warn = true;
 		max_sz = phdr_ptr->p_memsz;
 		offset = phdr_ptr->p_offset;
 		notes_section = kmalloc(max_sz, GFP_KERNEL);

fs/proc/vmcore.c static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr) · line 552

Quoted 5 lines
fs/proc/vmcore.c +1 -1
@@ -547,7 +549,7 @@ static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr)
 			return rc;
 		}
 		nhdr_ptr = notes_section;
-		while (nhdr_ptr->n_namesz != 0) {
+		for (j = 0; nhdr_ptr->n_namesz != 0; j++) {

Hi Pingfan,

I think we don't need to be this complex, how about simply check before while loop, if it is the cpu dummy note(initialize it with some magic), then handle it differently, e.g. set a "nowarn" flag to use afterwards and make sure it has zero p_memsz?

Also do the similar thing for update_note_header_size_elf32()?

Regards,
Xunlei

Quoted 18 lines
fs/proc/vmcore.c +11 -0
 			sz = sizeof(Elf64_Nhdr) +
 				(((u64)nhdr_ptr->n_namesz + 3) & ~3) +
 				(((u64)nhdr_ptr->n_descsz + 3) & ~3);
@@ -559,11 +561,22 @@ static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr)
 			real_sz += sz;
 			nhdr_ptr = (Elf64_Nhdr*)((char*)nhdr_ptr + sz);
 		}
+		if (real_sz != 0)
+			warn = false;
+		if (j == 1) {
+			nhdr_ptr = notes_section;
+			if ((nhdr_ptr->n_type == NT_DUMMY)
+			  && !strncmp(KEXEC_CORE_NOTE_NAME,
+				(char *)nhdr_ptr + sizeof(Elf64_Nhdr),
+				strlen(KEXEC_CORE_NOTE_NAME))) {
+				/* do not copy this dummy note */
+				real_sz = 0;
+			}

fs/proc/vmcore.c static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr) · line 582

Quoted 10 lines
fs/proc/vmcore.c +2 -2
+		}
 		kfree(notes_section);
 		phdr_ptr->p_memsz = real_sz;
-		if (real_sz == 0) {
+		if (warn)
 			pr_warn("Warning: Zero PT_NOTE entries found\n");
-		}
 	}
 
 	return 0;

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#3 lore raw

Re: [PATCH 2/2] [fs] proc/vmcore: check the dummy place holder for offline cpu to avoid warning

Quoted 43 lines · Xunlei Pang
Quoted 34 lines · Pingfan Liu

kexec-tools always allocates program headers for possible cpus. But when crashing, offline cpus have dummy headers. We do not copy these dummy notes into ELF file, also have no need of warning on them.

---
 fs/proc/vmcore.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
fs/proc/vmcore.c +3 -1
index 8ab782d..bbc9dad 100644
@@ -526,9 +526,10 @@ static u64 __init get_vmcore_size(size_t elfsz, size_t elfnotesegsz,
  */
 static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr)
 {
-     int i, rc=0;
+     int i, j, rc = 0;
      Elf64_Phdr *phdr_ptr;
      Elf64_Nhdr *nhdr_ptr;
+     bool warn;
 
      phdr_ptr = (Elf64_Phdr *)(ehdr_ptr + 1);
      for (i = 0; i < ehdr_ptr->e_phnum; i++, phdr_ptr++) {
@@ -536,6 +537,7 @@ static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr)
              u64 offset, max_sz, sz, real_sz = 0;
              if (phdr_ptr->p_type != PT_NOTE)
                      continue;
+             warn = true;
              max_sz = phdr_ptr->p_memsz;
              offset = phdr_ptr->p_offset;
              notes_section = kmalloc(max_sz, GFP_KERNEL);

fs/proc/vmcore.c static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr) · line 552

Quoted 5 lines
fs/proc/vmcore.c +1 -1
@@ -547,7 +549,7 @@ static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr)
                      return rc;
              }
              nhdr_ptr = notes_section;
-             while (nhdr_ptr->n_namesz != 0) {
+             for (j = 0; nhdr_ptr->n_namesz != 0; j++) {

Hi Pingfan,

Quoted 4 lines

I think we don't need to be this complex, how about simply check before while loop, if it is the cpu dummy note(initialize it with some magic), then handle it differently, e.g. set a "nowarn" flag to use afterwards and make sure it has zero p_memsz?

I had thought that how the percpu note section was filled. But you are right, we can suppose that for all archs, cpus just overwrite the note, not append the note.

Quoted 2 lines

Also do the similar thing for update_note_header_size_elf32()?

Yes, will fix it.

Thx,

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw
In reply to Pingfan Liu
Quoted 1 line · Pingfan Liu

kexec-tools always allocates program headers for each possible cpu. This

The code is in the file: kexec-tools/kexec/crashdump-elf.c
nr_cpus = sysconf(_SC_NPROCESSORS_CONF);

Quoted 56 lines

incurs zero PT_NOTE for offline cpu. We mark this case so that later, the capture kernel can distinguish it from the mistake of allocated program header.
The counterpart of the capture kernel comes in next patch.

---
This unnecessary warning buzz on all archs when there is offline cpu

 include/uapi/linux/elf.h | 1 +
 kernel/kexec_core.c      | 9 +++++++++
 2 files changed, 10 insertions(+)
include/uapi/linux/elf.h +1 -0
index b59ee07..9744f1e 100644
@@ -367,6 +367,7 @@ typedef struct elf64_shdr {
  * using the corresponding note types via the PTRACE_GETREGSET and
  * PTRACE_SETREGSET requests.
  */
+#define NT_DUMMY       0
 #define NT_PRSTATUS    1
 #define NT_PRFPREG     2
 #define NT_PRPSINFO    3
kernel/kexec_core.c +9 -1
index 5616755..aeac16e 100644
@@ -891,9 +891,12 @@ void __crash_kexec(struct pt_regs *regs)
        if (mutex_trylock(&kexec_mutex)) {
                if (kexec_crash_image) {
                        struct pt_regs fixed_regs;
+                       unsigned int cpu;
 
                        crash_setup_regs(&fixed_regs, regs);
                        crash_save_vmcoreinfo();
+                       for_each_cpu_not(cpu, cpu_online_mask)
+                               crash_save_cpu(NULL, cpu);
                        machine_crash_shutdown(&fixed_regs);
                        machine_kexec(kexec_crash_image);
                }
@@ -1040,6 +1043,12 @@ void crash_save_cpu(struct pt_regs *regs, int cpu)
        buf = (u32 *)per_cpu_ptr(crash_notes, cpu);
        if (!buf)
                return;
+       if (regs == NULL) {
+               buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_DUMMY,
+                               NULL, 0);
+               final_note(buf);
+               return;
+       }
        memset(&prstatus, 0, sizeof(prstatus));
        prstatus.pr_pid = current->pid;
        elf_core_copy_kernel_regs(&prstatus.pr_reg, regs);
--
Quoted 2 lines

2.7.4

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#5 lore raw
In reply to Pingfan Liu
Quoted 5 lines · Pingfan Liu

kexec-tools always allocates program headers for each possible cpu. This incurs zero PT_NOTE for offline cpu. We mark this case so that later, the capture kernel can distinguish it from the mistake of allocated program header.
The counterpart of the capture kernel comes in next patch.

When you execute dmesg on your testing machine and grep nr_cpu_ids, what's the value of nr_cpu_ids?

Quoted 54 lines

---
This unnecessary warning buzz on all archs when there is offline cpu

 include/uapi/linux/elf.h | 1 +
 kernel/kexec_core.c      | 9 +++++++++
 2 files changed, 10 insertions(+)
include/uapi/linux/elf.h +1 -0
index b59ee07..9744f1e 100644
@@ -367,6 +367,7 @@ typedef struct elf64_shdr {
  * using the corresponding note types via the PTRACE_GETREGSET and
  * PTRACE_SETREGSET requests.
  */
+#define NT_DUMMY	0
 #define NT_PRSTATUS	1
 #define NT_PRFPREG	2
 #define NT_PRPSINFO	3
kernel/kexec_core.c +9 -0
index 5616755..aeac16e 100644
@@ -891,9 +891,12 @@ void __crash_kexec(struct pt_regs *regs)
 	if (mutex_trylock(&kexec_mutex)) {
 		if (kexec_crash_image) {
 			struct pt_regs fixed_regs;
+			unsigned int cpu;
 
 			crash_setup_regs(&fixed_regs, regs);
 			crash_save_vmcoreinfo();
+			for_each_cpu_not(cpu, cpu_online_mask)
+				crash_save_cpu(NULL, cpu);
 			machine_crash_shutdown(&fixed_regs);
 			machine_kexec(kexec_crash_image);
 		}
@@ -1040,6 +1043,12 @@ void crash_save_cpu(struct pt_regs *regs, int cpu)
 	buf = (u32 *)per_cpu_ptr(crash_notes, cpu);
 	if (!buf)
 		return;
+	if (regs == NULL) {
+		buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_DUMMY,
+				NULL, 0);
+		final_note(buf);
+		return;
+	}
 	memset(&prstatus, 0, sizeof(prstatus));
 	prstatus.pr_pid = current->pid;
 	elf_core_copy_kernel_regs(&prstatus.pr_reg, regs);
Signature · 1 line
2.7.4

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw
Quoted 10 lines · Baoquan He
Quoted 5 lines · Pingfan Liu

kexec-tools always allocates program headers for each possible cpu. This incurs zero PT_NOTE for offline cpu. We mark this case so that later, the capture kernel can distinguish it from the mistake of allocated program header.
The counterpart of the capture kernel comes in next patch.

When you execute dmesg on your testing machine and grep nr_cpu_ids, what's the value of nr_cpu_ids?

nr_cpu_ids=128

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#7 lore raw
Quoted 8 lines · Liu ping fan
Quoted 7 lines · Baoquan He
Quoted 5 lines · Pingfan Liu

kexec-tools always allocates program headers for each possible cpu. This incurs zero PT_NOTE for offline cpu. We mark this case so that later, the capture kernel can distinguish it from the mistake of allocated program header.
The counterpart of the capture kernel comes in next patch.

Quoted 4 lines
Quoted 3 lines

When you execute dmesg on your testing machine and grep nr_cpu_ids, what's the value of nr_cpu_ids?

nr_cpu_ids=128

And what's the cpu number of in "lscpu" command?

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#8 lore raw
Quoted 9 lines · Baoquan He
Quoted 8 lines · Liu ping fan
Quoted 7 lines · Baoquan He
Quoted 5 lines · Pingfan Liu

kexec-tools always allocates program headers for each possible cpu. This incurs zero PT_NOTE for offline cpu. We mark this case so that later, the capture kernel can distinguish it from the mistake of allocated program header.
The counterpart of the capture kernel comes in next patch.

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

When you execute dmesg on your testing machine and grep nr_cpu_ids, what's the value of nr_cpu_ids?

nr_cpu_ids=128

And what's the cpu number of in "lscpu" command?

NUMA node1 CPU(s): 0-7

The system booted up with 128 possible cpu and only 8 online. Also I tested on x86 guest, after bootup with 8 cpus, then offline 4 of them, the zero PT_NOTE warning buzz too.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#9 lore raw
Quoted 15 lines · Liu ping fan
Quoted 14 lines · Baoquan He
Quoted 12 lines · Liu ping fan
Quoted 10 lines · Baoquan He
Quoted 5 lines · Pingfan Liu

kexec-tools always allocates program headers for each possible cpu. This incurs zero PT_NOTE for offline cpu. We mark this case so that later, the capture kernel can distinguish it from the mistake of allocated program header.
The counterpart of the capture kernel comes in next patch.

When you execute dmesg on your testing machine and grep nr_cpu_ids, what's the value of nr_cpu_ids?

nr_cpu_ids=128

Quoted 7 lines
Quoted 1 line

And what's the cpu number of in "lscpu" command?

NUMA node1 CPU(s): 0-7

The system booted up with 128 possible cpu and only 8 online. Also I tested on x86 guest, after bootup with 8 cpus, then offline 4 of them, the zero PT_NOTE warning buzz too.

Yes, this is what I think not quite appropriate using for_each_cpu_not(cpu, cpu_online_mask). Maybe it need try to save on those cpus which is present but not online. not online seems not good, it's not reasonable to save those getting apic but no cpu plugged.

Thanks
Baoquan

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#10 lore raw

[...]

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

When you execute dmesg on your testing machine and grep nr_cpu_ids, what's the value of nr_cpu_ids?

nr_cpu_ids=128

And what's the cpu number of in "lscpu" command?

NUMA node1 CPU(s): 0-7

Quoted 9 lines
Quoted 3 lines

The system booted up with 128 possible cpu and only 8 online. Also I tested on x86 guest, after bootup with 8 cpus, then offline 4 of them, the zero PT_NOTE warning buzz too.

Yes, this is what I think not quite appropriate using for_each_cpu_not(cpu, cpu_online_mask). Maybe it need try to save on those cpus which is present but not online. not online seems not good, it's not reasonable to save those getting apic but no cpu plugged.

In the file: kexec-tools/kexec/crashdump-elf.c
nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
And this is why this patch needs to make a mark on these offline cpu. This is no something like "_SC_NPROCESSORS_PRESENT" option, so just work around it in kernel side.
Anyway for crash kernel, we only write "core" in percpu notes without no more info, and it costs nothing when capture kernel gather the PT_NOTE.

Thx,
Pingfan

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#11 lore raw
In reply to Pingfan Liu
Quoted 5 lines · Pingfan Liu

kexec-tools always allocates program headers for each possible cpu. This incurs zero PT_NOTE for offline cpu. We mark this case so that later, the capture kernel can distinguish it from the mistake of allocated program header.
The counterpart of the capture kernel comes in next patch.

Hmm, we can initialize the cpu crash note buf in crash_notes_memory_init(), needless to do it at the crash moment, right?

BTW, does this cause any issue, for example the crash utility can't parse the vmcore properly? or just reproduce lots of warnings after offline multiple cpus?

Regards,
Xunlei

Quoted 41 lines

---
This unnecessary warning buzz on all archs when there is offline cpu

 include/uapi/linux/elf.h | 1 +
 kernel/kexec_core.c      | 9 +++++++++
 2 files changed, 10 insertions(+)
include/uapi/linux/elf.h +1 -0
index b59ee07..9744f1e 100644
@@ -367,6 +367,7 @@ typedef struct elf64_shdr {
  * using the corresponding note types via the PTRACE_GETREGSET and
  * PTRACE_SETREGSET requests.
  */
+#define NT_DUMMY	0
 #define NT_PRSTATUS	1
 #define NT_PRFPREG	2
 #define NT_PRPSINFO	3
kernel/kexec_core.c +3 -0
index 5616755..aeac16e 100644
@@ -891,9 +891,12 @@ void __crash_kexec(struct pt_regs *regs)
 	if (mutex_trylock(&kexec_mutex)) {
 		if (kexec_crash_image) {
 			struct pt_regs fixed_regs;
+			unsigned int cpu;
 
 			crash_setup_regs(&fixed_regs, regs);
 			crash_save_vmcoreinfo();
+			for_each_cpu_not(cpu, cpu_online_mask)
+				crash_save_cpu(NULL, cpu);
 			machine_crash_shutdown(&fixed_regs);
 			machine_kexec(kexec_crash_image);
 		}
@@ -1040,6 +1043,12 @@ void crash_save_cpu(struct pt_regs *regs, int cpu)
 	buf = (u32 *)per_cpu_ptr(crash_notes, cpu);
 	if (!buf)

kernel/kexec_core.c void crash_save_cpu(struct pt_regs *regs, int cpu) · line 1054

Quoted 10 lines
kernel/kexec_core.c +6 -0
 		return;
+	if (regs == NULL) {
+		buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_DUMMY,
+				NULL, 0);
+		final_note(buf);
+		return;
+	}
 	memset(&prstatus, 0, sizeof(prstatus));
 	prstatus.pr_pid = current->pid;
 	elf_core_copy_kernel_regs(&prstatus.pr_reg, regs);

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#12 lore raw
Quoted 10 lines · Xunlei Pang
Quoted 5 lines · Pingfan Liu

kexec-tools always allocates program headers for each possible cpu. This incurs zero PT_NOTE for offline cpu. We mark this case so that later, the capture kernel can distinguish it from the mistake of allocated program header.
The counterpart of the capture kernel comes in next patch.

Hmm, we can initialize the cpu crash note buf in crash_notes_memory_init(), needless to do it at the crash moment, right?

The cpus can be on-off-on.., We can not know the user's action.

Quoted 3 lines

BTW, does this cause any issue, for example the crash utility can't parse the vmcore properly? or just reproduce lots of warnings after offline multiple cpus?

No. This patch just place a mark on these offline cpu. The next patch for capture kernel will recognize this case, and ignore this kind of pt_note by the code:
real_sz = 0; // although the size of this kind of PT_NOTE is not zero, but it contains nothing useful, so just ignore it phdr_ptr->p_memsz = real_sz

Thx,
Pingfan

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#13 lore raw
Quoted 11 lines · Liu ping fan
Quoted 9 lines · Xunlei Pang
Quoted 5 lines · Pingfan Liu

kexec-tools always allocates program headers for each possible cpu. This incurs zero PT_NOTE for offline cpu. We mark this case so that later, the capture kernel can distinguish it from the mistake of allocated program header.
The counterpart of the capture kernel comes in next patch.

Hmm, we can initialize the cpu crash note buf in crash_notes_memory_init(), needless to do it at the crash moment, right?

The cpus can be on-off-on.., We can not know the user's action.

I meant we can add the fake note into the cpu note buf, then the crash happens, the online ones will be overwritten with the real note data, while others(!online) will still be the fake note.

Quoted 10 lines
Quoted 4 lines

BTW, does this cause any issue, for example the crash utility can't parse the vmcore properly? or just reproduce lots of warnings after offline multiple cpus?

No. This patch just place a mark on these offline cpu. The next patch for capture kernel will recognize this case, and ignore this kind of pt_note by the code:
real_sz = 0; // although the size of this kind of PT_NOTE is not zero, but it contains nothing useful, so just ignore it phdr_ptr->p_memsz = real_sz

If there is any other vmcore functional issue besides throwing "Warning: Zero PT_NOTE entries found"?

Regards,
Xunlei

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#14 lore raw

[...]

Quoted 10 lines
Quoted 7 lines
Quoted 1 line

No. This patch just place a mark on these offline cpu. The next patch for capture kernel will recognize this case, and ignore this kind of pt_note by the code:
real_sz = 0; // although the size of this kind of PT_NOTE is not zero, but it contains nothing useful, so just ignore it phdr_ptr->p_memsz = real_sz

If there is any other vmcore functional issue besides throwing "Warning: Zero PT_NOTE entries found"?

Not at present when I debugged.
I just think we can not suppose the behaviour of different archs, so just mark out the dummy pt_note. If some archs want to use these notes memory,
they will just overwrite the dummy.

Thx,
Pingfan

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#15 lore raw
Quoted 10 lines · Liu ping fan

[...]

Quoted 8 lines
Quoted 6 lines

No. This patch just place a mark on these offline cpu. The next patch for capture kernel will recognize this case, and ignore this kind of pt_note by the code:
real_sz = 0; // although the size of this kind of PT_NOTE is not zero, but it contains nothing useful, so just ignore it phdr_ptr->p_memsz = real_sz

If there is any other vmcore functional issue besides throwing "Warning: Zero PT_NOTE entries found"?

Not at present when I debugged.

Well, agree that we should fix it given that it produces many unnecessary warnings on some machines.

Quoted 4 lines

I just think we can not suppose the behaviour of different archs, so just mark out the dummy pt_note. If some archs want to use these notes memory,
they will just overwrite the dummy.

For cpu crash_notes, it should be arch-independent, and related to elf format.

Quoted 8 lines

Thx,
Pingfan

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#16 lore raw
In reply to Pingfan Liu

Hi, Pingfan

Quoted 5 lines · Pingfan Liu

kexec-tools always allocates program headers for each possible cpu. This incurs zero PT_NOTE for offline cpu. We mark this case so that later, the capture kernel can distinguish it from the mistake of allocated program header.
The counterpart of the capture kernel comes in next patch.

I thought you saw the warnings on ppc64 and it might be a ppc64 issue. But if this is instead a general issue, can we think about if this is really necessary?

Does it have any side effect other than the warning messages? If there is nothing bad other than the warnings maybe leave it as is will be a better way.

Quoted 54 lines

---
This unnecessary warning buzz on all archs when there is offline cpu

 include/uapi/linux/elf.h | 1 +
 kernel/kexec_core.c      | 9 +++++++++
 2 files changed, 10 insertions(+)
include/uapi/linux/elf.h +1 -0
index b59ee07..9744f1e 100644
@@ -367,6 +367,7 @@ typedef struct elf64_shdr {
  * using the corresponding note types via the PTRACE_GETREGSET and
  * PTRACE_SETREGSET requests.
  */
+#define NT_DUMMY	0
 #define NT_PRSTATUS	1
 #define NT_PRFPREG	2
 #define NT_PRPSINFO	3
kernel/kexec_core.c +9 -0
index 5616755..aeac16e 100644
@@ -891,9 +891,12 @@ void __crash_kexec(struct pt_regs *regs)
 	if (mutex_trylock(&kexec_mutex)) {
 		if (kexec_crash_image) {
 			struct pt_regs fixed_regs;
+			unsigned int cpu;
 
 			crash_setup_regs(&fixed_regs, regs);
 			crash_save_vmcoreinfo();
+			for_each_cpu_not(cpu, cpu_online_mask)
+				crash_save_cpu(NULL, cpu);
 			machine_crash_shutdown(&fixed_regs);
 			machine_kexec(kexec_crash_image);
 		}
@@ -1040,6 +1043,12 @@ void crash_save_cpu(struct pt_regs *regs, int cpu)
 	buf = (u32 *)per_cpu_ptr(crash_notes, cpu);
 	if (!buf)
 		return;
+	if (regs == NULL) {
+		buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_DUMMY,
+				NULL, 0);
+		final_note(buf);
+		return;
+	}
 	memset(&prstatus, 0, sizeof(prstatus));
 	prstatus.pr_pid = current->pid;
 	elf_core_copy_kernel_regs(&prstatus.pr_reg, regs);
Signature · 1 line
2.7.4

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#17 lore raw
Quoted 9 lines · Dave Young

Hi, Pingfan

Quoted 5 lines · Pingfan Liu

kexec-tools always allocates program headers for each possible cpu. This incurs zero PT_NOTE for offline cpu. We mark this case so that later, the capture kernel can distinguish it from the mistake of allocated program header.
The counterpart of the capture kernel comes in next patch.

I thought you saw the warnings on ppc64 and it might be a ppc64 issue.

It affects all archs, since kexec-tools creates each program header for each _present_ cpu. So if the cpu is offline, then the warning buzzes.

Quoted 7 lines

But if this is instead a general issue, can we think about if this is really necessary?

Does it have any side effect other than the warning messages? If there is nothing bad other than the warnings maybe leave it as is will be a better way.

I think kernel warning always made people upset who do not know the back ground of the related field.
While on the other hand, the program behaves correctly against our expectation, so just suppress the warning to make everyone easy.

Regards,
Pingfan

Quoted 49 lines
Quoted 49 lines

---
This unnecessary warning buzz on all archs when there is offline cpu

 include/uapi/linux/elf.h | 1 +
 kernel/kexec_core.c      | 9 +++++++++
 2 files changed, 10 insertions(+)
include/uapi/linux/elf.h +1 -0
index b59ee07..9744f1e 100644
@@ -367,6 +367,7 @@ typedef struct elf64_shdr {
  * using the corresponding note types via the PTRACE_GETREGSET and
  * PTRACE_SETREGSET requests.
  */
+#define NT_DUMMY     0
 #define NT_PRSTATUS  1
 #define NT_PRFPREG   2
 #define NT_PRPSINFO  3
kernel/kexec_core.c +9 -0
index 5616755..aeac16e 100644
@@ -891,9 +891,12 @@ void __crash_kexec(struct pt_regs *regs)
      if (mutex_trylock(&kexec_mutex)) {
              if (kexec_crash_image) {
                      struct pt_regs fixed_regs;
+                     unsigned int cpu;
 
                      crash_setup_regs(&fixed_regs, regs);
                      crash_save_vmcoreinfo();
+                     for_each_cpu_not(cpu, cpu_online_mask)
+                             crash_save_cpu(NULL, cpu);
                      machine_crash_shutdown(&fixed_regs);
                      machine_kexec(kexec_crash_image);
              }
@@ -1040,6 +1043,12 @@ void crash_save_cpu(struct pt_regs *regs, int cpu)
      buf = (u32 *)per_cpu_ptr(crash_notes, cpu);
      if (!buf)
              return;
+     if (regs == NULL) {
+             buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_DUMMY,
+                             NULL, 0);
+             final_note(buf);
+             return;
+     }
      memset(&prstatus, 0, sizeof(prstatus));
Quoted 8 lines
Quoted 5 lines
kernel/kexec_core.c +0 -1
      prstatus.pr_pid = current->pid;
      elf_core_copy_kernel_regs(&prstatus.pr_reg, regs);
--

2.7.4

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec