Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp7040962ybf; Fri, 6 Mar 2020 09:13:21 -0800 (PST) X-Google-Smtp-Source: ADFU+vtAEohSogFdeq5K+rlwUidAGQpAkLLJS4ghCMWZG/9SmhzOFaUia0SYugKzIzhWNVaZ0DmS X-Received: by 2002:a05:6808:5d4:: with SMTP id d20mr3197938oij.138.1583514801503; Fri, 06 Mar 2020 09:13:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583514801; cv=none; d=google.com; s=arc-20160816; b=tK0xtd+NIPvNc2138vTUPXQnkyV92HFZjgn5kE9QvH3uiW99xaLN3/1MRxFbB/f12j vxPyxQFIo97x8djPYGQzJsHgK+jP6ID1lNtMCFEe5evSriUgSS7qIND60nsuPIDdTqs0 70GFVvCzWXE73kqlhI+zc6uXAAy0BADDRvyJuIjIWM5pUvDJ5Vj/vdKWi1ef6JJjtZ1f wDqKERw1KuulBAAc+8RAvRYCpEBURBGWNbcVpHmOiMmA3AP6v+D/gGGxlN29v6MTtgC8 fgOla5n2ose+QYXhxRYxNrfNPN8Da5WmNNXgrzhP7jj51TocaAkNw5ZqQn4TZgVooLoN LtSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Yskyhb5MAj3gfBWVrJyupKmskSJdAmyZg1xe5aa7xRU=; b=OPfs596n0PpaFTdy6ur8e9pSgYC2c6PMGCx4XjAPTWsPJNC6aA5xJ0ZnrIZCT1J6Su Xg4Tpw7FzDTXtmyuGXCtPw1B4EvJT0JfbI+0xbPxwaj0wop6fab7OVQVaiN3UOGvm5uB udU5cildmB5HSqdvspeZaGmNEzwJGuNxOgHJ73C0GPXCygCKoPJmAZDfS4M5dec1HXbt u63VRQKsbohcxLuPCqOoV3GpFKGnLQcIsEOWwL9WgM9MP8tsUCm+N7yqVq7GD8KVgOZ2 qKqkYvYKSL1PSiQEBs5diAXSMgrQV2mMUml2+QHLzLW6YENIn4CFPI3nbTumQkxiti8k +0Yg== 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 v81si4988oia.114.2020.03.06.09.13.05; Fri, 06 Mar 2020 09:13:21 -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; 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 S1726579AbgCFRMs (ORCPT + 99 others); Fri, 6 Mar 2020 12:12:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:59080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726231AbgCFRMs (ORCPT ); Fri, 6 Mar 2020 12:12:48 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8379320658; Fri, 6 Mar 2020 17:12:47 +0000 (UTC) Date: Fri, 6 Mar 2020 12:12:46 -0500 From: Steven Rostedt To: Artem Savkov Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org Subject: Re: [PATCH] ftrace: return first found result in lookup_rec() Message-ID: <20200306121246.5dac2573@gandalf.local.home> In-Reply-To: <20200306081035.21213-1-asavkov@redhat.com> References: <20200306081035.21213-1-asavkov@redhat.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 6 Mar 2020 09:10:35 +0100 Artem Savkov wrote: > It appears that ip ranges can overlap so. In that case lookup_rec() > returns whatever results it got last even if it found nothing in last > searched page. > > This breaks an obscure livepatch late module patching usecase: > - load livepatch > - load the patched module > - unload livepatch > - try to load livepatch again > > To fix this return from lookup_rec() as soon as it found the record > containing searched-for ip. This used to be this way prior lookup_rec() > introduction. > > Fixes: 7e16f581a817 ("ftrace: Separate out functionality from ftrace_location_range()") > Signed-off-by: Artem Savkov > --- > kernel/trace/ftrace.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index 3f7ee102868a..b0f5ee1fd6e4 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -1547,8 +1547,10 @@ static struct dyn_ftrace *lookup_rec(unsigned long start, unsigned long end) > rec = bsearch(&key, pg->records, pg->index, > sizeof(struct dyn_ftrace), > ftrace_cmp_recs); how about just adding: if (rec) break; as that will do the same thing without adding two returns. -- Steve > + if (rec) > + return rec; > } > - return rec; > + return NULL; > } > > /**