From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 28E2BCF9C6F for ; Tue, 24 Sep 2024 11:37:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:In-Reply-To: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sImyZnPJpUxN/Hd5pPYi0QXsCRCw+DH8j9BcHpDjkww=; b=EN8GJqhEiBn95wnpMYoQOgMSCf B4azF9nZtSauZwwcaUvBBOBEY3emjIW204AmR6uEfypqyUvO44tQLHH2Kv+CUKUZQBcgoxMkYiw2R HerINAzUSbzP9LYmBejkcnQ8LgyRlvYVZb5KQpGPF/mO35bEDJAPZwDm6uSyI0VfFCmtD5D8r8vO3 pefa+KEjkDgT+uvTMk/TUr/x3wc/6ISzLh7kmTTRBHu7hBfF7PTjp1Rz+dLPxT2MY8uLpy8d+jNmy 1wIvIC1wg2kB19l9ETbGfyNwHjESD1OW9EwlT/BhYmZ7WnylXIEnPfPgu5KyPNxrvSzPg5h7xQW9f d+295NHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1st3qn-00000002BVf-0Fll; Tue, 24 Sep 2024 11:37:01 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1st3oA-00000002AoN-3SfB for linux-arm-kernel@lists.infradead.org; Tue, 24 Sep 2024 11:34:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727177656; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sImyZnPJpUxN/Hd5pPYi0QXsCRCw+DH8j9BcHpDjkww=; b=d6ImtCmJTtKYsjy/OCVw8aZRg90Q9cZobOPIXSppZuFoGRiAUKNZifdWUcKBgLAQy57Qp8 wxILjjlG0U1d/zUg/2tOJ7BNM/xrnCxJoh9p0Z5IZTyOHMdAHNwhcaq2ujw/0L2RNNKyiM BUmHm2Im66YOLLgdFri2ypFcBP5sP4Q= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-504-zQLxxr_HMwSthCQWFjHHHw-1; Tue, 24 Sep 2024 07:34:12 -0400 X-MC-Unique: zQLxxr_HMwSthCQWFjHHHw-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4D88618EB2CC; Tue, 24 Sep 2024 11:34:11 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.226.71]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id AF405195608A; Tue, 24 Sep 2024 11:34:07 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 24 Sep 2024 13:33:58 +0200 (CEST) Date: Tue, 24 Sep 2024 13:33:54 +0200 From: Oleg Nesterov To: "qiwu.chen" 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" Subject: Re: [PATCH v4 1/2] panic: add option to dump task maps info in panic_print Message-ID: <20240924113322.GA7248@redhat.com> References: <20240924074341.37272-1-qiwu.chen@transsion.com> MIME-Version: 1.0 In-Reply-To: <20240924074341.37272-1-qiwu.chen@transsion.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240924_043419_007359_479CDD2C X-CRM114-Status: GOOD ( 18.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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.