From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 492E4C433E0 for ; Wed, 5 Aug 2020 21:01:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26D4F21D95 for ; Wed, 5 Aug 2020 21:01:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KFyN3Mfa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725920AbgHEVBX (ORCPT ); Wed, 5 Aug 2020 17:01:23 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:38281 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726224AbgHEVBU (ORCPT ); Wed, 5 Aug 2020 17:01:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596661279; 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=AwlhS9A6gXAAkqCmgiXaqnLD4HXkSIN9WLGrUCy1lAs=; b=KFyN3MfaNRpSLDcyu2Ubm/BeGUg7K6/usRlkgR1906iy/2bMs+6WjFUUL6KLqpGFksOji1 kDcceFiIhdQgBBuO7raeXbwWdoCjlDWX2yARopID0IsGGphIKHgBiBT2eOmc5QWBM0WyUZ rSHMnYFZ05P5YeIUHr+/RpMgEDc7iMc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-75-NwTBjdllMtOzSlQa0ra2Nw-1; Wed, 05 Aug 2020 17:01:14 -0400 X-MC-Unique: NwTBjdllMtOzSlQa0ra2Nw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 51BC1100AA22; Wed, 5 Aug 2020 21:01:12 +0000 (UTC) Received: from krava (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with SMTP id A597A5F9DB; Wed, 5 Aug 2020 21:01:07 +0000 (UTC) Date: Wed, 5 Aug 2020 23:01:01 +0200 From: Jiri Olsa To: Andrii Nakryiko Cc: Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Networking , bpf , Song Liu , Yonghong Song , Martin KaFai Lau , David Miller , John Fastabend , Wenbo Zhang , KP Singh , Brendan Gregg , Florent Revest , Al Viro Subject: Re: [PATCH v9 bpf-next 10/14] bpf: Add d_path helper Message-ID: <20200805210101.GF319954@krava> References: <20200801170322.75218-1-jolsa@kernel.org> <20200801170322.75218-11-jolsa@kernel.org> <20200805175850.GD319954@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200805175850.GD319954@krava> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Wed, Aug 05, 2020 at 07:58:54PM +0200, Jiri Olsa wrote: > On Tue, Aug 04, 2020 at 11:35:53PM -0700, Andrii Nakryiko wrote: > > On Sat, Aug 1, 2020 at 10:04 AM Jiri Olsa wrote: > > > > > > Adding d_path helper function that returns full path for > > > given 'struct path' object, which needs to be the kernel > > > BTF 'path' object. The path is returned in buffer provided > > > 'buf' of size 'sz' and is zero terminated. > > > > > > bpf_d_path(&file->f_path, buf, size); > > > > > > The helper calls directly d_path function, so there's only > > > limited set of function it can be called from. Adding just > > > very modest set for the start. > > > > > > Updating also bpf.h tools uapi header and adding 'path' to > > > bpf_helpers_doc.py script. > > > > > > Signed-off-by: Jiri Olsa > > > --- > > > include/uapi/linux/bpf.h | 13 +++++++++ > > > kernel/trace/bpf_trace.c | 48 ++++++++++++++++++++++++++++++++++ > > > scripts/bpf_helpers_doc.py | 2 ++ > > > tools/include/uapi/linux/bpf.h | 13 +++++++++ > > > 4 files changed, 76 insertions(+) > > > > > > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > > > index eb5e0c38eb2c..a356ea1357bf 100644 > > > --- a/include/uapi/linux/bpf.h > > > +++ b/include/uapi/linux/bpf.h > > > @@ -3389,6 +3389,18 @@ union bpf_attr { > > > * A non-negative value equal to or less than *size* on success, > > > * or a negative error in case of failure. > > > * > > > + * int bpf_d_path(struct path *path, char *buf, u32 sz) > > > > nit: probably would be good to do `const struct path *` here, even if > > we don't do const-ification properly in all helpers. hum, for this I need to update scripts/bpf_helpers_doc.py and it looks like it's not ready for const struct yet: CLNG-LLC [test_maps] get_cgroup_id_kern.o In file included from progs/test_lwt_ip_encap.c:7: In file included from /home/jolsa/linux/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:11: /home/jolsa/linux/tools/testing/selftests/bpf/tools/include/bpf/bpf_helper_defs.h:32:1: warning: 'const' ignored on this declaration [-Wmissing-declarations] const struct path; ^ would it be ok as a follow up change? I'll need to check on bpf_helpers_doc.py script first jirka