From nobody Tue Jan 10 23:39:53 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 4Ns6jm4mQLz2qp86 for ; Tue, 10 Jan 2023 23:39:56 +0000 (UTC) (envelope-from rob.fx907@gmail.com) Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) (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 4Ns6jm2tGNz3QyK for ; Tue, 10 Jan 2023 23:39:56 +0000 (UTC) (envelope-from rob.fx907@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-ej1-x636.google.com with SMTP id hw16so20887940ejc.10 for ; Tue, 10 Jan 2023 15:39:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iemIRVgn08nwebl8lm54yjwsDfrP4+FrfEtMa69nMUM=; b=LAmK5NH5V3fJPJNxtqail+gdq77gPVw4AZ22kdGCaOc8jij7oQTPMc+4cjhrwJhOfk FJb9CPJxgdSQMVo/+102ZNHYf7GihImpCCqG+fVaSkREihbUli3vvM55PJcf3R51pGlw /lFD3mRBsEq9EGpCRJtu/DG+WoOhKFhvr1ddaAZsEBKnxaH1qlbfnF0gtl95nk4fhS5o bSNph0U8sb/z53JE2r7MKhmFtyfGP0h8jD8ifg2wgkSMVSVJ2nh8m+W7JdmjystXsbyf tbtYCp7f3o8zMbzRAuEn9EdmCiYM3bN4CUExQFTbj264x9hqpzGCb1Z9iHY7TX+IsFaR WFVg== 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:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iemIRVgn08nwebl8lm54yjwsDfrP4+FrfEtMa69nMUM=; b=cAhzt36RXZAms2ZHBathR5YT1OLLI2ePNtedGfq/T/ZSVgU72XgpJ2kJJHsrAhzCfY +YDzQVjVCS4QPWZoQFll1KpAWRIn/lgI1nozk0zsgA+yS5PH/o5DX8c8UVqY0ets3TxS cB5G7lmE+IHcclGc8K7HU4uFJ668kte3Q2NHufNeyV4cdS5sHeM0+doPt4Ss52KPeUN6 xZyqcSAqaMfKS+sPcpW5a/I3fn6LXrkfYd+xL6eoReVQWOR8UwszC6dbT72u2Sqxb2B+ 5uDcxT9wzmuF0g0EQRDgFmGiYFUMXkYbCMxBLByvd8Qllajrm3jmaOSA3E+ovqXv36Ec 2gKw== X-Gm-Message-State: AFqh2krun3i03KwFfOan8QswziD6FpxgJquqjjh27lMEQAPKiyXrHsuT d2TVogHgMprQ30WgLQlpuNRSdgg3JFZbT7E7NEc= X-Google-Smtp-Source: AMrXdXsiEp6LzyAyPcnVZKQop0ITYjIetTqeyIyC4lwZB0wuAg354TLfYxyXs3UjZH88l+JLWIR4O72dpD3h0xEwi70= X-Received: by 2002:a17:906:e2c4:b0:829:e4f0:bf2b with SMTP id gr4-20020a170906e2c400b00829e4f0bf2bmr4708019ejb.389.1673393993908; Tue, 10 Jan 2023 15:39:53 -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 Received: by 2002:a17:906:f88c:b0:7c1:ed:5065 with HTTP; Tue, 10 Jan 2023 15:39:53 -0800 (PST) In-Reply-To: References: From: Rob Wing Date: Tue, 10 Jan 2023 14:39:53 -0900 Message-ID: Subject: Re: Syscalls: eventfd and timerfd To: Mateusz Guzik Cc: Jake Freeland , "freebsd-hackers@freebsd.org" Content-Type: multipart/alternative; boundary="00000000000093858505f1f16606" X-Rspamd-Queue-Id: 4Ns6jm2tGNz3QyK X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; TAGGED_FROM(0.00)[] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N --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 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 > > --00000000000093858505f1f16606 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable You might also be interested in checking out Brooks Davis' talk on addi= ng syscalls:




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:=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 "_= _specialfd",
=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_narg =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 = syscall
> 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>

--00000000000093858505f1f16606--