Received: by 10.223.185.116 with SMTP id b49csp3811694wrg; Tue, 6 Mar 2018 05:29:00 -0800 (PST) X-Google-Smtp-Source: AG47ELuZgqYknyrvWui7kBgR0awT10H6PxDWMh6eyYzQGb7NpPDGCr7Qqb0dfHXasxU1r5Ww2CJ7 X-Received: by 10.98.147.27 with SMTP id b27mr18996635pfe.145.1520342940692; Tue, 06 Mar 2018 05:29:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520342940; cv=none; d=google.com; s=arc-20160816; b=QRqY6IGiLne9DJISzrW32UgH7zX3B6AUNqqjMYd74oGVQIFgrcGEo/l3PwHvYPl59T FpCDnckNmwi5xxQiyTJ7vlMkjqoMRlOSOw2jnbaOPnU0MtcVXkXKej37cP+a0v+DEGDb TXh4vL5qxOJX0tog3VhlBHIvnShzco3RUAdSbVGM3+MJNwx2mqxoetoaCQddgJiylGoS olMvassA5BSF2bS9LRm+OWY0hYWb7qqrRnEs8QKe8NuHaPHt6i+jDNp8aJpewuZN326u SX7PnrQkzFxCFhjZRWYvGxbw6ucgWUKpH4VzY3hn7qjTO2SjaXd3Y+qesHO+JOTvNb4H sX/g== 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=ngoz/SGyHzD9lVodLGYIJJ+aTQ2sATCFT8rAKCghlic=; b=BtPZKcuuglDa4kZof9sGi5hTr5Z3zBu0IFyvI1IXLaXE2c07HaoSEqnJv4MllL2aeQ dckASxcWoTDGvbcH56JkJ0e+sgaMQTTk2wDtHqIdJPI9TKbPNqnq5ORDq2xNOYlyBF4D IkAfruGuE5fD9LdpuX+1u5jXwS2BxDLlGFSDI5kjKzSqHTxDs1goJgd8VcIly78ID9+C Q9YiK9c9P+bRnCHkbF+F1BKhpQYMNBUUPPFjU0xXF2+Mk1FmGo6fZUUBTLd1d7isPy0y 8n8X8eYD2vh130arM/Djj7Ua5kY6eAnLawUYyKswqeABnclZlFX7LN4Eipz8wrPRZ3AE hzLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VrKRVDp5; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z19si2296897pfi.407.2018.03.06.05.28.45; Tue, 06 Mar 2018 05:29:00 -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=fail header.i=@gmail.com header.s=20161025 header.b=VrKRVDp5; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753673AbeCFN1d (ORCPT + 99 others); Tue, 6 Mar 2018 08:27:33 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:45853 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753497AbeCFN1b (ORCPT ); Tue, 6 Mar 2018 08:27:31 -0500 Received: by mail-io0-f194.google.com with SMTP id m22so22008453iob.12 for ; Tue, 06 Mar 2018 05:27:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ngoz/SGyHzD9lVodLGYIJJ+aTQ2sATCFT8rAKCghlic=; b=VrKRVDp59UCe/ZHuJ2mFgB2flWznu23dPXBGaBEYYo/XivZoCsO31VPQM1Ws/zbc9B 2R3ZYoDSa2DSkqVDLbwSOu1Tj9z8kPGwKYJugtBZti1EwDWCb+cgoabpbqZrpA5aiIRk ePE1S+9NhIXyMSAmfvABQfi9wBfN3ga081L8/vpYsIBTXL8tU0BPppsN4J+7lM0tBRwU OV9kQXQqr/HlSFdXOP50YKh5KdGCJKLswPSkM4d36wkJDt5jDTX5d19tBT/Efi0FJYJC 8zFOGBRrFGGct66r+wEHsP3AvzQEyaJxy23pPexd5/YnYAMJHqKR73J8GrTfWzwvvRsg 9D5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ngoz/SGyHzD9lVodLGYIJJ+aTQ2sATCFT8rAKCghlic=; b=sP9aV77ZlTTotprruoCaxzFBCVtxALj7/5S8WNOTpibqsJFbfwaajEwp7yoomodsMc OrjdYE3E9JI51FLEnxK/2rua3Yg2M8BR+IH4S8bmpqqu7kXAkgC4VBA77BnTeEhV9gzy 1PdmsplFLHe5QMi0KfCtcfULWXQgWJDDt8W1H3jbVYRT3Nn+mQscHjPDiwNS/piliRGD /UpcX+xu3uxCtorYsw9UI1aC1zefApzptkUJ7oCv7Ys6U1ss0IN0+kIqOE1PMXLEPIcd ckrIWD2sgouv9T7Ky1b4aAiged5vw/FA3HYAy4LjBtpMG5gQx1QcGyj3guiQdmE624R0 kG0g== X-Gm-Message-State: APf1xPAbM9irHp8y+PYv04OxsoW6QnQzCXxUwMX28T8mxr4cR2e+XYPb COz5KZKj1/6p7H8zi3p4p93fROKO/Tw0BQZ7Tr8= X-Received: by 10.107.157.146 with SMTP id g140mr21071751ioe.5.1520342850901; Tue, 06 Mar 2018 05:27:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.79.34.71 with HTTP; Tue, 6 Mar 2018 05:27:30 -0800 (PST) In-Reply-To: <20180305053742.9149-1-sergey.senozhatsky@gmail.com> References: <20180305053742.9149-1-sergey.senozhatsky@gmail.com> From: Arnd Bergmann Date: Tue, 6 Mar 2018 14:27:30 +0100 X-Google-Sender-Auth: gqLkA6Rt0h-fw9euvxQfB0_qV6Y Message-ID: Subject: Re: [PATCH] dump_stack: convert generic dump_stack into a weak symbol To: Sergey Senozhatsky Cc: Petr Mladek , Tejun Heo , Steven Rostedt , Dave Young , Andi Kleen , Greentime Hu , 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 On Mon, Mar 5, 2018 at 6:37 AM, Sergey Senozhatsky wrote: > We want to move dump_stack related functions out of printk C > code and consolidate them in lib/dump_stack file. The reason why > dump_stack_print_info()/etc ended up in printk.c was a "generic" > (dummy) lib dump_stack() function, which archs can override. > For example, blackfin and nds32, define their own EXPORT_SYMBOL > dump_stack() functions. > > In case of blackfin that arch-specific dump_stack() symbol invokes > a global dump_stack_print_info() function. So we can't easily move > dump_stack_print_info() to lib/dump_stack, because this way we will > link with lib/dump_stack.o file, which will bring in a generic > dump_stack() symbol with it, causing a multiple definitions error: > - one dump_stack() from arch/blackfin/dumpstack > - the other one from lib/dump_stack > > Convert generic dump_stack() into a weak symbol. So we will be > able link with lib/dump_stack and at the same time archs will > be able to override dump_stack(). It also opens up a way for us > to move dump_stack_set_arch_desc(), dump_stack_print_info() and > show_regs_print_info() to lib/dump_stack. > > Signed-off-by: Sergey Senozhatsky > --- > arch/blackfin/kernel/dumpstack.c | 1 - > arch/nds32/kernel/traps.c | 2 -- > lib/dump_stack.c | 4 ++-- > 3 files changed, 2 insertions(+), 5 deletions(-) > > diff --git a/arch/blackfin/kernel/dumpstack.c b/arch/blackfin/kernel/dumpstack.c > index 3c992c1f8ef2..61af017130cd 100644 > --- a/arch/blackfin/kernel/dumpstack.c > +++ b/arch/blackfin/kernel/dumpstack.c > @@ -174,4 +174,3 @@ void dump_stack(void) > show_stack(current, &stack); > trace_buffer_restore(tflags); > } > -EXPORT_SYMBOL(dump_stack); As we are now removing blackfin, based on the latest discussion, this part should no longer be necessary. > diff --git a/arch/nds32/kernel/traps.c b/arch/nds32/kernel/traps.c > index 8828b4aeb72b..455bb0787367 100644 > --- a/arch/nds32/kernel/traps.c > +++ b/arch/nds32/kernel/traps.c > @@ -166,8 +166,6 @@ void dump_stack(void) > __dump(NULL, base_reg); > } > > -EXPORT_SYMBOL(dump_stack); > - > void show_stack(struct task_struct *tsk, unsigned long *sp) > { > unsigned long *base_reg; nds32 currently only exists in linux-next, not in the mainline kernel. If it's the only architecture that does something different from everyone else, I think we should change nds32. I looked at the nds32 show_stack() implementation now and it seems to me that it is completely unnecessary, as the implementation from lib/dump_stack.c does basically the same thing (by calling show_stack(NULL, NULL)). > diff --git a/lib/dump_stack.c b/lib/dump_stack.c > index c5edbedd364d..02a8ad163760 100644 > --- a/lib/dump_stack.c > +++ b/lib/dump_stack.c > @@ -25,7 +25,7 @@ static void __dump_stack(void) > #ifdef CONFIG_SMP > static atomic_t dump_lock = ATOMIC_INIT(-1); > > -asmlinkage __visible void dump_stack(void) > +asmlinkage __weak __visible void dump_stack(void) > { > unsigned long flags; > int was_locked; > @@ -58,7 +58,7 @@ asmlinkage __visible void dump_stack(void) > local_irq_restore(flags); > } > #else > -asmlinkage __visible void dump_stack(void) > +asmlinkage __weak __visible void dump_stack(void) > { > __dump_stack(); > } 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. Arnd