Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4776478pxb; Tue, 25 Jan 2022 19:18:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHs5B34pBLgDIjbLXG7jyT/kpobtfzi3TC2UkSEs2E5exp85lcdAfMX3sP+jH83hG+xOsL X-Received: by 2002:a17:907:d8c:: with SMTP id go12mr17057504ejc.430.1643167121293; Tue, 25 Jan 2022 19:18:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643167121; cv=none; d=google.com; s=arc-20160816; b=JQh/HR/ItxZoY9TBH8fIi0ACbtbt4r1bRNxfv6s5sKlfKcPnjPXWhumOrbKGXG9fZ+ OiutHPCw28xd3fIkk18o5k47v6e2ar3XcEiw5To2P+wTE/36X6hxv7i6Zi1bhjWF8Y5r ttn2Dn0/39LjjjvNVS7INfFx9Qu/gaJAgy5aByD2NYCV2suQu5wzAbOjidRI6iL+3tTT 81XZobOwcKG3BSCvJCI+8KAAMeg5f2vOdZe9GQ9sp5vSUShfEiq219M0tqi85JfQuTmp xNy0kMsSjLNXj+2QR72zPn63xl+fbGmbfTJUYuINF+wqZM+0PDkQPqDkFK54NqwB8nwc BYpQ== 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=ZYZFcKeTPsQCFaSsqNlB8G3oqmreXQCJIoK82/wxEkU=; b=rPbmuvIhF+e1WH1hkIQ98mOGoUv8hlL9uSp7Hgsfxpdu2aHVPPUzHd1BvO1luV1VYS QyMlFBiexk2viV0VRbiwyIpO3VyWkp3hIc+QZn0tcKa8Q1cbZHn63uU2gyz21pvrZCEV hN3PGNem0Onj/YVswNMbiuLHjyHSRcuZwa0lHbTEcYcLWZctXewT8fYyDFkCk4N0laRq NPpGz+9OE4Duaw/7nY47nqG7dqSgoxcWBiZvvpHu2un+/swIutKIqcOta5L6BusjK3et nIFogTkJGRD3/nBjFJgremjTsLOxkXLLEZIB3ST8aajcDHwGNLA7xoSbQtNAtkOdC9UC WMrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XEI8APwO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fy1si12158292ejc.72.2022.01.25.19.18.17; Tue, 25 Jan 2022 19:18:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XEI8APwO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234359AbiAYSMD (ORCPT + 99 others); Tue, 25 Jan 2022 13:12:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36106 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234038AbiAYSL7 (ORCPT ); Tue, 25 Jan 2022 13:11:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643134318; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZYZFcKeTPsQCFaSsqNlB8G3oqmreXQCJIoK82/wxEkU=; b=XEI8APwOLMstwDfrWdiGxohk0Tj8iYSCVRKmV+JMtqSXFTuhnopJyp3loDxYaHHf8o6WO3 zXkPX9jUNBdvt/mZ5qSie953p3xwpFT67vrMTvNMTWIr8HrCqg8yCIjR4ZExKqYfBDjcK3 WoGPRhqRNFS9hfmvU8oHnW67UDy54qE= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-522-LX73ie07OE-z8NKud-CURg-1; Tue, 25 Jan 2022 13:11:56 -0500 X-MC-Unique: LX73ie07OE-z8NKud-CURg-1 Received: by mail-ej1-f69.google.com with SMTP id v2-20020a170906292200b006a94a27f903so3781951ejd.8 for ; Tue, 25 Jan 2022 10:11:56 -0800 (PST) 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=ZYZFcKeTPsQCFaSsqNlB8G3oqmreXQCJIoK82/wxEkU=; b=KS68YnZ8Fx6kiTay/fmCTijkvy0RBmtpw7MiXZF3ErO+rysM0UhmIVQgtEbFu+F3gN dPoXQ8UXop7v6l5WjB+UAPAcYTHJnshHH8n07dlsNP+oaoExySm08Fqj3isG5Sm3AgIU jqbq0EQgRDlmTJ5IjGmuh7dOk4OgzoEDmHC0qZzPQ50VIw6oHDfqZ5CV6zO0hdPo35EU Z8g0pgyCbduyo+epTTt10TUkhc48R7oi3mT/VyXmmwG03lENdsW+Iku7xTZfUP2MUCQG M1rNyyXtjlGjEU5IvF0++n7PrhaDwH/JYzWLqsTu8Sul7ewc96uEhOwAMLswLKwbF9fK ZjyA== X-Gm-Message-State: AOAM530N9MJ51uxQeH0Vu98/9jXgjRezaX6H0Mya0QxsSFp/xVaDs62a RvBXF41pv2ikYJuuiyQFK8fn7tJMxFtZLBVN7A6307dNCZcdBiuVv3bvP4cBdNAvFj1RcVNjo9z ajEndir3vlLPhFA3HOPGoOaYW X-Received: by 2002:a17:907:9605:: with SMTP id gb5mr17348662ejc.685.1643134315388; Tue, 25 Jan 2022 10:11:55 -0800 (PST) X-Received: by 2002:a17:907:9605:: with SMTP id gb5mr17348639ejc.685.1643134315151; Tue, 25 Jan 2022 10:11:55 -0800 (PST) Received: from krava (nat-pool-brq-u.redhat.com. [213.175.37.12]) by smtp.gmail.com with ESMTPSA id k7sm6425341ejp.182.2022.01.25.10.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 10:11:54 -0800 (PST) Date: Tue, 25 Jan 2022 19:11:52 +0100 From: Jiri Olsa To: Masami Hiramatsu Cc: 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 , Steven Rostedt , "Naveen N . Rao" , Anil S Keshavamurthy , "David S . Miller" Subject: Re: [PATCH v5 2/9] fprobe: Add ftrace based probe APIs Message-ID: References: <164311269435.1933078.6963769885544050138.stgit@devnote2> <164311271777.1933078.9066058105807126444.stgit@devnote2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 25, 2022 at 05:41:24PM +0100, Jiri Olsa wrote: > On Tue, Jan 25, 2022 at 09:11:57PM +0900, Masami Hiramatsu wrote: > > SNIP > > > + > > +/* Convert ftrace location address from symbols */ > > +static int convert_func_addresses(struct fprobe *fp) > > +{ > > + unsigned long addr, size; > > + unsigned int i; > > + > > + /* Convert symbols to symbol address */ > > + if (fp->syms) { > > + fp->addrs = kcalloc(fp->nentry, sizeof(*fp->addrs), GFP_KERNEL); > > + if (!fp->addrs) > > + return -ENOMEM; > > + > > + for (i = 0; i < fp->nentry; i++) { > > + fp->addrs[i] = kallsyms_lookup_name(fp->syms[i]); > > + if (!fp->addrs[i]) /* Maybe wrong symbol */ > > + goto error; > > + } > > + } > > + > > + /* Convert symbol address to ftrace location. */ > > + for (i = 0; i < fp->nentry; i++) { > > + if (!kallsyms_lookup_size_offset(fp->addrs[i], &size, NULL)) > > + size = MCOUNT_INSN_SIZE; > > + addr = ftrace_location_range(fp->addrs[i], fp->addrs[i] + size); > > you need to substract 1 from 'end' in here, as explained in > __within_notrace_func comment: > > /* > * Since ftrace_location_range() does inclusive range check, we need > * to subtract 1 byte from the end address. > */ > > like in the patch below > > also this convert is for archs where address from kallsyms does not match > the real attach addresss, like for arm you mentioned earlier, right? > > could we have that arch specific, so we don't have extra heavy search > loop for archs that do not need it? one more question.. I'm adding support for user to pass function symbols to bpf fprobe link and I thought I'd pass symbols array to register_fprobe, but I'd need to copy the whole array of strings from user space first, which could take lot of memory considering attachment of 10k+ functions so I'm thinking better way is to resolve symbols already in bpf fprobe link code and pass just addresses to register_fprobe I assume you want to keep symbol interface, right? could we have some flag ensuring the conversion code is skipped, so we don't go through it twice? in any case I need addresses before I call register_fprobe, because of the bpf cookies setup thanks, jirka