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: 10736215 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8185813AD for ; Tue, 18 Dec 2018 18:54:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 727F229595 for ; Tue, 18 Dec 2018 18:54:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 669832962C; Tue, 18 Dec 2018 18:54:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D901829595 for ; Tue, 18 Dec 2018 18:54:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 645F78E0007; Tue, 18 Dec 2018 13:54:15 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5CF3B8E0001; Tue, 18 Dec 2018 13:54:15 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 497F08E0007; Tue, 18 Dec 2018 13:54:15 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id F17978E0001 for ; Tue, 18 Dec 2018 13:54:14 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id b17so15941726pfc.11 for ; Tue, 18 Dec 2018 10:54:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version; bh=Gx0bhRcL1WgzGx4uAcAoVMGOjdr6FfRTNvKocFLifVU=; b=AlEwasbyoZC3psrgNr1E4VIGUZHszev82LS/6SObLWPwojU/BIrkOzMbFWNfyJKNmq rtLTGts5oDNU+rmExWvgxJxGZW/RaAGyCJsfNSXJCrh+OjnvX9etZ+BVRt+00+mf1hFx RuqfH12/fM5M8M4MVejcCenI6CuNkJP9PvOTZhTNoStPLuy0k68+UFwEKaQEOqduc4Ey HqMwVOB1jvO9NHOhF6ohYGw86nBRjPqllt22iZ5kEkEUrBkAsS1MCxf1gmCUcL5J9qRK ygsSdjV9+nPNwIkIBALIemDnL6uN7hFUrlU3mHt949KiUNFbOwOVXcoweoXZmirkKcWq N8dg== X-Gm-Message-State: AA+aEWYyUU24mq60ulG2zi1yvCQs7IOD3ZDDXK1WvrRGDtkNMHrPGP79 gwo/nwWObGBKh0fPmLY6MoFDm7wgOARDfhwGrQcbjqgSd+xfIWjdB8k8sngJEEYwwAhx6aCJRpx QzbCRECMjXx+3h4nhWv4m4o2PWm09y6Ds7YAKIpiokb1zTvr3O6CaFw19paVM7qCQVw== X-Received: by 2002:a65:590b:: with SMTP id f11mr16831371pgu.60.1545159254615; Tue, 18 Dec 2018 10:54:14 -0800 (PST) X-Google-Smtp-Source: AFSGD/VjJttuWLubb9h+vB/apHQLIXRp3NSPWlbdZ2eCb9SP3F6AFqTpnQnJEPPg1x2x5XwoNCJW X-Received: by 2002:a65:590b:: with SMTP id f11mr16831314pgu.60.1545159253429; Tue, 18 Dec 2018 10:54:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545159253; cv=none; d=google.com; s=arc-20160816; b=G3eOltaKxXA1Ga8EjMF45dTbX5sK03EUP5tyXWccdD4ri2l0VaLnLFP4oGiIMJPmx/ B6IObYSs7Sv1m9jbZE1VI1I8h15O9yrpjpaV3sg2qYOAof1dNzTy8etjtZi8M79Tpub5 Bic1GUXd2aiSQsjBg6CICo7whFJEHRGkDuZ0QqdcXM4yhfQgdAwthYOgxzi+mFaRbyzC EZtTkIEt+bTKxtgXoOGsotCRSLWSlinnQc0LiB2MNIOps7snRqUrJBn8Pj33bM80g0op GstWEBpgAoK/pU0O7KwfoWo/mmG3qDCZnpSGf0MiCd9MT4F0lJzreu88f18KzPuxyMid zoLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Gx0bhRcL1WgzGx4uAcAoVMGOjdr6FfRTNvKocFLifVU=; b=s06If33GLY8XGGqUFf1mLIKzSkLabI598/x0wAIxs5fpRzIyRvfIRu2xPxwxkdAw16 u1sVHL5nK647MeMvJ3Whav0kDuqu4ui2/ikz7PSceHX3nsTZagNTMEGwIZANr3yAn991 Kq+F/HjnykIBZrraV8ojktE4lMsUiEjPVmnydLAZjtJzUOTUSy1ZRmPyCDkGUoZXlCQ+ ndrVaHAwRYwd2Dt+H9G6Eujp/UcfnGkJZ3wqAsJdLiD2kOAYwC9BkOVQeiOSExYyxRS2 tSQ2MJTKbAdUwK1YQ4wf5AB9ZNN9iCai7iUzYxtxCc62vkzBP0txZJbsXjXinPsLePQA t0rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=ThMzo9sz; spf=pass (google.com: domain of vineet.gupta1@synopsys.com designates 198.182.60.111 as permitted sender) smtp.mailfrom=vineet.gupta1@synopsys.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: from smtprelay.synopsys.com (smtprelay.synopsys.com. [198.182.60.111]) by mx.google.com with ESMTPS id z20si13629875pgv.159.2018.12.18.10.54.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Dec 2018 10:54:13 -0800 (PST) Received-SPF: pass (google.com: domain of vineet.gupta1@synopsys.com designates 198.182.60.111 as permitted sender) client-ip=198.182.60.111; Authentication-Results: mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=ThMzo9sz; spf=pass (google.com: domain of vineet.gupta1@synopsys.com designates 198.182.60.111 as permitted sender) smtp.mailfrom=vineet.gupta1@synopsys.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com 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 X-Originating-IP: [10.10.161.70] X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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,