Simplify filt_pipedetach()

2020-12-10 Thread Visa Hankala
filt_pipedetach() can be simplified a bit by using kn_hook to point to the pipe. This additionally lets the system fully remove elements from the knote lists. Previously, the write-side list just vanished when the peer was closed. OK? Index: kern/sys_pipe.c ===

Lock operations for knote lists

2020-12-11 Thread Visa Hankala
This patch extends struct klist with a callback descriptor and an argument. The main purpose of this is to let the kqueue subsystem assert when a klist should be locked, and operate the klist lock in klist_invalidate(). Access to a knote list of a kqueue-monitored object has to be serialized someh

Re: Switch select(2) to kqueue-based implementation

2020-12-12 Thread Visa Hankala
On Fri, Dec 11, 2020 at 09:35:59AM -0300, Martin Pieuchot wrote: > On 10/12/20(Thu) 09:59, Martin Pieuchot wrote: > > All previous kqueue refactoring have been committed, here's a final diff > > to modify the internal implementation of {p,}select(2) to query kqfilter > > handlers instead of poll on

Re: Switch select(2) to kqueue-based implementation

2020-12-13 Thread Visa Hankala
On Sat, Dec 12, 2020 at 11:29:02AM +, Visa Hankala wrote: > On Fri, Dec 11, 2020 at 09:35:59AM -0300, Martin Pieuchot wrote: > > +/* > > + * Convert given kqueue event into corresponding select(2) bit. > > + */ > > +int > > +pselcollect(struct proc *p, stru

Re: rw_lock_held() & friends

2020-12-14 Thread Visa Hankala
On Mon, Dec 14, 2020 at 10:59:05AM -0300, Martin Pieuchot wrote: > On 08/12/20(Tue) 14:39, Visa Hankala wrote: > > On Mon, Dec 07, 2020 at 03:25:00PM -0300, Martin Pieuchot wrote: > > > Simple diff below to add the rw_lock_held() as well as a read & write > > > versi

Remove variable count from kqueue_scan()

2020-12-14 Thread Visa Hankala
In function kqueue_scan(), variables count and nkev follow relation count + nkev == maxevents. The code becomes a bit simpler if count is removed. OK? Index: kern/kern_event.c === RCS file: src/sys/kern/kern_event.c,v retrieving revi

Re: Switch select(2) to kqueue-based implementation

2020-12-15 Thread Visa Hankala
On Tue, Dec 15, 2020 at 07:46:01AM -0300, Martin Pieuchot wrote: > @@ -636,43 +651,59 @@ dopselect(struct proc *p, int nd, fd_set > if (sigmask) > dosigsuspend(p, *sigmask &~ sigcantmask); > > -retry: > - ncoll = nselcoll; > - atomic_setbits_int(&p->p_flag, P_SELECT);

Re: Lock operations for knote lists

2020-12-15 Thread Visa Hankala
On Tue, Dec 15, 2020 at 09:58:16AM -0300, Martin Pieuchot wrote: > On 11/12/20(Fri) 17:37, Visa Hankala wrote: > > Index: kern/kern_event.c > > === > > RCS file: src/sys/kern/kern_event.c,v > > retrieving re

Re: Switch select(2) to kqueue-based implementation

2020-12-16 Thread Visa Hankala
On Tue, Dec 15, 2020 at 05:23:45PM +, Visa Hankala wrote: > On Tue, Dec 15, 2020 at 07:46:01AM -0300, Martin Pieuchot wrote: > > @@ -636,43 +651,59 @@ dopselect(struct proc *p, int nd, fd_set > > if (sigmask) > > dosigsuspend(p, *sigmask &~ sigca

Force knote state update in klist_invalidate()

2020-12-21 Thread Visa Hankala
There is a slight inconsistency in klist_invalidate(). If the knote is already in the event queue and has flag EV_ONESHOT, kqueue_scan() will not invoke the newly set f_event. In this case, the kevent(2) system call will return the knote's original event state that no longer reflects the state that

Re: Force knote state update in klist_invalidate()

2020-12-22 Thread Visa Hankala
On Mon, Dec 21, 2020 at 04:51:45PM -0300, Martin Pieuchot wrote: > On 21/12/20(Mon) 16:45, Visa Hankala wrote: > > There is a slight inconsistency in klist_invalidate(). If the knote is > > already in the event queue and has flag EV_ONESHOT, kqueue_scan() will > > not invoke

kqueue_scan() should not return EWOULDBLOCK

2020-12-22 Thread Visa Hankala
This fixes a recent regression in kqueue_scan() where the function can mistakenly return EWOULDBLOCK. Currently, kqueue_scan() does one more scan attempt after a timeout. Usually, this gives no new events and the function bails out through the following code. Note that it clears `error'.

Refactor klist insertion and removal

2020-12-23 Thread Visa Hankala
The following diff: * renames existing functions klist_insert() and klist_remove() to klist_insert_locked() and klist_remove_locked(), respectively. These functions expect that the caller has acquired the klist lock. * adds new functions klist_insert() and klist_remove() that acquire the kl

Set klist lock for pipes

2020-12-25 Thread Visa Hankala
This patch makes pipes use the pipe pair lock instead of the kernel lock for pipe klist serialization. In pipe_kqfilter(), the pipe pair lock is already held, so it is appropriate to keep on using klist_insert_locked() there. filt_pipedetach(), on the other hand, can be shortened by using klist_re

Clean up parameters of pselrecord()

2020-12-25 Thread Visa Hankala
The following diff cleans up the parameters of pselregister(), making its parameter use similar to that of pselcollect(). In addition, this removes from pselregister() the assumption that all the fd_set kinds are in one continuous array. OK? Index: kern/sys_generic.c =

Revise fd close notification for kqueue-based select(2) and poll(2)

2020-12-27 Thread Visa Hankala
This patch revises the way how kqueue notifies select(2) about the closing of monitored file descriptors. Instead of returning EBADF through kqueue_scan(), the error is conveyed in struct kevent. This is excessive for select(2) but should be useful with kqueue-based poll(2). The idea is the follow

Re: Revise fd close notification for kqueue-based select(2) and poll(2)

2020-12-28 Thread Visa Hankala
On Sun, Dec 27, 2020 at 05:09:46PM +, Visa Hankala wrote: > This patch revises the way how kqueue notifies select(2) about the > closing of monitored file descriptors. Instead of returning EBADF through > kqueue_scan(), the error is conveyed in struct kevent. This is excessive >

Re: Make kernel recognize more Lynloong models

2021-01-02 Thread Visa Hankala
On Sat, Jan 02, 2021 at 12:06:57PM +, Yifei ZHAN wrote: > Hi, > > The following patch will make kernel recognize Lynloong LM9002/9003 and > LM9013. I think LM9002/9003 is very similar to LM9001 since it works just > fine on my LM9002 with the codebase for LM9001. (Maybe they are just a > di

Re: Fix display resolution for Lynloong machines

2021-01-02 Thread Visa Hankala
On Sat, Jan 02, 2021 at 12:39:49PM +, Yifei ZHAN wrote: > > Hi, > > > > The following patch will set the display resolution to 1368x768 for > > Lynloong all-in-one computers, which is their native resolution. Currently > > their resolution is being set to 1024x600 which prevents the screen f

Set klist lock for sockets

2021-01-05 Thread Visa Hankala
This diff sets klist lock for sockets. Since sockets use custom lock functions, the diff introduces socket_klistops for use with the klist interface. In soo_kqfilter(), the diff adds socket locking for accessing so_options and changing the klist. The patch replaces the use of the SB_KNOTE flag wi

Re: all platforms: isolate hardclock(9) from statclock()

2021-01-09 Thread Visa Hankala
On Fri, Jan 08, 2021 at 10:18:27AM -0600, Scott Cheloha wrote: > On Thu, Jan 07, 2021 at 08:12:10PM -0600, Scott Cheloha wrote: > > On Thu, Jan 07, 2021 at 09:37:58PM +0100, Mark Kettenis wrote: > > > > Date: Thu, 7 Jan 2021 11:15:41 -0600 > > > > From: Scott Cheloha > > > > > > > > Hi, > > > >

Re: loongson.html: update link for PMON repository

2021-01-16 Thread Visa Hankala
On Fri, Jan 15, 2021 at 12:53:35AM +, Yifei ZHAN wrote: > The following patch will update the link for PMON on loongson.html. The > existing site for PMON seems to be abandoned now and development of pmon > on loongson continues in Loongnix's git repository. Thanks, I have updated the link.

Re: Update model and resolution details for Loongson Lynloong

2021-01-16 Thread Visa Hankala
On Fri, Jan 15, 2021 at 01:38:14AM +, Yifei ZHAN wrote: > The following patches will update the hardware note file and loongson.html > with the corrent screen resolution and model details for Loongson > Lynloong. Thanks, committed with a rewrapped line in loongson.html. > Index: distrib/not

Re: 68.html: fix typo

2021-01-16 Thread Visa Hankala
On Fri, Jan 15, 2021 at 01:56:19AM +, Yifei ZHAN wrote: > I spotted a typo in www/68.html and this patch will fix it. Committed, thanks. > Index: 68.html > === > RCS file: /cvs/www/68.html,v > retrieving revision 1.85 > diff -u -

Re: all platforms: isolate hardclock(9) from statclock()

2021-01-16 Thread Visa Hankala
On Thu, Jan 14, 2021 at 12:46:38PM -0600, Scott Cheloha wrote: > Still need tests on these platforms: > > - alpha > - i386 > - mips64 (octeon will be sufficient) > - sgi > - sh Tested sys/kern/kern_clock.c and sys/arch/mips64/mips64/clock.c on loongson (also arch/loongson/dev/glxclk.c), octeon an

Extend struct filterops

2021-01-25 Thread Visa Hankala
This patch modifies the filterops callback interface so that it becomes easier to use with fine-grained locking. The current code is an entanglement of accesses to various data. Some items are more or less controlled by kqueue, while some others are more or less under the control of event sources.

Remove obsolete vnode opv declarations

2021-02-01 Thread Visa Hankala
This removes obsolete vnode operation vector declarations from header . The functions were removed in r1.28 of vfs_init.c. OK? Index: sys/systm.h === RCS file: src/sys/sys/systm.h,v retrieving revision 1.150 diff -u -p -r1.150 systm.

Re: rw_enter_diag() vs WITNESS

2021-02-15 Thread Visa Hankala
On Mon, Feb 15, 2021 at 11:37:45AM +0100, Martin Pieuchot wrote: > Diagnostic function rw_enter_diag() should be called before > WITNESS_CHECKORDER() to have proper locking/debugging information. > > In the case of 'locking against myself' it is currently impossible > to know where the lock has be

Re: rw_enter_diag() vs WITNESS

2021-02-16 Thread Visa Hankala
On Tue, Feb 16, 2021 at 10:07:27AM +0100, Martin Pieuchot wrote: > On 15/02/21(Mon) 16:58, Visa Hankala wrote: > > On Mon, Feb 15, 2021 at 11:37:45AM +0100, Martin Pieuchot wrote: > > > Diagnostic function rw_enter_diag() should be called before > > > WITNESS_CHECKORD

Re: [OpenBSD -current] Change event timer in main loop with kqueue

2021-02-27 Thread Visa Hankala
Moving to tech@. On Fri, Feb 26, 2021 at 09:42:07PM +0100, martin mag wrote: > I've been trying to use kqueue for the last couple of day but I keep > having an issue with EVFILT_TIMER filter. (I'm running Openbsd > -current) > > Right now, I'm trying to do the following: > 1) Initilialize a timer

Re: [OpenBSD -current] Change event timer in main loop with kqueue

2021-03-01 Thread Visa Hankala
On Sun, Feb 28, 2021 at 03:36:59PM +0100, martin mag wrote: > Visa Hankala wrote (patch truncated): > > The kernel does not reschedule the timer when the user changes the > > timeout period. The new period will take effect only after the current > > period has expired. Thi

Re: syslogd kernel timestamp

2021-03-21 Thread Visa Hankala
On Thu, Mar 18, 2021 at 05:57:45PM +0100, Alexander Bluhm wrote: > Since we stash log messages in the kernel, the timestamps added by > syslogd are delayed. The kernel could add the timestamp when it > receives the message by sendsyslog(2). This is more precise and > can be expressed by more digi

Re: [OpenBSD -current] Change event timer in main loop with kqueue

2021-03-21 Thread Visa Hankala
On Sat, Feb 27, 2021 at 01:36:29PM +, Visa Hankala wrote: > The kernel does not reschedule the timer when the user changes the > timeout period. The new period will take effect only after the current > period has expired. This is not explained in the manual page, though. > >

Enable libz when ddb is enabled

2021-03-30 Thread Visa Hankala
The addition of CTF handling has made ddb depend on libz. Listing this dependency would make it easier to build a RAMDISK with the debugger. OK? Index: conf/files === RCS file: src/sys/conf/files,v retrieving revision 1.699 diff -u -

Re: ddb: show all mounts: honour softdep

2021-04-05 Thread Visa Hankala
On Sun, Apr 04, 2021 at 11:56:57PM +0200, Klemens Nanni wrote: > ddb> show all mounts > mountpoint 0x800c8000 > flags 4205800 > vnodecovered 0x0 syncer 0xfd801f247a98 data 0x80087800 > vfsconf: ops 0x812ec530 name "ffs" num 1 ref 1 flags 0x2

Re: ddb: show all mounts: honour softdep

2021-04-06 Thread Visa Hankala
On Mon, Apr 05, 2021 at 06:01:42PM +0200, Klemens Nanni wrote: > On Mon, Apr 05, 2021 at 07:47:40AM +0000, Visa Hankala wrote: > > On Sun, Apr 04, 2021 at 11:56:57PM +0200, Klemens Nanni wrote: > > > ddb> show all mounts > > > mountpoint 0x8000

Allocate if_index before queue init

2022-07-16 Thread Visa Hankala
The index of a network interface is assigned in if_idxmap_insert(). ifq_init() and ifiq_init() use if_index before it has its final value. As a consequence, interfaces tend to use net_tq(0) as their first softnet task queue even though the other softnet task queues could be used as well. To fix thi

Remove nselcoll from vmstat(8) output

2022-07-25 Thread Visa Hankala
Remove the obsolete "select collisions" count from vmstat(8) output. Also, remove the reference of the now-nonexistent kernel variable "nselcoll", and terminate the name list with a NULL as required by kvm_nlist(3). OK? Index: vmstat.c

More splbio() with struct vnode

2022-07-26 Thread Visa Hankala
This diff puts more fields of struct vnode under splbio(). splbio() looks necessary with the fields that are modified through the buffer cache because the access can happen in an interrupt context. Wrapping LIST_EMPTY() with splbio() is probably overzealous. However, the added splbio() calls might

Re: randomise arc4random() rekey interval

2022-07-29 Thread Visa Hankala
On Thu, Jul 28, 2022 at 11:00:12AM +1000, Damien Miller wrote: > + rs->rs_count = REKEY_BASE; > + /* rekey interval should not be predictable */ > + _rs_random_u32(&rekey_fuzz); > + rs->rs_count += rekey_fuzz % REKEY_BASE; The randomization looks good. However, might it cause a pr

Re: randomise arc4random() rekey interval

2022-07-29 Thread Visa Hankala
On Fri, Jul 29, 2022 at 06:56:08AM -0600, Theo de Raadt wrote: > Visa Hankala wrote: > > > On Thu, Jul 28, 2022 at 11:00:12AM +1000, Damien Miller wrote: > > > + rs->rs_count = REKEY_BASE; > > > + /* rekey interval should not be predictable */ > > >

Re: randomise arc4random() rekey interval

2022-07-30 Thread Visa Hankala
On Sat, Jul 30, 2022 at 06:40:21PM +1000, Damien Miller wrote: > On Fri, 29 Jul 2022, Theo de Raadt wrote: > > > The question is what _rs_random_u32() will do when it calls > > _rs_stir_if_needed(). > > > > There is one potential problem. lib/libcrypto/arc4random/*.h contains > > portable wrappers

Re: mips64: trigger deferred timer interrupt from splx(9)

2022-08-07 Thread Visa Hankala
On Sun, Jul 31, 2022 at 01:28:18PM -0500, Scott Cheloha wrote: > Apparently mips64, i.e. octeon and loongson, has the same problem as > powerpc/macppc and powerpc64. The timer interrupt is normally only > logically masked, not physically masked in the hardware, when we're > running at or above IPL

Re: mips64: trigger deferred timer interrupt from splx(9)

2022-08-09 Thread Visa Hankala
On Mon, Aug 08, 2022 at 02:52:37AM -0500, Scott Cheloha wrote: > One thing I'm still uncertain about is how glxclk fits into the > loongson picture. It's an interrupt clock that runs hardclock() and > statclock(), but the code doesn't do any logical masking, so I don't > know whether or not I need

Re: Use SMR instead of SRP list in rtsock.c

2022-08-10 Thread Visa Hankala
On Wed, Aug 10, 2022 at 11:08:06AM +0200, Claudio Jeker wrote: > On Fri, Jul 01, 2022 at 04:03:21PM +0000, Visa Hankala wrote: > > On Fri, Jul 01, 2022 at 09:59:11AM +0200, Claudio Jeker wrote: > > > On Thu, Jun 30, 2022 at 03:46:35PM +, Visa Hankala wrote: > > > &

Remove unneeded kern.nselcoll sysctl

2022-08-14 Thread Visa Hankala
Remove unneeded kern.nselcoll sysctl. The last use of this sysctl in base was removed over two weeks ago. Debian Code Search does not show any uses of the KERN_NSELCOLL macro. OK? Index: lib/libc/sys/sysctl.2 === RCS file: src/lib/l

Remove kqueue-related trace points from poll(2) and select(2)

2022-08-14 Thread Visa Hankala
kqueue-based poll(2) and select(2) seem to work fairly well. Because of this, the ktrace points that display the internal translated events do not appear very valuable any longer. They clog up and make traces difficult to read. I think it is time to remove the trace points. OK? Index: sys/kern/sy

Re: mips64: trigger deferred timer interrupt from splx(9)

2022-08-17 Thread Visa Hankala
On Tue, Aug 09, 2022 at 09:54:02AM -0500, Scott Cheloha wrote: > On Tue, Aug 09, 2022 at 02:03:31PM +0000, Visa Hankala wrote: > > On Mon, Aug 08, 2022 at 02:52:37AM -0500, Scott Cheloha wrote: > > > One thing I'm still uncertain about is how glxclk fits into the > >

Re: mips64: trigger deferred timer interrupt from splx(9)

2022-08-18 Thread Visa Hankala
On Wed, Aug 17, 2022 at 11:42:50AM -0500, Scott Cheloha wrote: > On Wed, Aug 17, 2022 at 01:30:29PM +0000, Visa Hankala wrote: > > On Tue, Aug 09, 2022 at 09:54:02AM -0500, Scott Cheloha wrote: > > > On Tue, Aug 09, 2022 at 02:03:31PM +, Visa Hankala wrote: > > > &

Re: mips64: trigger deferred timer interrupt from splx(9)

2022-08-18 Thread Visa Hankala
On Thu, Aug 18, 2022 at 02:33:55PM +, Miod Vallat wrote: > > After about 92 hours, one machine showed cp0_raise_calls=622486 and > > another 695892. cp0_raise_miss was zero on both of them. On two other > > machines I had forgotten to allow ddb access from console and could > > not check the va

Re: EVFILT_TIMER add support for different timer precisions NOTE_{,U,N,M}SECONDS

2022-09-10 Thread Visa Hankala
On Wed, Aug 31, 2022 at 04:48:37PM -0400, aisha wrote: > I've added a patch which adds support for NOTE_{,U,M,N}SECONDS for > EVFILT_TIMER in the kqueue interface. It sort of makes sense to add an option to specify timeouts in sub-millisecond precision. It feels complete overengineering to add mul

Re: replace SRP with SMR in the if_idxmap commit

2022-11-10 Thread Visa Hankala
On Thu, Nov 10, 2022 at 11:59:02PM +1000, David Gwynne wrote: > On Thu, Nov 10, 2022 at 09:04:22PM +1000, David Gwynne wrote: > > On Thu, Nov 10, 2022 at 08:10:35AM +1000, David Gwynne wrote: > > > I know what this is. The barrier at the end of if_idxmap_alloc is > > > sleeping waiting for cpus to

Re: mips64, loongson, octeon: switch to clockintr(9)

2022-11-14 Thread Visa Hankala
On Sun, Nov 06, 2022 at 07:48:09PM +, Scott Cheloha wrote: > This patch switches loongson and octeon to clockintr(9). > > It has survived several release builds and upgrades from the resulting > bsd.rd images on my ER-4. The ER-4 doesn't have enough RAM to crunch a > parallel release build.

Re: mips64, loongson, octeon: switch to clockintr(9)

2022-11-16 Thread Visa Hankala
On Wed, Nov 16, 2022 at 07:00:23AM -0600, Scott Cheloha wrote: > On Mon, Nov 14, 2022 at 05:19:17PM +0000, Visa Hankala wrote: > > I think this clockintr_init() should be in cp0_startclock(). This would > > let other clock drivers do their own adjusting of the hz variables >

Re: Microsoft Surface: replace umstc(4) with ucc(4)

2022-11-19 Thread Visa Hankala
On Fri, Nov 18, 2022 at 11:03:06AM -0500, Dave Voutila wrote: > That fixes booting and the Surface Keyboard is usable, but I'm getting > spurious faults coming from retpoline out of filt_wseventdetach if I > detach and reattach the Surface Keyboard multiple times while running > Xorg. > > It's not

Remove unnecessary NOWITNESS kludge

2023-07-04 Thread Visa Hankala
Initialize stack-based mutexed using mtx_init(). This removes the need of the NOWITNESS kludge and lets the lock checker do its job with these mutexes. At the moment, static initialization of locks inside functions does not work correctly with WITNESS. A lock initializer sets up a struct that gets

Re: glxclk(4/loongson): remove driver

2023-07-05 Thread Visa Hankala
On Wed, Jul 05, 2023 at 09:39:00PM -0500, Scott Cheloha wrote: > glxclk(4) has been compiled-but-disabled for over six months. It was > disabled when loongson made the clockintr switch. Nobody has asked me > to make it an intrclock option for loongson so I assume the mips64 CP0 > interrupt clock

Re: smr_grace_wait(): Skip halted CPUs

2023-08-12 Thread Visa Hankala
On Fri, Aug 11, 2023 at 09:52:15PM +0200, Martin Pieuchot wrote: > When stopping a machine, with "halt -p" for example, secondary CPUs are > removed from the scheduler before smr_flush() is called. So there's no > need for the SMR thread to peg itself to such CPUs. This currently > isn't a proble

Re: smr_grace_wait(): Skip halted CPUs

2023-08-12 Thread Visa Hankala
On Sat, Aug 12, 2023 at 01:29:10PM +0200, Martin Pieuchot wrote: > On 12/08/23(Sat) 10:57, Visa Hankala wrote: > > On Fri, Aug 11, 2023 at 09:52:15PM +0200, Martin Pieuchot wrote: > > > When stopping a machine, with "halt -p" for example, secondary CPUs are > > &

Re: smr_grace_wait(): Skip halted CPUs

2023-08-13 Thread Visa Hankala
On Sat, Aug 12, 2023 at 02:40:31PM +0200, Martin Pieuchot wrote: > So do we want to keep the existing requirement of being able to execute > a thread on a CPU that has been removed from the scheduler? That's is > what smr_flush() currently needs. I find it surprising but I can add > that as a req

kqueue(2) and close-on-exec

2023-08-13 Thread Visa Hankala
FreeBSD and NetBSD have variants of the kqueue(2) system call that allow setting the close-on-exec flag on the returned file descriptor. In general, I think it is good that the flag can be set atomically for new descriptors. However, it seems to me that it is almost surely a mistake if a kqueue de

Re: kqueue(2) and close-on-exec

2023-08-14 Thread Visa Hankala
RCS file: regress/sys/kern/kqueue/kqueue-exec.c diff -N regress/sys/kern/kqueue/kqueue-exec.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/sys/kern/kqueue/kqueue-exec.c 14 Aug 2023 14:52:43 - @@ -0,0 +1,113 @@ +/* $OpenBSD$ */ + +/* + * Copyright (c) 2023 Visa Hankala + *

Re: prevent re-upgrade in powerpc64 boot loader

2023-09-24 Thread Visa Hankala
ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#define CMD_BUFF_SIZE 133 -#define BOOTDEVLEN 1024 - -struct cmd_table { - char *cmd_name; - char cmd_type; -#define CMDT_CMD 0 -#define CMDT_VAR 1 -#define CMDT_SET 2 -#define CMDT_MDC 3 - int (*cmd_ex

Re: Please test; midi(4): make midi{read,write}_filtops mp safe

2023-09-24 Thread Visa Hankala
On Sun, Sep 24, 2023 at 11:03:54PM +0300, Vitaliy Makkoveev wrote: > Please test this diff, I have no midi(4) devices. > > midi(4) already uses `audio_lock' mutex(9) for filterops, but they are > still kernel locked. Wipe out old selwakeup API and make them MP safe. > knote_locked(9) will not grab

Fix a panic with unlocked soclose()

2020-03-11 Thread Visa Hankala
jcs@ has reported the following panic which started appearing as a consequence of the recent file close unlocking: panic: kernel diagnostic assertion "timo || _kernel_lock_held()" failed: file "/usr/src/sys/kern/kern_synch.c", line 123 panic __assert tsleep usbd_transfer usbd_do_request_flags ur

Fix tsleep(9) during execve(2)

2020-03-21 Thread Visa Hankala
The recent change of initializing sls_sig = 0 in sleep_setup() (r1.164 of kern_synch.c) has introduced a regression with execve(2). execve(2) sets the current process in single thread mode for replacing the program image. In this mode, sleep_setup_signal() cancels a sleep, making tsleep(9) with PCA

Check ktrstart() error in doktrace()

2020-03-21 Thread Visa Hankala
This diff makes doktrace() check the outcome of ktrstart() and skip tracing if the trace file header cannot be written. OK? Index: kern/kern_ktrace.c === RCS file: src/sys/kern/kern_ktrace.c,v retrieving revision 1.101 diff -u -p -r1

Avoid selwakeup() in kqueue_wakeup()

2020-04-02 Thread Visa Hankala
selwakeup(sip) calls KNOTE(&sip->si_note, 0), which implies that kqueue_wakeup() should not call selwakeup() directly. Otherwise, a contrived program can trigger deep recursion. The diff below moves selwakeup() from kqueue_wakeup() to kqueue_task(). In addition to preventing the recursion, this ch

Constify pledgenames[]

2020-04-03 Thread Visa Hankala
This diff makes pledgenames[] const. OK? Index: sys/kern/kern_pledge.c === RCS file: src/sys/kern/kern_pledge.c,v retrieving revision 1.261 diff -u -p -r1.261 kern_pledge.c --- sys/kern/kern_pledge.c 15 Feb 2020 09:35:48 -

Change knote list head type

2020-04-04 Thread Visa Hankala
Below is a mostly mechanical patch that wraps the SLIST head of knotes inside another struct. The patch also introduces functions for adding and removing knotes from these lists. My intent is to extend the list struct so that the system can assert when the knote list should be locked. The idea is

Fix error path of VOP_IOCTL() in sr_hotspare()

2020-04-05 Thread Visa Hankala
In sr_hotspare(), the error path of VOP_IOCTL() appears to do a redundant VOP_CLOSE() and vput(). The diff below fixes that. The fail branch will close the vnode because `open' is true. OK? Index: dev/softraid.c === RCS file: src/sys

Re: Simplify NET_LOCK() variations

2020-04-12 Thread Visa Hankala
On Sun, Apr 12, 2020 at 03:26:14PM +0200, Martin Pieuchot wrote: > The existing variations of the NET_LOCK() macros are confusing. We're > now all aware of this fact. So let's keep them simple to prevent future > mistakes :) > > The diff below reduces the current set of methods to the following:

stacktrace_save() sync

2020-04-15 Thread Visa Hankala
This diff: * upgrades stacktrace_save() to stacktrace_save_at() if the latter is missing on the architecture, * defines stacktrace_save() as an inline function in to replace MD definitions. OK? Index: arch/amd64/amd64/db_trace.c ==

Struct for kqueue scan state

2020-04-20 Thread Visa Hankala
This diff introduces a struct for kqueue scan state. It eases making scans piecewise by keeping track of the scan's end point. The end point prevents the scan from recollecting events that are already being reported to the userspace. Below is an overview of the goal. It is achieved by combining th

Convert octrtc(4) to use

2020-05-18 Thread Visa Hankala
This diff converts octrtc(4) to use the interface, to reduce use of . Some highlights for reviewing: * dt.dt_year contains the actual year, while tt->year has base 1900. * dt.dt_wday uses range 0-6, whereas tt->dow's range is 1-7. * octrtc_gettime() no longer extracts day of week because clock

Remove sparc64 mutex.S

2020-05-18 Thread Visa Hankala
sparc64 has used the MI mutex since year 2018. However, the MD code still exists. The diff below removes it. OK? Index: arch/sparc64/sparc64/mutex.S === RCS file: arch/sparc64/sparc64/mutex.S diff -N arch/sparc64/sparc64/mutex.S ---

Update stale comment in

2020-05-20 Thread Visa Hankala
The header contains an outdated comment about headers and and should be updated. The comment is not fully consistent with the syslog(3) manual page because the manual does mention . However, the header's point still seems valid. OK? Index: sys/syslog.h

Retire

2020-05-23 Thread Visa Hankala
The header is not used any longer. Consequently, it should be safe to remove the following files: sys/arch/alpha/include/varargs.h sys/arch/hppa/include/varargs.h sys/arch/i386/include/varargs.h sys/arch/landisk/include/varargs.h sys/arch/loongson/include/varargs.h sys/arch/luna88k/include/vararg

Re: Kill NFS-only kqueue poller thread

2020-05-30 Thread Visa Hankala
On Thu, May 28, 2020 at 12:11:20PM +0200, Martin Pieuchot wrote: > When it comes to kqueue filters NFS is special. A custom thread is > created when the first event is registered. Its purpose is to poll > for changes every 2.5sec. This logic has been inherited from NetBSD > and is not present in

Outdated BUGS section in kqueue.2

2020-05-30 Thread Visa Hankala
The BUGS section in kqueue.2 is outdated. The FIFO limitation does not seem to exist anymore, AIO is not implemented at all in the kernel, and watching vnodes looks possible on all filesystem types that allow writing. OK to remove the section? Index: kqueue.2 =

Re: Kill NFS-only kqueue poller thread

2020-05-30 Thread Visa Hankala
On Sat, May 30, 2020 at 03:34:06PM +0200, Martin Pieuchot wrote: > On 30/05/20(Sat) 09:22, Visa Hankala wrote: > > On Thu, May 28, 2020 at 12:11:20PM +0200, Martin Pieuchot wrote: > > > When it comes to kqueue filters NFS is special. A custom thread is > > > crea

Re: Kill NFS-only kqueue poller thread

2020-05-31 Thread Visa Hankala
On Sun, May 31, 2020 at 09:40:47AM +0200, Martin Pieuchot wrote: > On 30/05/20(Sat) 15:49, Visa Hankala wrote: > > [...] > > Local filesystems can observe changes at the source, which makes polling > > unnecessary. NFS clients do not have that benefit. The NFSv3 protocol >

Call FRELE() without fdplock in dup*(2)

2020-06-10 Thread Visa Hankala
A while ago, finishdup() was changed to release fdplock before calling closef() to avoid potential lock order problems in the file close path. However, the dup* code can still invoke that path with fdplock held through FRELE(). That is fixed by the diff below. (In principle, the FRELE(fp, p) could

Block interrupts when changing struct process' ps_klist

2020-06-13 Thread Visa Hankala
The ps_klist member of struct process can be accessed from interrupt context as a result of signal sending. Currently, interrupts are not blocked when ps_klist is modified, which allows race conditions. The patch below guards ps_klist insertions and removals with splhigh(). The list should only be

Retire

2020-06-19 Thread Visa Hankala
The header has been unhooked from / for a while, and no one has complained. Nothing seems to reference any longer, so the following files should be ready for removal: sys/arch/alpha/include/stdarg.h sys/arch/amd64/include/stdarg.h sys/arch/arm/include/stdarg.h sys/arch/arm64/include/stdarg.h s

Use klist_invalidate() in knote_processexit()

2020-06-29 Thread Visa Hankala
knote_processexit() uses knote_remove() to clear any remaining knotes from &pr->ps_klist when process `pr' exits. All EVFILT_PROC knotes are removed by the KNOTE(&pr->ps_klist, NOTE_EXIT) call. However, ps_klist can contain EVFILT_SIGNAL knotes after the KNOTE(). To reserve knote_remove() for the

Re: have bpf kq events fire when the interface goes away

2021-04-21 Thread Visa Hankala
On Wed, Apr 21, 2021 at 11:04:20AM +1000, David Gwynne wrote: > On Wed, Apr 21, 2021 at 10:21:32AM +1000, David Gwynne wrote: > > if you have a program that uses kq (or libevent) to wait for bytes to > > read off an idle network interface via /dev/bpf and that interface > > goes away, the program d

Re: have bpf kq events fire when the interface goes away

2021-04-22 Thread Visa Hankala
On Thu, Apr 22, 2021 at 01:13:50PM +1000, David Gwynne wrote: > On Wed, Apr 21, 2021 at 01:15:53PM +0000, Visa Hankala wrote: > > On Wed, Apr 21, 2021 at 11:04:20AM +1000, David Gwynne wrote: > > > On Wed, Apr 21, 2021 at 10:21:32AM +1000, David Gwynne wrote: > > > &

Driver for Cadence UART

2021-04-23 Thread Visa Hankala
@@ -0,0 +1,36 @@ +.\"$OpenBSD$ +.\" +.\" Copyright (c) 2021 Visa Hankala +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this per

Re: Driver for Cadence UART

2021-04-23 Thread Visa Hankala
On Fri, Apr 23, 2021 at 04:26:34PM +0200, Mark Kettenis wrote: > > Date: Fri, 23 Apr 2021 12:54:54 + > > From: Visa Hankala > > > > This diff adds an initial driver for Cadence UART. This controller block > > is present at least on Xilinx Zynq system-on-chi

Driver for Zynq-7000 system-level control registers

2021-04-26 Thread Visa Hankala
x: share/man/man4/man4.armv7/zqsyscon.4 === RCS file: share/man/man4/man4.armv7/zqsyscon.4 diff -N share/man/man4/man4.armv7/zqsyscon.4 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ share/man/man4/man4.armv7/zqsyscon.426 Apr 2021

Re: Driver for Zynq-7000 system-level control registers

2021-04-27 Thread Visa Hankala
On Mon, Apr 26, 2021 at 05:25:18PM +0200, Mark Kettenis wrote: > > Date: Mon, 26 Apr 2021 14:19:38 + > > From: Visa Hankala > > > > The following diff adds a preliminary driver for the system-level > > control registers of Xilinx Zynq-7000. It enables system

sdhc(4) attachment for Zynq-7000

2021-05-02 Thread Visa Hankala
Zynq-7000 has a variant of Arasan SD controller that is not recognized by the fdt glue. The diff below fixes this. The controller's capabilities register lacks the base clock frequency. The attachment glue has to provide this parameter. OK? Index: dev/fdt/sdhc_fdt.c =

Re: sdhc(4) attachment for Zynq-7000

2021-05-02 Thread Visa Hankala
On Sun, May 02, 2021 at 05:28:24PM +0200, Mark Kettenis wrote: > > Date: Sun, 2 May 2021 14:21:29 + > > From: Visa Hankala > > > > Zynq-7000 has a variant of Arasan SD controller that is not recognized > > by the fdt glue. The diff below fixes this. > >

Fix mbuf leaks in re_rxeof()

2021-05-13 Thread Visa Hankala
It looks that re_rxeof() might leak mbufs in two cases. The first case happens if the controller returns an incomplete frame when frames are expected to be non-fragmented. Note that in this instance the fragment list sc->rl_head should be empty and does not need clearing. The second leak happens i

Re: timeout(9): add TIMEOUT_MPSAFE flag

2021-05-13 Thread Visa Hankala
On Thu, May 13, 2021 at 12:04:57AM -0500, Scott Cheloha wrote: > The funky locking dance in softclock() and softclock_thread() is > needed to keep from violating the locking hierarchy. The > timeout_mutex is above the kernel lock, so we need to leave the > timeout_mutex, then drop the kernel lock,

Re: timeout(9): add TIMEOUT_MPSAFE flag

2021-05-13 Thread Visa Hankala
On Thu, May 13, 2021 at 11:08:25AM -0500, Scott Cheloha wrote: > > On May 13, 2021, at 10:57 AM, Visa Hankala wrote: > > > > On Thu, May 13, 2021 at 12:04:57AM -0500, Scott Cheloha wrote: > >> The funky locking dance in softclock() and softclock_thread() is > >&g

Re: panic(9): set panicstr atomically

2021-05-15 Thread Visa Hankala
On Wed, May 12, 2021 at 07:08:39PM -0500, Scott Cheloha wrote: > In a separate mail thread, bluhm@ mentioned that panic(9) does not > cleanly handle multiple CPUs entering it simultaneously: > > https://marc.info/?l=openbsd-tech&m=161908805925325&w=2 > > I'm unsure which part of panic(9) is causi

Add f_modify and f_process callbacks to socket filterops

2021-05-18 Thread Visa Hankala
This diff adds f_modify and f_process callbacks to socket event filters. As a result, socket events are handled using the non-legacy paths in filter_modify() and filter_process() of kern_event.c This a step toward MP-safety. However, everything still runs under the kernel lock. The change has thre

Serialize kqueue's internals with a mutex

2021-05-20 Thread Visa Hankala
This patch adds a mutex that serializes access to a kqueue. As a result, most of kqueue's internals should become safe to run without the kernel lock. In principle, the patch should allow unlocking kevent(2). Some notes: * The existing uses of splhigh() outline where the mutex should be held. *

  1   2   3   4   5   >