public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Hui Zhu <teawater@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	WANG Cong <xiyou.wangcong@gmail.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Simon Kagstrom <simon.kagstrom@netinsight.net>,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kexec: set prstatus.pr_pid to cpu id when current->pid is 0
Date: Tue, 03 Aug 2010 00:37:46 -0700	[thread overview]
Message-ID: <m1zkx4w3hx.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <AANLkTikuUi=i6Lk-ZpE65Gr0tWOeVnrnpWPe85T=J=Ph@mail.gmail.com> (Hui Zhu's message of "Tue\, 3 Aug 2010 15\:21\:49 +0800")

Hui Zhu <teawater@gmail.com> writes:

> Hi,
>
> I found that from gdb 7.1 to gdb-cvs-head cannot analyze the core file
> that get from kdump.
> What I got:
> [New <main task>]
> [New Thread 2719]
> ../../src/gdb/thread.c:884: internal-error: switch_to_thread:
> Assertion `inf != NULL' failed.
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
> Quit this debugging session? (y or n)
> That is because:
>  objdump -h ./vmcore
>
> ./vmcore:     file format elf64-x86-64
>
> Sections:
> Idx Name          Size      VMA               LMA               File off  Algn
>   0 note0         00000a48  0000000000000000  0000000000000000  00000238  2**0
>                   CONTENTS, READONLY
>   1 .reg/0        000000d8  0000000000000000  0000000000000000  000002bc  2**2
>                   CONTENTS
>   2 .reg          000000d8  0000000000000000  0000000000000000  000002bc  2**2
>                   CONTENTS
>   3 .reg/2719     000000d8  0000000000000000  0000000000000000  00000420  2**2
>                   CONTENTS
>   4 .reg/0        000000d8  0000000000000000  0000000000000000  00000584  2**2
>                   CONTENTS
>   5 .reg/0        000000d8  0000000000000000  0000000000000000  000006e8  2**2
>                   CONTENTS
> Each of reg/n is a cpu core note.  It will be a GDB thread.  n is the
> prstatus.pr_pid that will be the thread lwpid.  Because the 3 threads
> pid is same, so GDB get error.
>
> current->pid is 0 because this cpu is in idle.  So I add a check, set
> prstatus.pr_pid to cpu id when current->pid is 0.  Then GDB work OK
> with the core.

That is a gdb limitation.  It looks to me like applying this patch will
loose information, and give you no guarantee that prstatus.pr_pid will
not equal 0.

If you want to change something please do it in a post processing tool.

Eric


> Thanks,
> Hui
>
> Signed-off-by: Hui Zhu <teawater@gmail.com>
> ---
>  kernel/kexec.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> --- a/kernel/kexec.c
> +++ b/kernel/kexec.c
> @@ -1191,7 +1191,10 @@ void crash_save_cpu(struct pt_regs *regs
>  	if (!buf)
>  		return;
>  	memset(&prstatus, 0, sizeof(prstatus));
> -	prstatus.pr_pid = current->pid;
> +	if (current->pid)
> +		prstatus.pr_pid = current->pid;
> +	else
> +		prstatus.pr_pid = cpu;
>  	elf_core_copy_kernel_regs(&prstatus.pr_reg, regs);
>  	buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS,
>  		      	      &prstatus, sizeof(prstatus));

  reply	other threads:[~2010-08-03  7:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-03  7:21 [PATCH] kexec: set prstatus.pr_pid to cpu id when current->pid is 0 Hui Zhu
2010-08-03  7:37 ` Eric W. Biederman [this message]
2010-08-03  7:44   ` Hui Zhu
2010-08-03  8:15     ` Eric W. Biederman
2010-08-03  8:36       ` Simon Horman

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=m1zkx4w3hx.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=akpm@linux-foundation.org \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=simon.kagstrom@netinsight.net \
    --cc=teawater@gmail.com \
    --cc=xiyou.wangcong@gmail.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