Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4263961imu; Tue, 18 Dec 2018 11:45:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/WXHqHqUOiHSMHcgkgl9t3GiTFJSwINrR0SmG9JfC9zREJ3YfQVnz7g8mr1dSCBiC+eJAou X-Received: by 2002:a65:4946:: with SMTP id q6mr16450721pgs.201.1545162343521; Tue, 18 Dec 2018 11:45:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545162343; cv=none; d=google.com; s=arc-20160816; b=kXsDdnq/8l0JFdaKq/35RnhWvSFFmqWSJyZ8nno+fA6e8QHv8zZkYAUuBjG7Ca+98S FI3oS8eIBnt8rFjZhwhkLEphdQQ816Yad3Wto6YIW15bYtsDJ5nrrsqreb6KeJdArdW7 s0jkz62CtQA8vz6CfRlhbI+DOofYYWjylqoqOp2+JQvRCAn4mXCkl17SCI0xodVhlRxP yEHmV8QW9kqd4rIj4OLH9E3m5QyhrjLAzJOn+8o53evu4abvIS+S60XcVv0bjMREZXcG GNNYBGfSNh1JExo8sKajc9pL5XWuohsrjvfbQjtwWe5Szqo+ZFiRCsC+PbgtFIAu+Vgu xgFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Gx0bhRcL1WgzGx4uAcAoVMGOjdr6FfRTNvKocFLifVU=; b=g+Bhf+sqGaY8hwwBFMoux60ZZLJGWYwnjLNyrliii3QjIJopik8T868beDU/dSNZy2 HrdOUy7Cw1jqSUH99LkNQKAXvlrt96F3RWltu2/BvE2ItMFVE6lMfQM/UOIi8h7s3YMj P3uOSviDCfQinkWA1hN8K29YwfLKsRULwyCvb0FMKih9CFa+UMcYBBrwqx993GGK6JKS ylVgF0BXcUdIhiJj2VCOO6WcjMvoPXzMEbPhlUGfikmAbK/ik4mMICYQVAO7rEZxkmfn 1y19Tk0DGS21kWur87dEfIrPOvnqSIEorEyeYQr5LHFPnPxYYmvXo1tK1m/0Ht4TPPJ2 v5+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=ThMzo9sz; 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=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9si14449141plb.180.2018.12.18.11.45.27; Tue, 18 Dec 2018 11:45:43 -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=@synopsys.com header.s=mail header.b=ThMzo9sz; 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=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726962AbeLRSyQ (ORCPT + 99 others); Tue, 18 Dec 2018 13:54:16 -0500 Received: from us01smtprelay-2.synopsys.com ([198.182.60.111]:55830 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbeLRSyN (ORCPT ); Tue, 18 Dec 2018 13:54:13 -0500 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id CE13710C0BCA; Tue, 18 Dec 2018 10:54:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1545159252; bh=Dmmf92XTwIVxBegyy3MkhN2/6mGU00jYdmv+BDLE/IE=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=ThMzo9szwxcID/+P7MyBY/Cp9ofIE1KLDillTJ6gm35dEj7gaNI20io/OOShc3jMq HFi8LPMi7C514pAxxkClHW9kfDDQTW0QrqEP8U1Xx3mp7qWTple8eGMBLoSdZSLZ7f U1c6CuGUnOgI0Ydhcpo9IGy8U5CbvmOiAK5L8GV+yk/20cUKoQEocfmgcUZP+I0jeu 6NoTRUA/JMqutWgZJ/rGKP/BHXRKHKYhyQEvc1LSyz+hqpPAIycMy2vTxlAejo1aEz rDgohiU8PLyIueCutbIETbIKBpJd+cK8dMdx9mBUZxqoYeOrz6HEoOktmSKsdrSVPs P0ttPOcpmUTbw== Received: from US01WXQAHTC1.internal.synopsys.com (us01wxqahtc1.internal.synopsys.com [10.12.238.230]) by mailhost.synopsys.com (Postfix) with ESMTP id AE4A0399B; Tue, 18 Dec 2018 10:54:12 -0800 (PST) Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.104) by US01WXQAHTC1.internal.synopsys.com (10.12.238.230) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 18 Dec 2018 10:54:12 -0800 Received: from IN01WEHTCB.internal.synopsys.com (10.144.199.105) by IN01WEHTCA.internal.synopsys.com (10.144.199.103) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 19 Dec 2018 00:24:11 +0530 Received: from vineetg-Latitude-E7450.internal.synopsys.com (10.10.161.70) by IN01WEHTCB.internal.synopsys.com (10.144.199.243) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 19 Dec 2018 00:24:11 +0530 From: Vineet Gupta To: CC: , , , Peter Zijlstra , "Vineet Gupta" Subject: [PATCH 1/2] ARC: show_regs: avoid page allocator Date: Tue, 18 Dec 2018 10:53:58 -0800 Message-ID: <1545159239-30628-2-git-send-email-vgupta@synopsys.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545159239-30628-1-git-send-email-vgupta@synopsys.com> References: <1545159239-30628-1-git-send-email-vgupta@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.10.161.70] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use on-stack smaller buffers instead of dynamic pages. The motivation for this change was to address lockdep splat when signal handling code calls show_regs (with preemption disabled) and ARC show_regs calls into sleepable page allocator. | 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 Despite this, lockdep still barfs (see next change), but this patch still has merit as in we use smaller/localized buffers now and there's less instructoh trace to sift thru when debugging pesky issues. Signed-off-by: Vineet Gupta --- arch/arc/kernel/troubleshoot.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c index e8d9fb452346..2885bec71fb8 100644 --- a/arch/arc/kernel/troubleshoot.c +++ b/arch/arc/kernel/troubleshoot.c @@ -58,11 +58,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[256]; mm = get_task_mm(tsk); if (!mm) @@ -80,10 +81,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 +96,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[256]; + char *nm = "?"; + if (vma->vm_file) { - nm = file_path(vma->vm_file, buf, PAGE_SIZE - 1); + nm = file_path(vma->vm_file, buf, 256-1); if (IS_ERR(nm)) nm = "?"; } @@ -173,13 +176,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 +187,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 +219,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.7.4