From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751190AbdFAM0y (ORCPT ); Thu, 1 Jun 2017 08:26:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53060 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751054AbdFAM0x (ORCPT ); Thu, 1 Jun 2017 08:26:53 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A9090C057FA6 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jpoimboe@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A9090C057FA6 Date: Thu, 1 Jun 2017 07:26:51 -0500 From: Josh Poimboeuf To: Peter Zijlstra Cc: x86@kernel.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Linus Torvalds , Andy Lutomirski , Jiri Slaby , Ingo Molnar , "H. Peter Anvin" Subject: Re: [RFC PATCH 10/10] x86/unwind: add undwarf unwinder Message-ID: <20170601122651.g6xtofvyy3mbo7lq@treble> References: <89552d4047e5aed843f7b6a54277f9af62da6a82.1496293620.git.jpoimboe@redhat.com> <20170601110539.helelmmngwaba7fa@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170601110539.helelmmngwaba7fa@hirez.programming.kicks-ass.net> 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.32]); Thu, 01 Jun 2017 12:26:52 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 01, 2017 at 01:05:39PM +0200, Peter Zijlstra wrote: > On Thu, Jun 01, 2017 at 12:44:16AM -0500, Josh Poimboeuf wrote: > > > +static struct undwarf *__undwarf_lookup(struct undwarf *undwarf, > > + unsigned int num, unsigned long ip) > > +{ > > + struct undwarf *first = undwarf; > > + struct undwarf *last = undwarf + num - 1; > > + struct undwarf *mid; > > + unsigned long u_ip; > > + > > + while (first <= last) { > > + mid = first + ((last - first) / 2); > > + u_ip = undwarf_ip(mid); > > + > > + if (ip >= u_ip) { > > + if (ip < u_ip + mid->len) > > + return mid; > > + first = mid + 1; > > + } else > > + last = mid - 1; > > + } > > + > > + return NULL; > > +} > > That's a bog standard binary search thing, don't we have a helper for > that someplace? I wasn't able to find one... > > +static struct undwarf *undwarf_lookup(unsigned long ip) > > +{ > > + struct undwarf *undwarf; > > + struct module *mod; > > + > > + /* Look in vmlinux undwarf section: */ > > + undwarf = __undwarf_lookup(__undwarf_start, __undwarf_end - __undwarf_start, ip); > > + if (undwarf) > > + return undwarf; > > + > > + /* Look in module undwarf sections: */ > > + preempt_disable(); > > + mod = __module_address(ip); > > + if (!mod || !mod->arch.undwarf) > > + goto module_out; > > + undwarf = __undwarf_lookup(mod->arch.undwarf, mod->arch.num_undwarves, ip); > > + > > +module_out: > > + preempt_enable(); > > + return undwarf; > > +} > > A few points here: > > - that first lookup is entirely pointless if !core_kernel_text(ip) True. > - that preempt_{dis,en}able() muck is 'pointless', for while it shuts > up the warnings from __modules_address(), nothing preserves the > struct undwarf you get a pointer to after the preempt_enable(). Oops! > - what about 'interesting' things like, ftrace_trampoline, kprobe insn > slots and bpf text? I think support for generated code can come later. My current plan is to have some kind of registration interface for associating debuginfo with generated code. Maybe as part of the generated code management thing we talked about before: https://lkml.kernel.org/r/20170110085923.GD3092@twins.programming.kicks-ass.net -- Josh