Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4442849ioa; Wed, 27 Apr 2022 04:06:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4J9SEi1JrFBiKLN6whaUuPhgfG0rjS6R0qwBObEWY+4M3VcrDOpkG/WXr2Co/nHsox+Xv X-Received: by 2002:a17:90b:33ca:b0:1d4:d5ab:40b0 with SMTP id lk10-20020a17090b33ca00b001d4d5ab40b0mr41076038pjb.96.1651057585400; Wed, 27 Apr 2022 04:06:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651057585; cv=none; d=google.com; s=arc-20160816; b=jms3Bl+Txl3BK05Hd9aeWV0spqEJhlto6wSN4ps+U1IQjcuEU4nBCP7z8qVufex8vU Ka+HQiPM0koPEP5VYseOFH1GijxPkm0GcG2VYsvKC2U4C/wQmUk0KUKECo+ITnBA5Xmw yQHTa8I8wWz9eBjYBay5yBw9pmCvBnMyVJTMbv3WQLNBdxbSIGExk9fJc1Jtz+i3EAzG N1WGhNLKbzLQC5bm1kpvusMVOtRr0xOZxouSKmSQu/q9HodkWBKUQQcjR0jJFIUikeYP ay/aQjQXa/MxK/BNRI5lU9tAFk/+K4stwvAzlmgJlefsN5EAR6CD/uVW3WhzjhKl5eV5 6ujA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=dEo2+y/8qjx1fIDeaMOdpV+AtGBaU1LQ3xaIslxvit0=; b=cAIBE4aGy/6ee9O4HXn58HCNPYdxEv7y/kaKfxtwmjwfiQWFRvAAvAm5juH4FAAV10 01tHsX0nbkN/mrTGmh6SRS5lXGJ+90HqMJa/Ck6l430MOMFFmvOE2VjOxKK+qQ5uMQiI 5I2M1Win4v1DqVA/kn1gvTeSRFOAGifq2zEDHj+lt6id+r5UoLrOWEyKPvnjMq3Khzbi /SbQK29tFE5FqoKZd1zReNOrgfCsVYbnl2Unw6YCRnic6etAbNokPNdmqstgzWUfnQR4 1DB8gtwjPa1CiCr9GfOsxwkdrGjGQiCqELUEJWUD7qyQadcL48IfZ87pn2VriUv5ggQh mkhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OF7ff69a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z7-20020a17090abd8700b001c64f3d4750si4914412pjr.161.2022.04.27.04.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:06:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OF7ff69a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 298E32D2EB5; Wed, 27 Apr 2022 03:00:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352796AbiDZQHT (ORCPT + 99 others); Tue, 26 Apr 2022 12:07:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237871AbiDZQHO (ORCPT ); Tue, 26 Apr 2022 12:07:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DA91434AA; Tue, 26 Apr 2022 09:04:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F3EFA61A59; Tue, 26 Apr 2022 16:04:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94823C385AA; Tue, 26 Apr 2022 16:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650989045; bh=69jqnS80ls4U/ADxnP7PEc7prC9IyzE3eMxJZnp7tAU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=OF7ff69aH9WhWwYQqzv8Ol92hHSgQ1EBu3+vmSaVHUEhT5CXy6BJoKpnIuYAhOrt8 W1+kix+7UbGMbEfZgWHap4qIKIRg2Ye6XkwFsUB7ytq8MkxS6U4QjlimKB3EUaL4Tl lG+o75zjCy5+kHsfpGM/hBJukTZGFs1jaomfDgYBY1Kv33I3gF4Y/h2hmu16YG4tOI kHd3BWsSDlq/XDUcjLKqULgQd/YhY8S2ZqFQGnW6NepUoyoYTx17eDXhJL7t6mPl// V69PmgBM9PsxdttsmpNYPouZkSizbbwh7Uo5h5cBqpGePVXkk9IKXAYus5nAM8w29n A7gpRf/DVOB8Q== Date: Wed, 27 Apr 2022 01:03:59 +0900 From: Masami Hiramatsu To: Jiri Olsa 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: <20220427010359.8400f28813c1ffc62af2ae2b@kernel.org> In-Reply-To: References: <20220418124834.829064-1-jolsa@kernel.org> <20220418124834.829064-2-jolsa@kernel.org> <20220418233546.dfe0a1be12193c26b05cdd93@kernel.org> <20220426190108.d9c76f5ccff52e27dbef21af@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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, 26 Apr 2022 14:27:04 +0200 Jiri Olsa wrote: > 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. Oops, I meant "I don't think that cause any problem." > > np, will move it to ftrace Thank you! > > thanks, > jirka -- Masami Hiramatsu