Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp207026imj; Thu, 14 Feb 2019 18:41:49 -0800 (PST) X-Google-Smtp-Source: AHgI3IZYcEg06MWgsyTf/2VxK4+OU03Tp30kFCVbrCZEHt+miR/yetACD1pdSng7giptPvUz/Yhl X-Received: by 2002:a62:2ad6:: with SMTP id q205mr7384349pfq.243.1550198509165; Thu, 14 Feb 2019 18:41:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198509; cv=none; d=google.com; s=arc-20160816; b=DHhXcIoItYIXMNSCjv4HYhlWFRs7Gh1uqMMcvG/Fdeo1rcj8l29ZCoKJ4RiG4FLYr9 bQN8yXL+hx53O2Y2Y5NlYGfn+EajYcH2v4lJREDYiJD6rlTXrZqM5BMGun828/0MedYr T2anAhwA6hcpmBFh+I8paptWRNa53ltzdRHEvKKH6R+y/YWTDV+hCuHuBP8AjZl9DgcO SeJUl6a+XGSyogDRdAcO/00dXauzTaZ30b0NDR8X8wUlPllgKdRX4tDrWU5sX+zbClWL w2aTMgu3xKIYVoBxN4Q6F6Gh614lVEE9lbBk1iB2kS9Dt8y+S+O5jeeQZSg5tunHD6eI emYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qvtrbZH+FLgQanrdV8h3xzXpDMs+l+na+ulDO9vMOLg=; b=dKzwQ4BlNSdM6lqqhe2CHhJbDtR/QizzhO2LcXuCEsI4XcFcGQ3+TR8yEIVfPfXECR xiakZZyVxRcZf2F+aIePXRl6m9En/XHSmYQepUsaGIn+shqqtwMePR0WmxNfc/Hf2b3N rUpftY2234fPtH1wHig9o2iv4l9CNrpQJpQGEiwucX5k3vWmK6yCTuXf6NBRpO7E5Lsr eot3l+I3sR1vph8rJ7pSYjw9eq/vABJLgE4NrJ/AF7oKIfgsRlokeoDiBj/nanUsHugA 16eWGS70CNfx8NAqGYuNxLhUYkhqy/C+o0s1y02zTJyYVu0foqZhhbi3b5TVKLkZt+UA NWnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qUGkQ0n9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si1915956plk.238.2019.02.14.18.41.33; Thu, 14 Feb 2019 18:41:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qUGkQ0n9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389811AbfBOCKB (ORCPT + 99 others); Thu, 14 Feb 2019 21:10:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:50004 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388861AbfBOCJx (ORCPT ); Thu, 14 Feb 2019 21:09:53 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8EE7921B68; Fri, 15 Feb 2019 02:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196592; bh=AlT1FIsaHGqXQQZrjEMpCuAnOm73kd5vjfGJQDSHJyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qUGkQ0n9WLvX76o1EGVz58w0q/zzdwth7RirL/TBB+ywLwooUnmwkWqqRV+SmKTUd RUm13hA9QAJwNOu1MAxaVKlVopy0aZ0IBgC/MPdOQnw1yCXqZ6PYKfuU44zKdjRtRF wjDHO3ZcEAUviph+7y91Z1MGYc3mthMa07lx6KSw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vineet Gupta , Sasha Levin , linux-snps-arc@lists.infradead.org Subject: [PATCH AUTOSEL 4.20 33/77] ARC: show_regs: lockdep: avoid page allocator... Date: Thu, 14 Feb 2019 21:08:11 -0500 Message-Id: <20190215020855.176727-33-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215020855.176727-1-sashal@kernel.org> References: <20190215020855.176727-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vineet Gupta [ Upstream commit ab6c03676cb190156603cf4c5ecf97aa406c9c53 ] and use smaller/on-stack buffer instead The motivation for this change was lockdep splat like below. | potentially unexpected fatal signal 11. | BUG: sleeping function called from invalid context at ../mm/page_alloc.c:4317 | in_atomic(): 1, irqs_disabled(): 0, pid: 57, name: segv | no locks held by segv/57. | Preemption disabled at: | [<8182f17e>] get_signal+0x4a6/0x7c4 | CPU: 0 PID: 57 Comm: segv Not tainted 4.17.0+ #23 | | Stack Trace: | arc_unwind_core.constprop.1+0xd0/0xf4 | __might_sleep+0x1f6/0x234 | __get_free_pages+0x174/0xca0 | show_regs+0x22/0x330 | get_signal+0x4ac/0x7c4 # print_fatal_signals() -> preempt_disable() | do_signal+0x30/0x224 | resume_user_mode_begin+0x90/0xd8 So signal handling core calls show_regs() with preemption disabled but an ensuing GFP_KERNEL page allocator call is flagged by lockdep. We could have switched to GFP_NOWAIT, but turns out that is not enough anways and eliding page allocator call leads to less code and instruction traces to sift thru when debugging pesky crashes. FWIW, this patch doesn't cure the lockdep splat (which next patch does). Reviewed-by: William Kucharski Signed-off-by: Vineet Gupta Signed-off-by: Sasha Levin --- arch/arc/kernel/troubleshoot.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c index e8d9fb452346..5c6663321e87 100644 --- a/arch/arc/kernel/troubleshoot.c +++ b/arch/arc/kernel/troubleshoot.c @@ -18,6 +18,8 @@ #include #include +#define ARC_PATH_MAX 256 + /* * Common routine to print scratch regs (r0-r12) or callee regs (r13-r25) * -Prints 3 regs per line and a CR. @@ -58,11 +60,12 @@ static void show_callee_regs(struct callee_regs *cregs) print_reg_file(&(cregs->r13), 13); } -static void print_task_path_n_nm(struct task_struct *tsk, char *buf) +static void print_task_path_n_nm(struct task_struct *tsk) { char *path_nm = NULL; struct mm_struct *mm; struct file *exe_file; + char buf[ARC_PATH_MAX]; mm = get_task_mm(tsk); if (!mm) @@ -72,7 +75,7 @@ static void print_task_path_n_nm(struct task_struct *tsk, char *buf) mmput(mm); if (exe_file) { - path_nm = file_path(exe_file, buf, 255); + path_nm = file_path(exe_file, buf, ARC_PATH_MAX-1); fput(exe_file); } @@ -80,10 +83,9 @@ static void print_task_path_n_nm(struct task_struct *tsk, char *buf) pr_info("Path: %s\n", !IS_ERR(path_nm) ? path_nm : "?"); } -static void show_faulting_vma(unsigned long address, char *buf) +static void show_faulting_vma(unsigned long address) { struct vm_area_struct *vma; - char *nm = buf; struct mm_struct *active_mm = current->active_mm; /* can't use print_vma_addr() yet as it doesn't check for @@ -96,8 +98,11 @@ static void show_faulting_vma(unsigned long address, char *buf) * if the container VMA is not found */ if (vma && (vma->vm_start <= address)) { + char buf[ARC_PATH_MAX]; + char *nm = "?"; + if (vma->vm_file) { - nm = file_path(vma->vm_file, buf, PAGE_SIZE - 1); + nm = file_path(vma->vm_file, buf, ARC_PATH_MAX-1); if (IS_ERR(nm)) nm = "?"; } @@ -173,13 +178,8 @@ void show_regs(struct pt_regs *regs) { struct task_struct *tsk = current; struct callee_regs *cregs; - char *buf; - buf = (char *)__get_free_page(GFP_KERNEL); - if (!buf) - return; - - print_task_path_n_nm(tsk, buf); + print_task_path_n_nm(tsk); show_regs_print_info(KERN_INFO); show_ecr_verbose(regs); @@ -189,7 +189,7 @@ void show_regs(struct pt_regs *regs) (void *)regs->blink, (void *)regs->ret); if (user_mode(regs)) - show_faulting_vma(regs->ret, buf); /* faulting code, not data */ + show_faulting_vma(regs->ret); /* faulting code, not data */ pr_info("[STAT32]: 0x%08lx", regs->status32); @@ -221,8 +221,6 @@ void show_regs(struct pt_regs *regs) cregs = (struct callee_regs *)current->thread.callee_reg; if (cregs) show_callee_regs(cregs); - - free_page((unsigned long)buf); } void show_kernel_fault_diag(const char *str, struct pt_regs *regs, -- 2.19.1