linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: "qiwu.chen" <qiwuchen55@gmail.com>
Cc: corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org,
	paulmck@kernel.org, akpm@linux-foundation.org,
	linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
	"qiwu.chen" <qiwu.chen@transsion.com>
Subject: Re: [PATCH v4 1/2] panic: add option to dump task maps info in panic_print
Date: Tue, 24 Sep 2024 13:33:54 +0200	[thread overview]
Message-ID: <20240924113322.GA7248@redhat.com> (raw)
In-Reply-To: <20240924074341.37272-1-qiwu.chen@transsion.com>

On 09/24, qiwu.chen wrote:
>
> +EXPORT_SYMBOL(get_vma_name);

Why?

> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -3566,6 +3566,10 @@ static inline bool range_in_vma(struct vm_area_struct *vma,
>  #ifdef CONFIG_MMU
>  pgprot_t vm_get_page_prot(unsigned long vm_flags);
>  void vma_set_page_prot(struct vm_area_struct *vma);
> +void get_vma_name(struct vm_area_struct *vma,
> +			 const struct path **path,
> +			 const char **name,
> +			 const char **name_fmt);
>  #else

You didn't move get_vma_name() from fs/proc/task_mmu.c, so it also depends
on CONFIG_PROC_FS.

> +/*
> + * This function is called in panic proccess if the PANIC_PRINT_TASK_MAPS_INFO
> + * flag is specified in panic_print, which is helpful to debug panic issues due
> + * to an unhandled falut in user mode such as kill init.
> + */
> +static void dump_task_maps_info(struct task_struct *tsk)
> +{
> +	struct pt_regs *user_ret = task_pt_regs(tsk);
> +	struct mm_struct *mm = tsk->mm;
> +	struct vm_area_struct *vma;
> +
> +	if (!mm || !user_mode(user_ret))
> +		return;
> +
> +	pr_info("Dump task %s:%d maps start\n", tsk->comm, task_pid_nr(tsk));
> +	mmap_read_lock(mm);
> +	VMA_ITERATOR(vmi, mm, 0);
> +	for_each_vma(vmi, vma) {
> +		int flags = vma->vm_flags;
> +		unsigned long long pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
> +		const struct path *path;
> +		const char *name_fmt, *name;
> +		char name_buf[SZ_256];
> +
> +		get_vma_name(vma, &path, &name, &name_fmt);

So this code won't compile if CONFIG_MMU=n ?

> +		if (path) {
> +			name = d_path(path, name_buf, sizeof(name_buf));
> +			name = IS_ERR(name) ? "?" : name;

perhaps this needs mangle_path() ...

> +		} else if (name || name_fmt) {
> +			snprintf(name_buf, sizeof(name_buf), name_fmt ?: "%s", name);
> +			name = name_buf;
> +		}

Why not

		} else if (name_fmt) {
			snprintf(name_buf, sizeof(name_buf), name_fmt, name);
			name = name_buf;
		}
?

> +		if (name)
> +			pr_info("%08lx-%08lx %c%c%c%c %08llx %s\n",
> +				vma->vm_start, vma->vm_end,
> +				flags & VM_READ ? 'r' : '-',
> +				flags & VM_WRITE ? 'w' : '-',
> +				flags & VM_EXEC ? 'x' : '-',
> +				flags & VM_MAYSHARE ? 's' : 'p',
> +				pgoff, name);

I don't really understand why you skip vma if !name...

Oleg.



  parent reply	other threads:[~2024-09-24 11:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24  7:43 qiwu.chen
2024-09-24  7:43 ` [PATCH v4 2/2] arm64: show signal info for global init qiwu.chen
2024-09-24 18:36   ` Oleg Nesterov
2024-09-25  3:54     ` chenqiwu
2024-09-25 12:05       ` Oleg Nesterov
2024-09-26 10:12         ` chenqiwu
2024-09-24 11:33 ` Oleg Nesterov [this message]
2024-09-25  8:27   ` [PATCH v4 1/2] panic: add option to dump task maps info in panic_print chenqiwu
2024-09-25 12:19     ` Oleg Nesterov
2024-09-26  3:30       ` chenqiwu
2024-09-24 15:06 ` kernel test robot
2024-09-24 15:06 ` kernel test robot
2024-10-01 11:23 ` Lorenzo Stoakes

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=20240924113322.GA7248@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=paulmck@kernel.org \
    --cc=qiwu.chen@transsion.com \
    --cc=qiwuchen55@gmail.com \
    --cc=will@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