Page MenuHomeFreeBSD

Pre-Allocate pty devices in mod_event handler rather than using dev_clone
AbandonedPublic

Authored by davide on Nov 27 2014, 12:40 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 28, 8:58 AM
Unknown Object (File)
Mon, Mar 18, 2:47 PM
Unknown Object (File)
Feb 23 2024, 9:11 AM
Unknown Object (File)
Feb 20 2024, 4:38 PM
Unknown Object (File)
Jan 17 2024, 9:34 AM
Unknown Object (File)
Jan 8 2024, 9:33 AM
Unknown Object (File)
Jan 8 2024, 9:33 AM
Unknown Object (File)
Jan 8 2024, 9:21 AM
Subscribers
None

Details

Reviewers
jhb
ed
Summary

root@maxwell:/home/davide # kldload pty
root@maxwell/home/davide # sysctl -a |grep pty
kern.tty_pty_warningcnt: 1
kern.npty: 32
debug.softdep.emptyjblocks: 0

root@maxwell:/home/davide # ls /dev/pty*
/dev/ptyl0 /dev/ptyl2 /dev/ptyl4 /dev/ptyl6 /dev/ptyl8 /dev/ptyla /dev/ptylc /dev/ptyle /dev/ptylg /dev/ptyli /dev/ptylk /dev/ptylm /dev/ptylo /dev/ptylq /dev/ptyls /dev/ptylu
/dev/ptyl1 /dev/ptyl3 /dev/ptyl5 /dev/ptyl7 /dev/ptyl9 /dev/ptylb /dev/ptyld /dev/ptylf /dev/ptylh /dev/ptylj /dev/ptyll /dev/ptyln /dev/ptylp /dev/ptylr /dev/ptylt /dev/ptylv

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

davide retitled this revision from to Pre-Allocate pty devices in mod_event handler rather than using dev_clone.
davide updated this object.
davide edited the test plan for this revision. (Show Details)
davide added reviewers: ed, jhb.
sys/dev/pty/pty.c
62

I don't entirely see why we'd need this sysctl variable. The point is, the devices are created when you load the module. After the module has loaded, we never use this one again, meaning that the user still has no way to influence this, right?

The upper limit is also far too high. The naming scheme doesn't really allow you to create more.

119

So the point is: we originally used the naming scheme pty[pqrs][0-9a-v] and only later on added support for pty[l-o][0-9a-v] when that became insufficient. Please make sure that if npty is low, the first device you hand out is ptyp0. Otherwise you will break compatibility. See:

https://svnweb.freebsd.org/base/head/etc/etc.i386/ttys?r1=199250&r2=203068

139

Instead of coming up with complicated logic to compute the next device name, it's actually easier to recompute it entirely.

namedev[3] = "pqrsPQRS"[i / 32];
n = i % 32;
namedev[4] = n < 10 ? n + '0' : n - 10 + 'a';

Drop this revision after discussion on the mailing list.