Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp909464imm; Wed, 15 Aug 2018 08:10:17 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyfrhQyHgrVDyuCnwORIoz+O1Mfjc5S7Xc2oR4Sw7P2PnUa6m8bbKToLhRQIxCMvQAjgGw2 X-Received: by 2002:a17:902:b28c:: with SMTP id u12-v6mr24320654plr.16.1534345817420; Wed, 15 Aug 2018 08:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534345817; cv=none; d=google.com; s=arc-20160816; b=CsfTdneXeIN/IaRmfsInxHzaNLmiPTxsqegRrY7goxqkx3EKLY9t3g73q0eM9cKoE+ lYEbuAvLXLpSA1TN/TqaurZCP/CQ9eOSQwEHqjj2mjDikDKKA3eNClY5KcRJYhYPohJz dYhrzWuQKTdRcLEq2D7BfYyUULt2cHwShc3bLL530ACaD+i6YE0iQuAP1YNrREFOP0Oc 4tsDLoyWC4dsYkouzvqlGSPITGMqW3fi5wr0O9qY7e/qqsCK2kwabjJf+n/B14FEA7j/ v143SZ4pJvap9s1+oaR/Ec4lBVrBVeiWM8QxsJ3N/hTZ7oCrSu6+vyiSQN1K5SqHRuA8 sNoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=NzFilJ2b334rZqx38B5bz/RI7F2eH8cGx8lHAUeSJSk=; b=y5ZfUvtg4zrtdRZV0NYDhbvSKblEvdDgwBL8lbVkBqZonLpdsOQt+KQtVHwZEQx/r1 fX0M/PV18dK6+AyDAjwDgP28afqNY97O9pe6oIsSF4D6NZXZQ5yI8zl4NgTaCAfbEAil 6RCI1fMoEvEu76k0a33HnxAUizra71LVLZirEAQ3AfemCo1R4TVMA5y1HckXK5yZ8S/p QX1U1FSDbaFvWsjoyShHzRoGk1Cmw6ADkW+r4PP4B74X/NKqAih8X65ZzoSxfwehIun/ O4pqq57JdmCZOUFKpMkyzm+RGFddgg7kI38GOSEyaxUkBdzxN4UOxgllrRWfBLVmcxUY +fhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HyRKE2Qj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f28-v6si25987178pfh.33.2018.08.15.08.10.02; Wed, 15 Aug 2018 08:10:17 -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; dkim=pass header.i=@kernel.org header.s=default header.b=HyRKE2Qj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730777AbeHOSBS (ORCPT + 99 others); Wed, 15 Aug 2018 14:01:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:51182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729528AbeHOSBS (ORCPT ); Wed, 15 Aug 2018 14:01:18 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (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 F1146214AB; Wed, 15 Aug 2018 15:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1534345725; bh=hhUCw/6m/9JrSMVI9Hlk+i1w6PgbwxxedNPfk3bswd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HyRKE2QjrL0yinVtCu8TjBxLaUimpGmtus3djdEXcBX348eJUCssisTYYAXQyr+kE nNtErcLjI6nLWT1F505m9eXsykc/1ntmYvxNLUl9P5kbafNvPGnSN/2cv1SXRJttV3 uXyCxvgwM/TGsbTXeMLuO5Yv4NxI/9PZBDvH4NiQ= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Adrian Hunter , Alexander Shishkin , Andy Lutomirski , Dave Hansen , "H . Peter Anvin" , Jiri Olsa , Joerg Roedel , Thomas Gleixner , x86@kernel.org, Arnaldo Carvalho de Melo Subject: [PATCH 33/35] kallsyms: Simplify update_iter_mod() Date: Wed, 15 Aug 2018 12:06:09 -0300 Message-Id: <20180815150611.32080-34-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180815150611.32080-1-acme@kernel.org> References: <20180815150611.32080-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Adrian Hunter The logic in update_iter_mod() is overcomplicated and gets worse every time another get_ksymbol_* function is added. In preparation for adding another get_ksymbol_* function, simplify logic in update_iter_mod(). Signed-off-by: Adrian Hunter Tested-by: (ftrace changes only) Steven Rostedt (VMware) Acked-by: Andi Kleen Acked-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Andy Lutomirski Cc: Dave Hansen Cc: H. Peter Anvin Cc: Jiri Olsa Cc: Joerg Roedel Cc: Thomas Gleixner Cc: x86@kernel.org Link: http://lkml.kernel.org/r/1528289651-4113-2-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- kernel/kallsyms.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index a23e21ada81b..aa31aa07f2ef 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -506,27 +506,24 @@ static void reset_iter(struct kallsym_iter *iter, loff_t new_pos) } } +/* + * The end position (last + 1) of each additional kallsyms section is recorded + * in iter->pos_..._end as each section is added, and so can be used to + * determine which get_ksymbol_...() function to call next. + */ static int update_iter_mod(struct kallsym_iter *iter, loff_t pos) { iter->pos = pos; - if (iter->pos_ftrace_mod_end > 0 && - iter->pos_ftrace_mod_end < iter->pos) - return get_ksymbol_bpf(iter); - - if (iter->pos_mod_end > 0 && - iter->pos_mod_end < iter->pos) { - if (!get_ksymbol_ftrace_mod(iter)) - return get_ksymbol_bpf(iter); + if ((!iter->pos_mod_end || iter->pos_mod_end > pos) && + get_ksymbol_mod(iter)) return 1; - } - if (!get_ksymbol_mod(iter)) { - if (!get_ksymbol_ftrace_mod(iter)) - return get_ksymbol_bpf(iter); - } + if ((!iter->pos_ftrace_mod_end || iter->pos_ftrace_mod_end > pos) && + get_ksymbol_ftrace_mod(iter)) + return 1; - return 1; + return get_ksymbol_bpf(iter); } /* Returns false if pos at or past end of file. */ -- 2.14.4