From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752561AbdEIBiW (ORCPT ); Mon, 8 May 2017 21:38:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56434 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751094AbdEIBiV (ORCPT ); Mon, 8 May 2017 21:38:21 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 497BD3DE3D Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jpoimboe@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 497BD3DE3D Date: Mon, 8 May 2017 20:38:18 -0500 From: Josh Poimboeuf To: Andy Lutomirski Cc: Linus Torvalds , Jiri Slaby , Andrew Morton , live-patching@vger.kernel.org, Linux Kernel Mailing List , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , the arch/x86 maintainers , Jiri Kosina Subject: Re: [PATCH 7/7] DWARF: add the config option Message-ID: <20170509013818.i2njk66mcgp4rtp7@treble> References: <20170505122200.31436-1-jslaby@suse.cz> <20170505122200.31436-7-jslaby@suse.cz> <20170507165524.cdxfuwbd5alr7v6k@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 09 May 2017 01:38:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 08, 2017 at 05:21:24PM -0700, Andy Lutomirski wrote: > On Sun, May 7, 2017 at 9:55 AM, Josh Poimboeuf wrote: > > struct undwarf { > > unsigned int ip; /* instruction pointer (relative offset from base) */ > > unsigned prev_frame:13; /* offset to previous frame from current stack pointer */ > > unsigned regs:1; /* whether prev_frame contains entry regs (regs->ip) */ > > unsigned align:2; /* some details for dealing with gcc stack realignment */ > > } __packed; > > > > extern struct undwarf undwarves[]; > > Some comments in case you're actually planning to do this: > > 'unsigned int ip' is the majority of the size of this thing. It might > be worth trying to store a lot fewer bits. You could split the > structure into: > > struct undwarf_header { > unsigned long start_ip; > unsigned align:2; /* i'm assuming this rarely changes */ > ...; > unsigned int offset_to_details; > }; > > and > > struct undwarf_details { > unsigned short ip_offset; > unsigned short prev_frame; > }; > > and you'd find the details by first looking up the last header before > the ip and then finding the details starting at (uintptr_t)header + > header->offset_to_details. Good idea. According to some back-of-a-napkin math, a scheme like this could reduce the data size from 1.8M down to 1.2M with my kernel config, a not-too-shabby 600k savings. > Also, don't you need some indication of which reg is the base from > which you find previous frame? After all, sometimes GCC will emit a > frame pointer even in an otherwise frame-pointer-omitting kernel. I don't think we *need* to do that. I believe the base reg can just always[*] be the stack pointer, even with frame pointers. That said, it might be beneficial to use the frame pointer as the base reg where applicable, because it would shrink the data size, especially in a kernel with frame pointers enabled. And I think we would only need an extra bit to store that info. First I'll just start with the simplest possible scheme (i.e., what I proposed above). Even that calculates out to be smaller than the DWARF .eh_frame stuff. Then after that we can look at compression techniques (and their associated tradeoffs). [*] ignoring rare gcc stack realignments -- Josh