Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1350434imm; Wed, 1 Aug 2018 14:29:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpebpNbX20nmneqV08GZrgTOFpA3hEyPMNAx/UXED89jM59S1NOZ5T/Wba5H8ChBwVqAK6hm X-Received: by 2002:a63:8449:: with SMTP id k70-v6mr29903pgd.309.1533158991800; Wed, 01 Aug 2018 14:29:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533158991; cv=none; d=google.com; s=arc-20160816; b=Su0iqyv+siVQMwxBmvC9EkHFhB5vl5BSdQp4vMvrpld3MuC8VV7lPzsN1Hip7Ofk/6 GxcgZGJYdkTVlhGOA0p5m+qJ+9/0psSZ4c/zK8l6J4XIcUTZMokX0Fl1W9lKpowNEGRa TGENxddSEAb2lqaomUH/CLVPNAwuvYRrAigmKMGIwYUfN/33ncTWtNWvcjef2+NYdSMB ZLkywlBKA3xU7og5rf528VYLXsd0RVsaNN2Sdp636i/W6Fn5onNpb0nok0guWP6iiN8/ v4JSxDjWoh30vmW9UXatcp0TNbG7hF9yCE6ARcmSiJpeXTb8F0eAxKJOhZz9FMhkoaGz vAOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=sA/m2YCOClXXOsytRRGtEDas8uEYvdNyFeo5Okfeq+A=; b=1AcVnmp3WgrLZI9QklFPaa2cE+Rdpunfgq4m1bp8paU4f4QZYTMEfbo3I7VUtIP/pK Fs8gD+LFD0Utah6Pz/3WeSsBc2YESmqryZ7CgtKndb/U/MeDcD/jn9dvuU1xSCtM0bhi Lb54J/RmxGWAoYWsyPvil0GPsSBVVxl1lvpaCsnuCJKwd28CpcTp+nr/PtoClR5hHJlE XSq9JdmPM/fnhCh02EWfPw9x6dPKgu8xkVNWDB2qNsJVx+xEbu1snT6wzR8lCt4Yy7zA 4Gy0gWMUrVQBJGSms7KXUL+nS2QLTN+u47yf35qYe4UkJe7ESckgM6tlB5KQ+nRlh5ZH X8Uw== ARC-Authentication-Results: i=1; mx.google.com; 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 v11-v6si17167plp.33.2018.08.01.14.29.37; Wed, 01 Aug 2018 14:29:51 -0700 (PDT) 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; 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 S1732332AbeHAXPO (ORCPT + 99 others); Wed, 1 Aug 2018 19:15:14 -0400 Received: from simcoe208srvr.owm.bell.net ([184.150.200.208]:46032 "EHLO torfep02.bell.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730995AbeHAXPO (ORCPT ); Wed, 1 Aug 2018 19:15:14 -0400 Received: from bell.net torfep02 184.150.200.158 by torfep02.bell.net with ESMTP id <20180801212729.TTZS32387.torfep02.bell.net@torspm01.bell.net>; Wed, 1 Aug 2018 17:27:29 -0400 Received: from [192.168.2.49] (really [70.53.62.189]) by torspm01.bell.net with ESMTP id <20180801212729.FUEW26298.torspm01.bell.net@[192.168.2.49]>; Wed, 1 Aug 2018 17:27:29 -0400 Subject: Re: [PATCH] parisc: prefer _THIS_IP_ and _RET_IP_ statement expressions To: Nick Desaulniers Cc: deller@gmx.de, jejb@parisc-linux.org, Nathan Chancellor , Thomas Gleixner , pravin.shedge4linux@gmail.com, Kate Stewart , Greg KH , linux-parisc@vger.kernel.org, LKML References: <20180801182258.17834-1-ndesaulniers@google.com> <78c667f9-5c8b-3835-83eb-4b59e27e4f7e@bell.net> From: John David Anglin Message-ID: Date: Wed, 1 Aug 2018 17:27:27 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Cloudmark-Analysis: v=2.2 cv=DZT4krlW c=1 sm=0 tr=0 a=VCUqJnZSONuD0ISaPFNHjQ==:17 a=IkcTkHD0fZMA:10 a=dapMudl6Dx4A:10 a=FBHGMhGWAAAA:8 a=vx3-_5-rBGK8EIvQcvkA:9 a=QEXdDO2ut3YA:10 a=9gvnlMMaQFpL9xblJ6ne:22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-08-01 4:52 PM, Nick Desaulniers wrote: > Dave, thanks for the quick review! > > On Wed, Aug 1, 2018 at 1:10 PM John David Anglin wrote: >> On 2018-08-01 2:22 PM, Nick Desaulniers wrote: >>> As part of the effort to reduce the code duplication between _THIS_IP_ >>> and current_text_addr(), let's consolidate callers of >>> current_text_addr() to use _THIS_IP_. >> Using the generic _THIS_IP_ results in significantly longer code than >> the parisc implementation >> of current_text_addr(). > It might be worthwhile to file a bug with your compiler vendor. It > seems like there may be a better way to generate code for this > construct. > > Also, I'm curious how hot this code is? I assume in general that the C > construct may be larger than the inline assembly, but I'm curious if > this introduces a performance regression or just makes the code > larger? Do you have stats on the size difference and performance > differences? What's more important to me is whether the patch is > correct... I exaggerated the size difference.  It's two instructions versus one on PA 2.0. > >> It also results in a local label in the text. >> This breaks the unwind data >> for the function with the label in 32-bit kernels. The implementation >> of current_text_addr() >> doesn't add a label. > ... oh, I guess I'm surprised that the label ends up in the code, vs > there just being a constant generated. Can you send me the > disassembly? Also, I'm curious how does having the label present in > the text break the unwinder? (I'm not familiar with how unwinding > works beyond following frame pointers). The generic code results in the following assembly code: .L2:         ldil LR'.L2,%r25         ldo RR'.L2(%r25),%r25 It's the LR and RR relocations that cause the label to end up in the final symbol table. The linker can't throw .L2 away  as its address has been taken. The comparable PA 2.0 code is:         mfia %r25 I'm aware of this issue as I just changed gcc to move branch tables to read-only data when generating non-PIC code because of this issue. Helge knows more about the unwind issues than I do as it's specific to the linux kernel. Userspace uses dwarf unwind info.  I believe what happens is the unwinder finds the label instead of the relevant function and its unwind data. > >> _THIS_IP_ should be defined using >> current_text_addr() on parisc. > I'm trying to eliminate current_text_addr() in the kernel, as it only > has 4 call sites (3 are arch specific). What are your thoughts on > making the current parisc current_text_addr() just a static function > (or statement expression that's local to) in > arch/parisc/kernel/unwind.c? I understand the desire to eliminate current_text_addr().  However, as it stands, using _THIS_IP_ introduces text  labels at many sites in the kernel.  That's why parisc needs to be able to provide its own define for _THIS_IP_.  Currently, we have in asm/processor.h: /*  * Default implementation of macro that returns current  * instruction pointer ("program counter").  */ #ifdef CONFIG_PA20 #define current_ia(x)   __asm__("mfia %0" : "=r"(x)) #else /* mfia added in pa2.0 */ #define current_ia(x)   __asm__("blr 0,%0\n\tnop" : "=r"(x)) #endif #define current_text_addr() ({ void *pc; current_ia(pc); pc; }) Dave -- John David Anglin dave.anglin@bell.net