From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751256AbdFANKc (ORCPT ); Thu, 1 Jun 2017 09:10:32 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:41094 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751062AbdFANKa (ORCPT ); Thu, 1 Jun 2017 09:10:30 -0400 Date: Thu, 1 Jun 2017 15:10:20 +0200 From: Peter Zijlstra To: Josh Poimboeuf 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: <20170601131020.fcyv77m3qb5v2zwc@hirez.programming.kicks-ass.net> References: <89552d4047e5aed843f7b6a54277f9af62da6a82.1496293620.git.jpoimboe@redhat.com> <20170601110539.helelmmngwaba7fa@hirez.programming.kicks-ass.net> <20170601122651.g6xtofvyy3mbo7lq@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170601122651.g6xtofvyy3mbo7lq@treble> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 01, 2017 at 07:26:51AM -0500, Josh Poimboeuf wrote: > 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... Yeah, I looked too and couldn't find it either. A well.