public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
  • * Re: [PATCH v3 1/2] panic: add option to dump task maps info in panic_print
           [not found] <20240922095504.7182-1-qiwu.chen@transsion.com>
           [not found] ` <20240922095504.7182-2-qiwu.chen@transsion.com>
    @ 2024-09-22 13:13 ` Oleg Nesterov
      1 sibling, 0 replies; 3+ messages in thread
    From: Oleg Nesterov @ 2024-09-22 13:13 UTC (permalink / raw)
      To: qiwu.chen
      Cc: corbet, mhocko, jani.nikula, akpm, brauner, paulmck, linux-doc,
    	qiwu.chen, linux-kernel
    
    On 09/22, qiwu.chen wrote:
    >
    > +	for_each_vma(vmi, vma) {
    > +		struct file *file = vma->vm_file;
    > +		int flags = vma->vm_flags;
    > +		unsigned long long pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
    > +		struct anon_vma_name *anon_name = NULL;
    > +		struct mm_struct *mm = vma->vm_mm;
    > +		char buf[256] = {0};
    > +		const char *name = NULL;
    > +
    > +		if (mm)
    > +			anon_name = anon_vma_name(vma);
    > +
    > +		if (file) {
    > +			if (anon_name) {
    > +				snprintf(buf, sizeof(buf), "[anon_shmem:%s]", anon_name->name);
    > +				name = buf;
    > +			} else {
    > +				char *f_path = d_path(file_user_path(file), buf, sizeof(buf));
    > +
    > +				name = IS_ERR(f_path) ? "?" : f_path;
    > +			}
    > +			goto print;
    > +		}
    > +
    > +		if (vma->vm_ops && vma->vm_ops->name) {
    > +			name = vma->vm_ops->name(vma);
    > +			if (name)
    > +				goto print;
    > +		}
    > +
    > +		name = arch_vma_name(vma);
    > +		if (!name) {
    > +			if (mm) {
    > +				if (vma_is_initial_heap(vma))
    > +					name = "[heap]";
    > +				else if (vma_is_initial_stack(vma))
    > +					name = "[stack]";
    > +			} else
    > +				name = "[vdso]";
    > +
    > +			if (anon_name) {
    > +				snprintf(buf, sizeof(buf), "[anon:%s]", anon_name->name);
    > +				name = buf;
    > +			}
    > +		}
    > +
    
    Wouldn't it be better to export/reuse get_vma_name() rather than duplicate
    its code ?
    
    Oleg.
    
    
    ^ permalink raw reply	[flat|nested] 3+ messages in thread

  • end of thread, other threads:[~2024-09-23  5:12 UTC | newest]
    
    Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
    -- links below jump to the message on this page --
         [not found] <20240922095504.7182-1-qiwu.chen@transsion.com>
         [not found] ` <20240922095504.7182-2-qiwu.chen@transsion.com>
    2024-09-22 12:54   ` [PATCH v3 2/2] exit: dump current pt_regs info on global init exit Oleg Nesterov
    2024-09-23  5:11     ` chenqiwu
    2024-09-22 13:13 ` [PATCH v3 1/2] panic: add option to dump task maps info in panic_print Oleg Nesterov
    

    This is a public inbox, see mirroring instructions
    for how to clone and mirror all data and code used for this inbox