Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Jan 2023 14:39:53 -0900
From:      Rob Wing <rob.fx907@gmail.com>
To:        Mateusz Guzik <mjguzik@gmail.com>
Cc:        Jake Freeland <jake@technologyfriends.net>,  "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: Syscalls: eventfd and timerfd
Message-ID:  <CAF3%2Bn_f0DX=gfdbwDKTUB4SLACZa-RvYHm1MyrUU302xNmF%2Bpg@mail.gmail.com>
In-Reply-To: <CAGudoHHd%2BqixeXW_V3f4pXWG8-Bi6eAbUHBGY6033W8P-JBivA@mail.gmail.com>
References:  <CAOgZAGbK5H=JtxY7MZKyyXa=i=CXbYtV4tCOvg6N-CRYjqJ4fQ@mail.gmail.com> <CAGudoHHd%2BqixeXW_V3f4pXWG8-Bi6eAbUHBGY6033W8P-JBivA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--00000000000093858505f1f16606
Content-Type: text/plain; charset="UTF-8"

You might also be interested in checking out Brooks Davis' talk on adding
syscalls:

https://www.bsdcan.org/events/bsdcan_2022/sessions/session/73/slides/35/so-you-want-to-add-a-syscall.pdf

https://youtu.be/_5LF_0GIpi8



On Tuesday, January 10, 2023, Mateusz Guzik <mjguzik@gmail.com> wrote:

