Received: by 10.223.185.116 with SMTP id b49csp4839055wrg; Wed, 7 Mar 2018 01:46:20 -0800 (PST) X-Google-Smtp-Source: AG47ELtNwN49+0I8JmxPALPsh9MBRrUDhbEU8k6123MljpicAV5r+oogvaEDvaTNoJiSwWWmn9aB X-Received: by 10.101.82.70 with SMTP id q6mr17410545pgp.67.1520415980475; Wed, 07 Mar 2018 01:46:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520415980; cv=none; d=google.com; s=arc-20160816; b=FOZaJHvJRx8Z7tjzG0dDfjkgy9X/qLkjFqUvPDY5IzGPotPvQDi7rih8VXoFayzKLb TcWl5D9bm3RM9UP5m5me/Ebx58oRVJxyxoGK2EReJov+r82uo0hM3j1GJaLgQpYTCHQj +0kxKAe6kAw3ITsEGlprqal9kfjRsNTTOyCYfbUk1vbL3PJxXRCLSwnWJq0kFPddTDSc CaeMwJkTtzk11qFo42C5srznou4mbOYiuBWfmxm+xVLlqJvNHpxYu2gxdTCbm8t0IAhs sOuzhpz73Nzl1Z6I9OvpatlUBeJtCXlKuqlhs5ex8ndvfCSkixegMcuzt2XnuUUR98nj kR+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Cn4mB1fBGMklrZPx5a6o+/M3qCwhZPjkosz/F0tDxdA=; b=cjGLmn/bwR504FtHrwV/wF8ZCVyYUu6WN0owcp52DVFp4TxBnwyVahnvNumFdSMBUb cg+x2ZNiOSeq2aABovZumtrTafbjjD78HRR6ibbve5ugRc+l9WOBub+KfXR1qzwQcfCz 7WtJzG6zdob6M+LykVCY0oF3nXeNFiD+Weqf0kFzuAMSFeR5etNkmb7KcimCy/6ArrUu y7GbKR0nIj5NqMmTxHiTRBRMC0vSeNU8qPDw0CK6WR7IHa8DFuYhL7/K1irDleSdcMwR jodIw17YZ5rTupb+bFlYzsVVtTLazSjQqs8mSSSbkyepBPxV8KqJXacQfxiB9Fu/AEx1 JVqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ErRiE4xX; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t19-v6si12422768plo.742.2018.03.07.01.46.05; Wed, 07 Mar 2018 01:46:20 -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=@gmail.com header.s=20161025 header.b=ErRiE4xX; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751220AbeCGJpL (ORCPT + 99 others); Wed, 7 Mar 2018 04:45:11 -0500 Received: from mail-vk0-f66.google.com ([209.85.213.66]:39705 "EHLO mail-vk0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751072AbeCGJpJ (ORCPT ); Wed, 7 Mar 2018 04:45:09 -0500 Received: by mail-vk0-f66.google.com with SMTP id f6so927423vkh.6 for ; Wed, 07 Mar 2018 01:45:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Cn4mB1fBGMklrZPx5a6o+/M3qCwhZPjkosz/F0tDxdA=; b=ErRiE4xXz7V1TH3Skx+jT4/VJGcxwTsFuPMPXIWCi3/Ebadon20U1BlBb9arTMcusn Qe+1rwPvyXG7PczLezA7y5Poko2JbwSaomFFTDXrKUaKpiCOx6mR/V2hz+l5/xO84tvG 5cvLVgZghVYww4s4iADqCVaKJDgw4r4hraxHFipuZZVr41R7/O18tNOD6bULgpmUcxh8 c0HdTRCjO0fFP9zGgLBKbIwAyseTBjIvTThIoJtOC120b85SMTr6AsA4UQex0AZcQFD7 uBw9qz6pvX3J9WEFn600QiFqsDKVhN14O25WdJPI2HwcStMneN0cnCSL17n0ThWTHhUH YpdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Cn4mB1fBGMklrZPx5a6o+/M3qCwhZPjkosz/F0tDxdA=; b=ssJDfCZEJ0RyWVdVke0whPvA5nIOaSptYSjWbNyLpFGpB881sKwpp3X0Yl/PdcxSXI CR6GfcyzTPqu+q+IQ1O2TPUYsUC58OfKdYmDCwwejnW7yZrcj0oCPxIYOMylujZU3OeD OkkILOf1OSj4xt0ZJsN1aMUwjZtMnLlgaIp5tWFrFKocYqdi8aSULraq9IHE98WvS2DC HT7P+VkrV5RtqC9tYNl5vkzKArYCA1bG3HfhT9ARKI959kH8rmHx533jViWCYoUHnXBh ReFYZGxKY1TC70o2aVm3C11g6VbnhoC3/XN/MmIZgAaZrq2gCNlW2UfEogpvM5k6M3zC yBGA== X-Gm-Message-State: APf1xPBYU40/s/LIJ2t5emqQ92L/3FvbpmRYaCWmjwDL4wFhzDfVVXCV PJwHDAa6fZCIC2JU+6K6rAXbhFb8ZhSDsEcKxJo= X-Received: by 10.31.209.69 with SMTP id i66mr15312341vkg.95.1520415908234; Wed, 07 Mar 2018 01:45:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.159.49.66 with HTTP; Wed, 7 Mar 2018 01:44:27 -0800 (PST) In-Reply-To: <20180307090917.2xqifk2wpk5ty36j@pathway.suse.cz> References: <20180305053742.9149-1-sergey.senozhatsky@gmail.com> <20180307022127.GB802@jagdpanzerIV> <20180307090917.2xqifk2wpk5ty36j@pathway.suse.cz> From: Greentime Hu Date: Wed, 7 Mar 2018 17:44:27 +0800 Message-ID: Subject: Re: [PATCH] dump_stack: convert generic dump_stack into a weak symbol To: Petr Mladek Cc: Arnd Bergmann , Sergey Senozhatsky , Tejun Heo , Steven Rostedt , Dave Young , Andi Kleen , Vincent Chen , Peter Zijlstra , Andrew Morton , Stephen Rothwell , adi-buildroot-devel@lists.sourceforge.net, Linux Kernel Mailing List , Sergey Senozhatsky Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-03-07 17:09 GMT+08:00 Petr Mladek : > Ah, there was a mid-air collision. Arnd already answered most of my > questions and even more. > > On Wed 2018-03-07 09:46:27, Arnd Bergmann wrote: >> On Wed, Mar 7, 2018 at 3:21 AM, Sergey Senozhatsky >> wrote: >> > On (03/06/18 14:27), Arnd Bergmann wrote: >> >> Weak symbols are generally discouraged in the kernel. We have >> >> them in a couple of places, but I find them rather confusing as they >> >> make it harder to figure out what is actually going on. >> > >> > Honestly, I kind of find __weak less confusing than EXPORT_SYMBOL(dump_stack) >> > in 3 different places. __weak hints that the symbol likely will be overridden >> > somewhere, while EXPORT_SYMBOL() does not (at least not to me). Dunno. >> >> It's not either/or, they are both wrong ;-) >> >> The EXPORT_SYMBOL() is not the thing that makes it work. The duplicate >> declaration today only works because lib/dump_stack.o is listed as lib-y >> in the Makefile instead of obj-y. On blackfin and nds32, this causes the entire >> file to just not be included in the final vmlinux, because there are no >> references to it. >> >> With your patch, I would actually expect the lib/dump_stack.o file >> to still not be picked up, so now you have a missing EXPORT_SYMBOL() >> on the two unusual architectures until the point when you add another >> (referenced) symbol to it. > > Great catch! We should change it from lib-y to obj-y. Of course, > the best solution would be if nds32 uses the generic implementation > and we could avoid adding __weak. > I agree too. I think I can add a patch to remove the dump_stack() implementation in nds32 and use the generic one. diff --git a/arch/nds32/kernel/traps.c b/arch/nds32/kernel/traps.c index 8828b4aeb72b..6e34eb9824a4 100644 --- a/arch/nds32/kernel/traps.c +++ b/arch/nds32/kernel/traps.c @@ -156,18 +156,6 @@ static void __dump(struct task_struct *tsk, unsigned long *base_reg) pr_emerg("\n"); } -void dump_stack(void) -{ - unsigned long *base_reg; - if (!IS_ENABLED(CONFIG_FRAME_POINTER)) - __asm__ __volatile__("\tori\t%0, $sp, #0\n":"=r"(base_reg)); - else - __asm__ __volatile__("\tori\t%0, $fp, #0\n":"=r"(base_reg)); - __dump(NULL, base_reg); -} - -EXPORT_SYMBOL(dump_stack); -