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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03A34C7618E for ; Fri, 21 Apr 2023 11:18:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229599AbjDULSk (ORCPT ); Fri, 21 Apr 2023 07:18:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229520AbjDULSk (ORCPT ); Fri, 21 Apr 2023 07:18:40 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8470010A for ; Fri, 21 Apr 2023 04:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682075876; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+a819jXQkhWrRCkf1kmbqhc9TRLDMyUVW4Zd+vmWTnQ=; b=PIA/Yz04iAhJbOzCPVnt8jz9/3y8JV7f0tQwceA+IMwvI9IzdQ1b+Xx9vFaUKkx75OcYnB QwdW9gS5GyBBvtky91+SAlxlN7PJvbE/rAom9V2sMtEYqvJvraqULR/su2xojXHOHKWPNt h3/7l9NFAU6O9Qvn02qSxEKYgFPgzK4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-gX2HJHduMuGATRoheuo5gQ-1; Fri, 21 Apr 2023 07:17:53 -0400 X-MC-Unique: gX2HJHduMuGATRoheuo5gQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6C0985A5A3; Fri, 21 Apr 2023 11:17:52 +0000 (UTC) Received: from astarta.redhat.com (unknown [10.39.192.158]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2CC04140EBF4; Fri, 21 Apr 2023 11:17:51 +0000 (UTC) From: Yauheni Kaliuta To: Alexei Starovoitov Cc: Yonghong Song , bpf , Artem Savkov , Viktor Malik , Jerome Marchand Subject: Re: sys_enter tracepoint ctx structure References: Date: Fri, 21 Apr 2023 14:17:49 +0300 In-Reply-To: (Alexei Starovoitov's message of "Thu, 20 Apr 2023 16:12:49 -0700") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Hi, Alexei! >>>>> On Thu, 20 Apr 2023 16:12:49 -0700, Alexei Starovoitov wrote: > On Thu, Apr 20, 2023 at 2:40=E2=80=AFPM Yauheni Kaliuta wrote: >> >>>>> On Thu, 20 Apr 2023 13:54:26 -0700, Alexei Starovoitov wrote: >> > On Thu, Apr 20, 2023 at 1:37=E2=80=AFPM Yauheni Kaliuta wrote: >> >> >>>>> On Thu, 20 Apr 2023 08:59:09 -0700, Alexei Starovoitov wrote: >> >> >> >> >> >> Should perf_call_bpf_enter/exit (kernel/trace/trace_syscalls.c) >> >> >> use struct trace_event_raw_sys_enter/exit instead of locally >> >> >> crafted struct syscall_tp_t nowadays? >> >> >> >> >> >> > No. It needs syscall_tp_t. >> >> >> >> > test_progs's vmlinux test >> >> >> expects it as the context. >> >> >> >> >> >> >> > what do you mean? Pls share a code pointer? >> >> >> >> https://github.com/torvalds/linux/blob/master/tools/testing/selftest= s/bpf/progs/test_vmlinux.c#L19 >> >> >> >> SEC("tp/syscalls/sys_enter_nanosleep") >> >> int handle__tp(struct trace_event_raw_sys_enter *args) >>=20 >> > I see. That bit is correct and that's what bpftrace is doing >> > when attaching to syscalls. >> > What do you see in your patched RT kernel when you do: >> > cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/for= mat >> > ? >> > Depending on the answer we might need to fix >> > the kernel side that has to use struct trace_entry >> > in syscall_tp_t instead of plain long long. >>=20 >> # cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/for= mat >> name: sys_enter_nanosleep >> ID: 374 >> format: >> field:unsigned short common_type; offset:0; size:2; signed:= 0; >> field:unsigned char common_flags; offset:2; size:1; signed:= 0; >> field:unsigned char common_preempt_count; offset:3; size:1;= signed:0; >> field:int common_pid; offset:4; size:4; signed:1; >> field:unsigned char common_preempt_lazy_count; offset:8; size:1;= signed:0; >>=20 >> field:int __syscall_nr; offset:12; size:4; signed:1; >> field:struct __kernel_timespec * rqtp; offset:16; size:8; signed:= 0; >> field:struct __kernel_timespec * rmtp; offset:24; size:8; signed:= 0; >>=20 >> print fmt: "rqtp: 0x%08lx, rmtp: 0x%08lx", ((unsigned long)(REC->rqtp))= , ((unsigned long)(REC->rmtp)) > Lol. > Jiri even fixed the issue with this format in bpftrace 3 years ago: > https://github.com/iovisor/bpftrace/commit/a2e3d5dbc03ceb49b776cf5602d31= 896158844a7 Hehe :) > Let's fix the kernel side too. Something like this should do it: > diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls= .c > index 942ddbdace4a..7aa1f4299486 100644 > --- a/kernel/trace/trace_syscalls.c > +++ b/kernel/trace/trace_syscalls.c > @@ -555,7 +555,7 @@ static int perf_call_bpf_enter(struct > trace_event_call *call, struct pt_regs *re > struct syscall_trace_enter *rec) > { > struct syscall_tp_t { > - unsigned long long regs; > + struct trace_entry ent; > unsigned long syscall_nr; > unsigned long args[SYSCALL_DEFINE_MAXARGS]; > } param; > @@ -657,7 +657,7 @@ static int perf_call_bpf_exit(struct > trace_event_call *call, struct pt_regs *reg > struct syscall_trace_exit *rec) > { > struct syscall_tp_t { > - unsigned long long regs; > + struct trace_entry ent; > pls add build_bug_on that sizeof(ent) >=3D sizeof(void*). Ok. Should the line *(struct pt_regs **)¶m =3D regs; be commented someh= ow? --=20 WBR, Yauheni Kaliuta