From nobody Sat Oct 15 21:55:30 2022 X-Original-To: freebsd-questions@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 4MqcWg2ZPgz4fpgf for ; Sat, 15 Oct 2022 21:55:43 +0000 (UTC) (envelope-from yaroslaw.mashko@gmail.com) Received: from mail-vs1-xe32.google.com (mail-vs1-xe32.google.com [IPv6:2607:f8b0:4864:20::e32]) (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 4MqcWf2Z8Lz3J0g for ; Sat, 15 Oct 2022 21:55:42 +0000 (UTC) (envelope-from yaroslaw.mashko@gmail.com) Received: by mail-vs1-xe32.google.com with SMTP id k6so8202928vsc.8 for ; Sat, 15 Oct 2022 14:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=cdmd1FG4fTEb5eKCfr/W97tYIihNcJf34/PlG06UHas=; b=e321gp5Ht7ZduifFRCrwvya/MK7Veg0MF6xNlwiXC1WjuB7rzkFdlF8iX2BOcFqQML jEwY5g1sTDAmIsan60kNrNBqFOFGr5WzZ6+b9e+RAjJGd0i7lss2JkxaqAdK2AIPsvrx CJYrymfSEvaqJyI3Ujmu6Sf5qbEcpaNfo4EEm1FP5yRcHDdIWZbREthLah32T6vYyGhn SATHyf4Xo6auGofP8UnS+/cpwguz8FzvxvQ80QxWl+jXEUukM5HlCqnZjq1e+nCa8kVk PUCYBixIm/ZlGU/ntK1li0WQPSZl/EeBCMnLNZhGkYcvU4iv5VZenPQq1zZWw3h40nDK YZqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=cdmd1FG4fTEb5eKCfr/W97tYIihNcJf34/PlG06UHas=; b=s7k2BjRaJGYqWJ9UTOEIaxVW0Bta0AILTPWf1U2t6Y5CyQbVObpiYYJfzMLL8f+XRl 4+GnZiYaARmtg4A94QY4Ujq8eeB2ksbiXbe09zPpRHAQyiK4LqMD/UKwnbjgGQscNZ4W z6kWHjmN4mpyxLWL0BsMvmjqSx6Z35au3RocgXiKotf1LDL/YQIxJUpym0SAs/3gVSij purLyoAV6zzeNWZ2Szwk2mVVYqfDeVt0bG+fJYa8tlEWxewASBPZJ0vEIU5qOLpnA+SL 7EiCZSZumdCgM8Ku4U/0/XkFkaVp3KacoeQROdjsibkaFGNrw+lAztAk4ePu4dadZPu+ UydA== X-Gm-Message-State: ACrzQf1HePVcAfA9Ka8Fs832LS69Ma0TWVmW+X33IZSkPe4cksUevTxq JPsgN+jLwQCRzKleSrxdvUJW8E0XER7ZsjHwtppkX/C99PAI/A== X-Google-Smtp-Source: AMsMyM6yboN7n5YsyC9OQdsxS/6O1jQ5P5D+mhBpmqhx0HqO12DxARjZYXX8S0RyEV4SlDUOy4EoUcgAiDP405kOx+0= X-Received: by 2002:a67:a24e:0:b0:3a5:38a0:b610 with SMTP id t14-20020a67a24e000000b003a538a0b610mr1575936vsh.2.1665870941611; Sat, 15 Oct 2022 14:55:41 -0700 (PDT) List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 From: =?UTF-8?B?0K/RgNC+0YHQu9Cw0LIg0JzQsNGI0LrQvg==?= Date: Sun, 16 Oct 2022 00:55:30 +0300 Message-ID: Subject: clarification on kqueue kernel event flags. To: freebsd-questions@freebsd.org Content-Type: multipart/alternative; boundary="000000000000b76a3e05eb19cd12" X-Rspamd-Queue-Id: 4MqcWf2Z8Lz3J0g X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=e321gp5H; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of yaroslaw.mashko@gmail.com designates 2607:f8b0:4864:20::e32 as permitted sender) smtp.mailfrom=yaroslaw.mashko@gmail.com X-Spamd-Result: default: False [-3.48 / 15.00]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_LONG(-0.48)[-0.479]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; RCPT_COUNT_ONE(0.00)[1]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::e32:from]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; TAGGED_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; MID_RHS_MATCH_FROMTLD(0.00)[]; TO_DN_NONE(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; MLMMJ_DEST(0.00)[freebsd-questions@freebsd.org]; DKIM_TRACE(0.00)[gmail.com:+]; RCVD_TLS_LAST(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N --000000000000b76a3e05eb19cd12 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, I got confused with EV_CLEAR flag. Some code follows. kev.ident =3D 1; kev.filter =3D EVFILT_TIMER; kev.flags =3D EV_ADD | EV_DISPATCH; kev.data =3D 4; kev.fflags =3D NOTE_SECONDS; l_reg_ev: status =3D kevent(kq, &kev, 1, NULL, 0, NULL); for(;;){ status =3D kevent(kq, NULL, 0, &kev, 1, NULL); kev.flags =3D EV_ENABLE; goto l_reg_ev; } This prints the series of: id : 1 > flags : EV_DISPATCH EV_CLEAR > filter : EVFILT_TIMER > data : # times timeout has expired since last kevent call: 1 > The "man kevent", the EV_CLEAR section says that: > After the event is retrieved by the user, its state is reset. > What I expect is that after the first goto, the EV_DISPATCH flag gets cleared. What does "the state" mean in the above? More specifically, what exactly EV_CLEAR changes with any combination of flags and filters? P.S. I did read a source code for "/sys/kern/kern_event.c". My brain fails to understand it as a whole, so, please be easy on me. --=20 =D0=AF=D1=80=D0=BE=D1=81=D0=BB=D0=B0=D0=B2 =D0=9C=D0=B0=D1=88=D0=BA=D0=BE +380 50 56 75 347 <+380+50+56+75+347> --000000000000b76a3e05eb19cd12 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

I got confused with E= V_CLEAR flag. Some code follows.

=C2=A0 kev.ident = =C2=A0=3D 1;
=C2=A0 kev.filter =3D EVFILT_TIMER;
=C2=A0 kev.flags =C2= =A0=3D EV_ADD | EV_DISPATCH;
=C2=A0 kev.data =C2=A0 =3D 4;
=C2=A0 kev= .fflags =3D NOTE_SECONDS;

=C2=A0l_reg_ev:
=C2=A0 status =3D kevent(kq, &kev, 1, NULL, 0, NULL);

<= /div>
=C2=A0 for(;;){
=C2=A0=C2=A0 status =3D kevent(kq, NULL= , 0, &kev, 1, NULL);
=C2=A0=C2=A0 kev.flags =3D EV_ENABLE;
=C2=A0=C2=A0 goto l_reg_ev;
=C2=A0 }

=
This prints the series of:

id =C2=A0 =C2=A0 =C2=A0: =C2=A01
flags= =C2=A0 : =C2=A0EV_DISPATCH EV_CLEAR
filter =C2=A0: =C2=A0EVFILT_TIMER=
data =C2=A0 =C2=A0: =C2=A0# times timeout has expired since last keven= t call: 1
=C2=A0
The "man kevent&= quot;, the EV_CLEAR section says that:
After the event is retrieved by the user, its = state is reset.

What I expect is that= after the first goto, the EV_DISPATCH flag gets cleared. What does "t= he state" mean in the above?
More specifically, what exactly= EV_CLEAR changes with any combination of flags and filters?

=
P.S.
I did read a source code for "/sys/kern/= kern_event.c". My brain fails to understand it as a whole, so, please = be easy on me.

--
=D0=AF=D1=80=D0=BE=D1=81=D0=BB=D0=B0= =D0=B2 =D0=9C=D0=B0=D1=88=D0=BA=D0=BE
--000000000000b76a3e05eb19cd12--