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.

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
Unit Tests Skipped

Event Timeline

davide updated this revision to Diff 2564.Nov 27 2014, 12:40 AM
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.
ed added inline comments.Nov 27 2014, 5:41 PM
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';

davide abandoned this revision.Nov 27 2014, 8:43 PM

Drop this revision after discussion on the mailing list.