From patchwork Tue Dec 18 18:53:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 1015564 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hld5+sEy"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="ThMzo9sz"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43K6dK4KLrz9s8r for ; Wed, 19 Dec 2018 05:54:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TQpymMoBZ4ZVE1+uvcc962poKSnK8HY0FGYPQIQJbig=; b=hld5+sEyKHbqFg VKBVBadKscZRaToZXF/LP6S5qnNx3M/j0+Yw8bXymSyyiEhDNdHQmiVQ9ECU+H7ThlnCAwQKPLXJE fYn4fo8PXDHlPk1b7NCdJYHXPvOMTdRK8QgutH4fSKWIXfgCPT9odNRg0xs6jUDzjKZUiC/SOYf6J ACjG54nxLYdLQJDG4azFmxdkSjO0yBewk2eerZbb6TVairwFVLXXAD8WzEdWuDiBKcLQReesPYHle 9nl61TPRoqbFWks3IuXA8o9TbIyJtqUVP5b9jQZ3ZueSD4w2V/r5+p0nFtSjYAXt3kRXluwb67agW 3VaiMlcF1HYRwqopobJA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZKVf-0000sd-Cx; Tue, 18 Dec 2018 18:54:27 +0000 Received: from us01smtprelay-2.synopsys.com ([198.182.60.111] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZKVb-0000pO-Ry for linux-snps-arc@lists.infradead.org; Tue, 18 Dec 2018 18:54:25 +0000 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: 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 X-Originating-IP: [10.10.161.70] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181218_105423_910759_D9DFBEE2 X-CRM114-Status: GOOD ( 13.74 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.60.111 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, Peter Zijlstra , Vineet Gupta , linux-kernel@vger.kernel.org Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.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 Reviewed-by: William Kucharski --- 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,