From nobody Tue Jan 10 23:42:12 2023 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Ns6mg36BXz2qpDG for ; Tue, 10 Jan 2023 23:42:27 +0000 (UTC) (envelope-from jake@technologyfriends.net) Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ns6mf3pG7z3jJq for ; Tue, 10 Jan 2023 23:42:26 +0000 (UTC) (envelope-from jake@technologyfriends.net) Authentication-Results: mx1.freebsd.org; dkim=none ("invalid DKIM record") header.d=technologyfriends.net header.s=google header.b=QbtjnMNp; spf=none (mx1.freebsd.org: domain of jake@technologyfriends.net has no SPF policy when checking 2a00:1450:4864:20::22c) smtp.mailfrom=jake@technologyfriends.net; dmarc=none Received: by mail-lj1-x22c.google.com with SMTP id n5so13765677ljc.9 for ; Tue, 10 Jan 2023 15:42:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=technologyfriends.net; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=LNAXbODrT1PLBhDZU5zn6S+aHHeTO/xW4SeTjopbOic=; b=QbtjnMNpugYdkb6DqqZuZNEhe1G3W6jcBz8DHOtPkpsLHMUAlXego46fI/yzr58y/s s7AIMk8rvcqvGwjggFLq8JoGNcqLOHGvYqWmYQC8+5V0ZShsUKRxnEoXUOMeMRHX9RT8 SZklQ3QxM5/d4zNPV7ZpfmF8mgvgNE9evSKu87x0LKA5reUWaqJz0GGl04jzgxY2rKP1 N54kR0+0KZORwe8It1CPqd6PmgY7UNjehRFsZwYidGMprtFAAmWRaK/CagcH4sjfW33I eRJ4Q5NRmWy3X2VGPAyOGyqW4aYWdzgSzQQlfmm3cDF9tR2jBypCip/Wl9lPl7dhuXsv mbkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LNAXbODrT1PLBhDZU5zn6S+aHHeTO/xW4SeTjopbOic=; b=pSeykTwR5I1o7MyYjq2s4fNqIsiAGFf0G0KD8AuLM/ItCM3k/QXVEHOzfDBAUhskXI VGiOiY0mOKAJpOumWY93CBKJK3vWzSXnwUzSY3GBFggRLdn88rNocl3NuTN5+SD1IUZX +FtS2szUnaQGJjdbIC3cW75U5idHyTn1Ev882k0FkUdYqWslRxze7G6WdXlffZ39MXHO lxEKqPauOiCnjc+oEpzp+R2iY42xzCsh3LT1/ITG8vxp4oG7vjGNlTotGbWWHi6hVBO3 ULIRDMPPPOub5YJ+UynJied/2lXe1qHQ/4QiCTAFfd78GNEJ5Uzo5jaa7frVH8EdBWa9 VX8g== X-Gm-Message-State: AFqh2krPenInZdHk5twiP61bw/tEFcpF8kFC6Pqp1xybJd7NH96X1s7M /1nyHOc6uhfKwLkILyWb6g9r9DfWeIFX8eWMNgKlHw== X-Google-Smtp-Source: AMrXdXvD0yXl6dp1UlJTtycc0xaKYpbo2/nY1RY09N4ZyXbJ3qNrx1L6GsMjWzUoi/+3EiHl9DLxym7yG5nfXmIfpY4= X-Received: by 2002:a2e:8e3b:0:b0:280:4f2:700a with SMTP id r27-20020a2e8e3b000000b0028004f2700amr2080504ljk.364.1673394143602; Tue, 10 Jan 2023 15:42:23 -0800 (PST) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: Jake Freeland Date: Tue, 10 Jan 2023 17:42:12 -0600 Message-ID: Subject: Re: Syscalls: eventfd and timerfd To: Rob Wing Cc: Mateusz Guzik , "freebsd-hackers@freebsd.org" Content-Type: multipart/alternative; boundary="0000000000007fc69505f1f16f79" X-Spamd-Result: default: False [-2.10 / 15.00]; AUTH_NA_OR_FAIL(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.999]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; TAGGED_RCPT(0.00)[]; DMARC_NA(0.00)[technologyfriends.net]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; R_DKIM_PERMFAIL(0.00)[technologyfriends.net:s=google]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::22c:from]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org]; R_SPF_NA(0.00)[no SPF record]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_HAS_DN(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[technologyfriends.net:~]; TO_DN_SOME(0.00)[]; FREEMAIL_CC(0.00)[gmail.com,freebsd.org]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_TLS_LAST(0.00)[]; FREEFALL_USER(0.00)[jake]; ARC_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-Rspamd-Queue-Id: 4Ns6mf3pG7z3jJq X-Spamd-Bar: -- X-ThisMailContainsUnwantedMimeParts: N --0000000000007fc69505f1f16f79 Content-Type: text/plain; charset="UTF-8" On Tue, Jan 10, 2023 at 5:39 PM Rob Wing 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 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 >> 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 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 >> >> --0000000000007fc69505f1f16f79 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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:
=


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

Jake Freeland
=C2=A0



On Tuesday, January 10, 2023, Mateusz Guzik <mjguzik@gmail.com> wrote= :
It is added with a n= on-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:=C2=A0 =C2=A0Wed Dec 23 16:14:04 2020 +0200

=C2=A0 =C2=A0 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=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0__sys___specialfd(int,
const void *, __size_t);
sys/compat/freebsd32/freebsd32_syscall.h:#define
FREEBSD32_SYS___specialfd=C2=A0 =C2=A0 =C2=A0 =C2=A0577
sys/compat/freebsd32/freebsd32_syscalls.c:=C2=A0 =C2=A0 =C2=A0 "__spec= ialfd",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* 577 =3D __specialfd */
sys/compat/freebsd32/freebsd32_sysent.c:=C2=A0 =C2=A0 =C2=A0 =C2=A0 { .sy_n= arg =3D
AS(__specialfd_args), .sy_call =3D (sy_call_t *)sys___specialfd,
.sy_auevent =3D AUE_SPECIALFD, .sy_flags =3D SYF_CAPENABLED, .sy_thrcnt =3D=
SY_THR_STATIC },=C2=A0 =C2=A0 /* 577 =3D __specialfd */
sys/compat/freebsd32/freebsd32_systrace_args.c: /* __specialfd */
sys/compat/freebsd32/freebsd32_systrace_args.c:=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0struct
__specialfd_args *p =3D params;
sys/compat/freebsd32/freebsd32_systrace_args.c: /* __specialfd */
sys/compat/freebsd32/freebsd32_systrace_args.c: /* __specialfd */
sys/kern/init_sysent.c: { .sy_narg =3D AS(__specialfd_args), .sy_call =3D (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
*/
sys/kern/sys_generic.c:sys___specialfd(struct thread *td, struct
__specialfd_args *args)
sys/kern/syscalls.c:=C2=A0 =C2=A0 "__specialfd",=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* 577 =3D __specialfd */
sys/kern/syscalls.master:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0int __specialfd(
sys/kern/systrace_args.c:=C2=A0 =C2=A0 =C2=A0 =C2=A0/* __specialfd */
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;
sys/kern/systrace_args.c:=C2=A0 =C2=A0 =C2=A0 =C2=A0/* __specialfd */
sys/kern/systrace_args.c:=C2=A0 =C2=A0 =C2=A0 =C2=A0/* __specialfd */
sys/sys/syscall.h:#define=C2=A0 =C2=A0 =C2=A0 =C2=A0SYS___specialfd 577
sys/sys/syscall.mk:=C2= =A0 =C2=A0 =C2=A0__specialfd.o \
sys/sys/sysproto.h:struct __specialfd_args {
sys/sys/sysproto.h:int=C2=A0 sys___specialfd(struct thread *, struct
__specialfd_args *);
sys/sys/sysproto.h:#define=C2=A0 =C2=A0 =C2=A0 SYS_AUE___specialfd=C2=A0 = =C2=A0 =C2=A0AUE_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 sysca= ll
> similar to what was done for eventfd. This is my first time implementi= ng
> a syscall, so I have been following the eventfd implementation as a > reference. I noticed that the eventfd syscall entries are absent from<= br> > 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 gm= ail.com>

--0000000000007fc69505f1f16f79--