> It is added with a non-standard entry point.
>
> If you git log -p sys/kern/sys_eventfd.c you will see:
>
> commit 7a202823aa54ba18c485bdbcf355269bcfee1ab9
> Author: Konstantin Belousov <kib@FreeBSD.org>
> Date:   Wed Dec 23 16:14:04 2020 +0200
>
>     Expose eventfd in the native API/ABI using a new __specialfd syscall
>
> then if you git grep __specialfd:
> lib/libc/gen/eventfd.c: return (__sys___specialfd(SPECIALFD_EVENTFD,
> &args, sizeof(args)));
> lib/libc/include/libc_private.h:int             __sys___specialfd(int,
> const void *, __size_t);
> sys/compat/freebsd32/freebsd32_syscall.h:#define
> FREEBSD32_SYS___specialfd       577
> sys/compat/freebsd32/freebsd32_syscalls.c:      "__specialfd",
>          /* 577 = __specialfd */
> sys/compat/freebsd32/freebsd32_sysent.c:        { .sy_narg =
> AS(__specialfd_args), .sy_call = (sy_call_t *)sys___specialfd,
> .sy_auevent = AUE_SPECIALFD, .sy_flags = SYF_CAPENABLED, .sy_thrcnt =
> SY_THR_STATIC },    /* 577 = __specialfd */
> sys/compat/freebsd32/freebsd32_systrace_args.c: /* __specialfd */
> sys/compat/freebsd32/freebsd32_systrace_args.c:         struct
> __specialfd_args *p = params;
> sys/compat/freebsd32/freebsd32_systrace_args.c: /* __specialfd */
> sys/compat/freebsd32/freebsd32_systrace_args.c: /* __specialfd */
> sys/kern/init_sysent.c: { .sy_narg = AS(__specialfd_args), .sy_call =
> (sy_call_t *)sys___specialfd, .sy_auevent = AUE_SPECIALFD, .sy_flags =
> SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },    /* 577 = __specialfd
> */
> sys/kern/sys_generic.c:sys___specialfd(struct thread *td, struct
> __specialfd_args *args)
> sys/kern/syscalls.c:    "__specialfd",                  /* 577 =
> __specialfd */
> sys/kern/syscalls.master:               int __specialfd(
> sys/kern/systrace_args.c:       /* __specialfd */
> sys/kern/systrace_args.c:               struct __specialfd_args *p =
> params;
> sys/kern/systrace_args.c:       /* __specialfd */
> sys/kern/systrace_args.c:       /* __specialfd */
> sys/sys/syscall.h:#define       SYS___specialfd 577
> sys/sys/syscall.mk:     __specialfd.o \
> sys/sys/sysproto.h:struct __specialfd_args {
> sys/sys/sysproto.h:int  sys___specialfd(struct thread *, struct
> __specialfd_args *);
> sys/sys/sysproto.h:#define      SYS_AUE___specialfd     AUE_SPECIALFD
>
> On 1/11/23, Jake Freeland <jake@technologyfriends.net> wrote:
> > Hi there,
> >
> > I am currently working on moving the linux_compat implementation of
> > timerfd (in sys/compat/linux/linux_event.c) into its own FreeBSD syscall
> > similar to what was done for eventfd. This is my first time implementing
> > a syscall, so I have been following the eventfd implementation as a
> > reference. I noticed that the eventfd syscall entries are absent from
> > sys/kern/syscalls.master and I am not sure why. Was eventfd never
> > formally added as a syscall entry or am I missing something? I was
> > planning on adding timerfd entries to syscalls.master, but now I am
> > unsure how to proceed.
> >
> > I apologize for my ignorance. This process is new to me.
> >
> > Thank you,
> > Jake Freeland
> >
>
>
> --
> Mateusz Guzik <mjguzik gmail.com>
>
>

--00000000000093858505f1f16606
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

You might also be interested in checking out Brooks Davis&#39; talk on addi=
ng syscalls:<div><br></div><div><a href=3D"https://www.bsdcan.org/events/bs=
dcan_2022/sessions/session/73/slides/35/so-you-want-to-add-a-syscall.pdf">h=
ttps://www.bsdcan.org/events/bsdcan_2022/sessions/session/73/slides/35/so-y=
ou-want-to-add-a-syscall.pdf</a></div><div><br></div><div><p style=3D"margi=
n:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Hel=
vetica"><a href=3D"https://youtu.be/_5LF_0GIpi8">https://youtu.be/_5LF_0GIp=
i8</a></p></div><div><p style=3D"margin:0px;font-stretch:normal;font-size:1=
2px;line-height:normal;font-family:Helvetica"><br></p><p style=3D"margin:0p=
x;font-stretch:normal;font-size:12px;line-height:normal;font-family:Helveti=
ca"><br></p>On Tuesday, January 10, 2023, Mateusz Guzik &lt;<a href=3D"mail=
to:mjguzik@gmail.com">mjguzik@gmail.com</a>&gt; wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">It is added with a non-standard entry point.<br>
<br>
If you git log -p sys/kern/sys_eventfd.c you will see:<br>
<br>
commit 7a202823aa54ba18c485bdbcf35526<wbr>9bcfee1ab9<br>
Author: Konstantin Belousov &lt;kib@FreeBSD.org&gt;<br>
Date:=C2=A0 =C2=A0Wed Dec 23 16:14:04 2020 +0200<br>
<br>
=C2=A0 =C2=A0 Expose eventfd in the native API/ABI using a new __specialfd =
syscall<br>
<br>
then if you git grep __specialfd:<br>
lib/libc/gen/eventfd.c: return (__sys___specialfd(SPECIALFD_<wbr>EVENTFD,<b=
r>
&amp;args, sizeof(args)));<br>
lib/libc/include/libc_private.<wbr>h:int=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0__sys___specialfd(int,<br>
const void *, __size_t);<br>
sys/compat/freebsd32/<wbr>freebsd32_syscall.h:#define<br>
FREEBSD32_SYS___specialfd=C2=A0 =C2=A0 =C2=A0 =C2=A0577<br>
sys/compat/freebsd32/<wbr>freebsd32_syscalls.c:=C2=A0 =C2=A0 =C2=A0 &quot;_=
_specialfd&quot;,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* 577 =3D __specialfd */<br>
sys/compat/freebsd32/<wbr>freebsd32_sysent.c:=C2=A0 =C2=A0 =C2=A0 =C2=A0 { =
.sy_narg =3D<br>
AS(__specialfd_args), .sy_call =3D (sy_call_t *)sys___specialfd,<br>
.sy_auevent =3D AUE_SPECIALFD, .sy_flags =3D SYF_CAPENABLED, .sy_thrcnt =3D=
<br>
SY_THR_STATIC },=C2=A0 =C2=A0 /* 577 =3D __specialfd */<br>
sys/compat/freebsd32/<wbr>freebsd32_systrace_args.c: /* __specialfd */<br>
sys/compat/freebsd32/<wbr>freebsd32_systrace_args.c:=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0struct<br>
__specialfd_args *p =3D params;<br>
sys/compat/freebsd32/<wbr>freebsd32_systrace_args.c: /* __specialfd */<br>
sys/compat/freebsd32/<wbr>freebsd32_systrace_args.c: /* __specialfd */<br>
sys/kern/init_sysent.c: { .sy_narg =3D AS(__specialfd_args), .sy_call =3D<b=
r>
(sy_call_t *)sys___specialfd, .sy_auevent =3D AUE_SPECIALFD, .sy_flags =3D<=
br>
SYF_CAPENABLED, .sy_thrcnt =3D SY_THR_STATIC },=C2=A0 =C2=A0 /* 577 =3D __s=
pecialfd<br>
*/<br>
sys/kern/sys_generic.c:sys___<wbr>specialfd(struct thread *td, struct<br>
__specialfd_args *args)<br>
sys/kern/syscalls.c:=C2=A0 =C2=A0 &quot;__specialfd&quot;,=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* 577 =3D __specialfd */<br>
sys/kern/syscalls.master:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0int __specialfd(<br>
sys/kern/systrace_args.c:=C2=A0 =C2=A0 =C2=A0 =C2=A0/* __specialfd */<br>
sys/kern/systrace_args.c:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0struct __specialfd_args *p =3D params;<br>
sys/kern/systrace_args.c:=C2=A0 =C2=A0 =C2=A0 =C2=A0/* __specialfd */<br>
sys/kern/systrace_args.c:=C2=A0 =C2=A0 =C2=A0 =C2=A0/* __specialfd */<br>
sys/sys/syscall.h:#define=C2=A0 =C2=A0 =C2=A0 =C2=A0SYS___specialfd 577<br>
sys/sys/<a href=3D"http://syscall.mk" target=3D"_blank">syscall.mk</a>:=C2=
=A0 =C2=A0 =C2=A0__specialfd.o \<br>
sys/sys/sysproto.h:struct __specialfd_args {<br>
sys/sys/sysproto.h:int=C2=A0 sys___specialfd(struct thread *, struct<br>
__specialfd_args *);<br>
sys/sys/sysproto.h:#define=C2=A0 =C2=A0 =C2=A0 SYS_AUE___specialfd=C2=A0 =
=C2=A0 =C2=A0AUE_SPECIALFD<br>
<br>
On 1/11/23, Jake Freeland &lt;<a href=3D"mailto:jake@technologyfriends.net"=
>jake@technologyfriends.net</a>&gt; wrote:<br>
&gt; Hi there,<br>
&gt;<br>
&gt; I am currently working on moving the linux_compat implementation of<br=
>
&gt; timerfd (in sys/compat/linux/linux_event.<wbr>c) into its own FreeBSD =
syscall<br>
&gt; similar to what was done for eventfd. This is my first time implementi=
ng<br>
&gt; a syscall, so I have been following the eventfd implementation as a<br=
>
&gt; reference. I noticed that the eventfd syscall entries are absent from<=
br>
&gt; sys/kern/syscalls.master and I am not sure why. Was eventfd never<br>
&gt; formally added as a syscall entry or am I missing something? I was<br>
&gt; planning on adding timerfd entries to syscalls.master, but now I am<br=
>
&gt; unsure how to proceed.<br>
&gt;<br>
&gt; I apologize for my ignorance. This process is new to me.<br>
&gt;<br>
&gt; Thank you,<br>
&gt; Jake Freeland<br>
&gt;<br>
<br>
<br>
-- <br>
Mateusz Guzik &lt;mjguzik <a href=3D"http://gmail.com" target=3D"_blank">gm=
ail.com</a>&gt;<br>
<br>
</blockquote></div>

--00000000000093858505f1f16606--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAF3%2Bn_f0DX=gfdbwDKTUB4SLACZa-RvYHm1MyrUU302xNmF%2Bpg>