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

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

On Tue, Jan 10, 2023 at 5:39 PM Rob Wing <rob.fx907@gmail.com> wrote:

> 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
>

I must've missed this when trying to find documentation on this topic.
Thanks for recommending this. I'll give it a watch.

Jake Freeland


>
>
> 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>
>>
>>

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

<div dir=3D"ltr"><div dir=3D"ltr"></div><div class=3D"gmail_quote"><div dir=
=3D"ltr" class=3D"gmail_attr">On Tue, Jan 10, 2023 at 5:39 PM Rob Wing &lt;=
<a href=3D"mailto:rob.fx907@gmail.com">rob.fx907@gmail.com</a>&gt; wrote:<b=
r></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex=
;border-left:1px solid rgb(204,204,204);padding-left:1ex">You might also be=
 interested in checking out Brooks Davis&#39; talk on adding syscalls:<div>=
<br></div><div><a href=3D"https://www.bsdcan.org/events/bsdcan_2022/session=
s/session/73/slides/35/so-you-want-to-add-a-syscall.pdf" target=3D"_blank">=
https://www.bsdcan.org/events/bsdcan_2022/sessions/session/73/slides/35/so-=
you-want-to-add-a-syscall.pdf</a></div><div><br></div><div><p style=3D"marg=
in:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:He=
lvetica"><a href=3D"https://youtu.be/_5LF_0GIpi8" target=3D"_blank">https:/=
/youtu.be/_5LF_0GIpi8</a></p></div></blockquote><div><br></div><div>I must&=
#39;ve missed this when trying to find documentation on this topic.</div><d=
iv>Thanks for recommending this. I&#39;ll give it a watch.</div><div><br></=
div><div>Jake Freeland</div><div>=C2=A0</div><blockquote class=3D"gmail_quo=
te" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204=
);padding-left:1ex"><div><p style=3D"margin:0px;font-stretch:normal;font-si=
ze:12px;line-height:normal;font-family:Helvetica"><br></p><p style=3D"margi=
n:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Hel=
vetica"><br></p>On Tuesday, January 10, 2023, Mateusz Guzik &lt;<a href=3D"=
mailto:mjguzik@gmail.com" target=3D"_blank">mjguzik@gmail.com</a>&gt; wrote=
:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bo=
rder-left:1px solid rgb(204,204,204);padding-left:1ex">It is added with a n=
on-standard entry point.<br>
<br>
If you git log -p sys/kern/sys_eventfd.c you will see:<br>
<br>
commit 7a202823aa54ba18c485bdbcf355269bcfee1ab9<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_EVENTFD,<br>
&amp;args, sizeof(args)));<br>
lib/libc/include/libc_private.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/freebsd32_syscall.h:#define<br>
FREEBSD32_SYS___specialfd=C2=A0 =C2=A0 =C2=A0 =C2=A0577<br>
sys/compat/freebsd32/freebsd32_syscalls.c:=C2=A0 =C2=A0 =C2=A0 &quot;__spec=
ialfd&quot;,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* 577 =3D __specialfd */<br>
sys/compat/freebsd32/freebsd32_sysent.c:=C2=A0 =C2=A0 =C2=A0 =C2=A0 { .sy_n=
arg =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/freebsd32_systrace_args.c: /* __specialfd */<br>
sys/compat/freebsd32/freebsd32_systrace_args.c:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0struct<br>
__specialfd_args *p =3D params;<br>
sys/compat/freebsd32/freebsd32_systrace_args.c: /* __specialfd */<br>
sys/compat/freebsd32/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___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"=
 target=3D"_blank">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.c) into its own FreeBSD sysca=
ll<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>
</blockquote></div></div>

--0000000000007fc69505f1f16f79--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOgZAGYZYEp42usEfqvkG5ZUdMTYLwBkC8UJ6ibBCpMFGv11Kw>