Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3629983ioa; Tue, 26 Apr 2022 07:11:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxlNWr3jLIXLxGsCw/Y7DynVcl0+3ryhLZy7j830iUlp9kFhcPyorrlOldOHA1EgyCfJ6B X-Received: by 2002:a05:6638:3e1b:b0:32b:a27:1dc8 with SMTP id co27-20020a0566383e1b00b0032b0a271dc8mr904875jab.303.1650982311775; Tue, 26 Apr 2022 07:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650982311; cv=none; d=google.com; s=arc-20160816; b=cQObq233LnE+AsbTBkM1RA38FS/Ld6U35wfaEQneHEUhEP/7uM9uBgDajEglyvB54H MNJzfhSNKxA+MpLHmguzmBkC+iHZVck/2Ilup75tCTp+xWt9wmH5rP6gorMUIyEzR0Cp 0gkpcXUBUMc0U0BUHdPi017//xr/IGCuXlQxMKN2NgmMC7FizQO664JtTlAisEXVfwh9 d1DdH9I7Jb+1qOhk3FpJaJpo96PXfHFzAQnT3UD19TOHDruwc2PTASnw7eUj38s3a0G8 MyhG2spWYTLOR2JMFqaH6DGiQ5DPIvbbdrwApxTYwHLjQPFjphu4rZefpUsD3Ymkq2Ih XpTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tUQrxavB/ZORPEFYd+g4E581It2+tjHhQ0R1hZx9kac=; b=ItQkLv6hXNl/CfTMwkBYx6fBQGOcXY14Jf64YhQK0yUHXzPqWhPEnxnX0Nn4LecZXE 63y1d/Kyi0jdvLbGmrM4638jQuYzzHD8edJczVeo5AYBmpE9x9PaJ6qnWI4e7CCqzeig SSJ4oXcbbcAqud/gOCcjQ7jw5g1udpd7fBBnGiVe8ax1gNh9cbhnInuiNsdPq+nD+Chs RAuJUnRXr3dtqWfQPLchSosHHSYzS0MQhvp3YXbvJJi5XwNIoJngSSSYPFF6FxWMm1ze zQcAHj2EOClph/Ys6jYFcp2mtB+eqrEZMcf6Z9G8ffZSCpLamKIWAmFeIX6PvfQvnZqb iSyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZnPrsRi6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t14-20020a5d884e000000b0064958084516si9625306ios.51.2022.04.26.07.11.32; Tue, 26 Apr 2022 07:11:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZnPrsRi6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349886AbiDZMaR (ORCPT + 99 others); Tue, 26 Apr 2022 08:30:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346338AbiDZMaP (ORCPT ); Tue, 26 Apr 2022 08:30:15 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1602D69295; Tue, 26 Apr 2022 05:27:08 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id a1so16475255edt.3; Tue, 26 Apr 2022 05:27:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tUQrxavB/ZORPEFYd+g4E581It2+tjHhQ0R1hZx9kac=; b=ZnPrsRi62/v9HJsUi4Io169wkYw6Jp8qgNE3yXWsPNEEN5M9eq6mDaWoAwCjEk57an i782RzuCMHROIBq0PmkvwV+YGs2buzhiKFjw23X2LvnUUwrdCBf/cBLFaUV3hOiGlZC6 VqjVpFP+Ee1Du4rVfPV0vkjq2JxdQf3Ah8AariZPWrmpyZFUsaHJro3PjKJea6Jd4SU+ o2+BvS/117XPWgc6zkOm04bYuYobvkK81T4sIIigD86ILimXZK4f1QsdIkT45rXC+3oP 6kl3XV79k/YRrh4i4KDhD9eKv8OzdfSMrxQE8N5k8LNUls55O/3JVBsTI9AnyM/hO4ZA RuZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tUQrxavB/ZORPEFYd+g4E581It2+tjHhQ0R1hZx9kac=; b=LWt2JuprMXW9+YYtu7spVX6S3MLgqX58souXzUrl4ShOzEmZnaNzwId8fiXJYbxV0I P5I2oRh2cUkqhEa2CPMUj1/BXDmDDSoZhtg9DxyqvcWNNJ1rpM+tPA0LA9qNjbdwEhLS 1rCv0fw1GAg9nrTvAmhXFMiUGFA9C6rnnpwGBQQX0a6W/ruqqZScPl8x2brNIz4etLa6 xV34dxgcStbqCGkKZwlvJmiiPZARZEj88/42kV3xt9TDxNHMW91XCCq94qUDDTkCaw07 BcLBTGmOmFWZhtunfZOSoNyLTtC0GmdJWCWlQmSJ4H7h5P3P8lriauGLYGLKcok7izo4 0z5A== X-Gm-Message-State: AOAM531L79vRkBXeBVu+4mdtsRnlp0FUOKTdfGWshpdhPqQdnVWksg26 HMk4WA13OpfYnztLpZHfhuE= X-Received: by 2002:a05:6402:1d90:b0:425:dd36:447c with SMTP id dk16-20020a0564021d9000b00425dd36447cmr13616178edb.347.1650976026463; Tue, 26 Apr 2022 05:27:06 -0700 (PDT) Received: from krava ([193.85.244.190]) by smtp.gmail.com with ESMTPSA id e26-20020a50a69a000000b00425c11446fasm5894150edc.3.2022.04.26.05.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 05:27:05 -0700 (PDT) Date: Tue, 26 Apr 2022 14:27:04 +0200 From: Jiri Olsa To: Masami Hiramatsu Cc: Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , netdev@vger.kernel.org, bpf@vger.kernel.org, lkml , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh Subject: Re: [PATCHv2 bpf-next 1/4] kallsyms: Add kallsyms_lookup_names function Message-ID: References: <20220418124834.829064-1-jolsa@kernel.org> <20220418124834.829064-2-jolsa@kernel.org> <20220418233546.dfe0a1be12193c26b05cdd93@kernel.org> <20220426190108.d9c76f5ccff52e27dbef21af@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220426190108.d9c76f5ccff52e27dbef21af@kernel.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 26, 2022 at 07:01:08PM +0900, Masami Hiramatsu wrote: > Hi Jiri, > > Sorry for replying late. > > On Fri, 22 Apr 2022 08:47:13 +0200 > Jiri Olsa wrote: > > > On Tue, Apr 19, 2022 at 10:26:05AM +0200, Jiri Olsa wrote: > > > > SNIP > > > > > > > +static int kallsyms_callback(void *data, const char *name, > > > > > + struct module *mod, unsigned long addr) > > > > > +{ > > > > > + struct kallsyms_data *args = data; > > > > > + > > > > > + if (!bsearch(&name, args->syms, args->cnt, sizeof(*args->syms), symbols_cmp)) > > > > > + return 0; > > > > > + > > > > > + addr = ftrace_location(addr); > > > > > + if (!addr) > > > > > + return 0; > > > > > > > > Ooops, wait. Did you do this last version? I missed this point. > > > > This changes the meanings of the kernel function. > > > > > > yes, it was there before ;-) and you're right.. so some archs can > > > return different address, I did not realize that > > > > > > > > > > > > + > > > > > + args->addrs[args->found++] = addr; > > > > > + return args->found == args->cnt ? 1 : 0; > > > > > +} > > > > > + > > > > > +/** > > > > > + * kallsyms_lookup_names - Lookup addresses for array of symbols > > > > > > > > More correctly "Lookup 'ftraced' addresses for array of sorted symbols", right? > > > > > > > > I'm not sure, we can call it as a 'kallsyms' API, since this is using > > > > kallsyms but doesn't return symbol address, but ftrace address. > > > > I think this name misleads user to expect returning symbol address. > > > > > > > > > + * > > > > > + * @syms: array of symbols pointers symbols to resolve, must be > > > > > + * alphabetically sorted > > > > > + * @cnt: number of symbols/addresses in @syms/@addrs arrays > > > > > + * @addrs: array for storing resulting addresses > > > > > + * > > > > > + * This function looks up addresses for array of symbols provided in > > > > > + * @syms array (must be alphabetically sorted) and stores them in > > > > > + * @addrs array, which needs to be big enough to store at least @cnt > > > > > + * addresses. > > > > > > > > Hmm, sorry I changed my mind. I rather like to expose kallsyms_on_each_symbol() > > > > and provide this API from fprobe or ftrace, because this returns ftrace address > > > > and thus this is only used from fprobe. > > > > > > ok, so how about: > > > > > > int ftrace_lookup_symbols(const char **sorted_syms, size_t cnt, unsigned long *addrs); > > > > quick question.. is it ok if it stays in kalsyms.c object? > > I think if this is for the ftrace API, I think it should be in the ftrace.c, and > it can remove unneeded #ifdefs in C code. > > > > > so we don't need to expose kallsyms_on_each_symbol, > > and it stays in 'kalsyms' place > > We don't need to expose it to modules, but just make it into a global scope. > I don't think that doesn't cause a problem. np, will move it to ftrace thanks, jirka