fix typo in ltrace usage

2013-06-05 Thread Arto Jonsson
Index: ktrace.c
===
RCS file: /cvs/src/usr.bin/ktrace/ktrace.c,v
retrieving revision 1.25
diff -u -r1.25 ktrace.c
--- ktrace.c1 Jun 2013 09:57:58 -   1.25
+++ ktrace.c5 Jun 2013 07:55:58 -
@@ -215,7 +215,7 @@
 {
if (is_ltrace)
fprintf(stderr, usage: %s [-ai] [-f trfile] [-u trspec]
- comand\n,
+ command\n,
__progname);
else
fprintf(stderr, usage: %s [-aBCcdi] [-f trfile] [-g pgid]



Re: ipsec / PF received-on

2013-06-05 Thread David Gwynne

On 04/06/2013, at 11:22 AM, Claudio Jeker cje...@diehard.n-r-g.com wrote:

 On Mon, Jun 03, 2013 at 11:49:58PM +0100, Stuart Henderson wrote:
 On a router running PF and isakmpd, I have a rule like this:
 
 match out on pppoe0 inet all received-on vlan5 nat-to $someip
 
 I was surprised to find this being applied to packets received on vlan5
 and caught by an ipsec flow; the resulting *encapsulated* (proto ESP) packets
 (as in, generated on the router itself, not actually themselves received on
 vlan5) end up getting natted.
 
 What does anyone else think...expected or not?
 
 
 Question, would you expect the ipsec packets to match against this rule?
 match out on pppoe0 inet all received-on enc0 nat-to $someip
 
 As in should we change the received interface when we hit ipsec?
 Think carefully since this path is edged by dragons and deep dark
 rabbit holes.

there is precedence for virtual interfaces to overwrite the rcvif on the way 
through. eg, em0 could become trunk0 which could become vlan0.

in this particular case though (ipsec gateway) id argue encapsulation by ipsec 
should clear the rcvif. is there any error handling for ipsec packets that 
relies on it?

dlg



Re: put procs on rb tree

2013-06-05 Thread Alexandre Ratchov
On Tue, Jun 04, 2013 at 11:33:12PM -0400, Ted Unangst wrote:
 Instead of using a fixed size hash table for procs, use an rb tree.
 
 Makes thread/process lookup even more web scale.
 

any measurement?

-- Alexandre



-current diff Re: tmpfs

2013-06-05 Thread Marc Espie
Here's the diff I have to -current with just tmpfs
(activate bits, uvm changes).

pedro, I know some of your stuff is not in there (I dropped the mount_tmpfs
diff), feel free to give me a full correct updated diff.

Index: lib/libc/sys/mount.2
===
RCS file: /home/openbsd/cvs/src/lib/libc/sys/mount.2,v
retrieving revision 1.40
diff -u -p -r1.40 mount.2
--- lib/libc/sys/mount.217 Nov 2011 14:26:14 -  1.40
+++ lib/libc/sys/mount.22 May 2013 18:56:39 -
@@ -227,6 +227,23 @@ struct udf_args {
 };
 .Ed
 .Pp
+.Dv MOUNT_TMPFS
+.Bd -literal -offset indent -compact
+#define TMPFS_ARGS_VERSION 1
+struct tmpfs_args {
+   int ta_version;
+
+   /* Size counters. */
+   ino_t   ta_nodes_max;
+   off_t   ta_size_max;
+
+   /* Root node attributes. */
+   uid_t   ta_root_uid;
+   gid_t   ta_root_gid;
+   mode_t  ta_root_mode;
+};
+.Ed
+.Pp
 The
 .Fn unmount
 function call disassociates the filesystem from the specified
Index: sbin/mount/mount.8
===
RCS file: /home/openbsd/cvs/src/sbin/mount/mount.8,v
retrieving revision 1.70
diff -u -p -r1.70 mount.8
--- sbin/mount/mount.8  23 Aug 2012 14:43:04 -  1.70
+++ sbin/mount/mount.8  2 May 2013 18:56:39 -
@@ -390,6 +390,7 @@ with option
 .Xr mount_ntfs 8 ,
 .Xr mount_procfs 8 ,
 .Xr mount_udf 8 ,
+.Xr mount_tmpfs 8 ,
 .Xr mount_vnd 8 ,
 .Xr sysctl 8 ,
 .Xr umount 8
Index: share/man/man4/options.4
===
RCS file: /home/openbsd/cvs/src/share/man/man4/options.4,v
retrieving revision 1.232
diff -u -p -r1.232 options.4
--- share/man/man4/options.423 May 2013 01:47:43 -  1.232
+++ share/man/man4/options.425 May 2013 14:56:27 -
@@ -273,6 +273,11 @@ Includes code for the UDF file systems t
 See
 .Xr mount_udf 8
 for details.
+.It Cd option TMPFS
+Includes code for the TMPFS efficient memory file system.
+See
+.Xr mount_tmpfs 8
+for details.
 .El
 .Sh FILE SYSTEM OPTIONS
 .Bl -ohang
Index: share/man/man5/fstab.5
===
RCS file: /home/openbsd/cvs/src/share/man/man5/fstab.5,v
retrieving revision 1.45
diff -u -p -r1.45 fstab.5
--- share/man/man5/fstab.5  17 Apr 2011 20:17:12 -  1.45
+++ share/man/man5/fstab.5  2 May 2013 18:56:39 -
@@ -127,6 +127,8 @@ A disk partition to be used for swapping
 A UDF filesystem.
 .It vnd
 A VND image file.
+.It tmpfs
+A local, efficient memory-based file system.
 .El
 .Pp
 The fourth field,
Index: sys/conf/GENERIC
===
RCS file: /home/openbsd/cvs/src/sys/conf/GENERIC,v
retrieving revision 1.196
diff -u -p -r1.196 GENERIC
--- sys/conf/GENERIC15 Apr 2013 15:32:19 -  1.196
+++ sys/conf/GENERIC2 May 2013 18:56:39 -
@@ -47,6 +47,7 @@ optionCD9660  # ISO 9660 + Rock Ridge 
 option UDF # UDF (DVD) file system
 option MSDOSFS # MS-DOS file system
 option FIFO# FIFOs; RECOMMENDED
+option TMPFS   # efficient memory file system
 
 option SOCKET_SPLICE   # Socket Splicing for TCP
 option TCP_SACK# Selective Acknowledgements for TCP
Index: sys/conf/files
===
RCS file: /home/openbsd/cvs/src/sys/conf/files,v
retrieving revision 1.547
diff -u -p -r1.547 files
--- sys/conf/files  3 Jun 2013 15:54:47 -   1.547
+++ sys/conf/files  5 Jun 2013 10:35:24 -
@@ -756,6 +756,12 @@ file ntfs/ntfs_ihash.c ntfs
 file ntfs/ntfs_subr.c  ntfs
 file ntfs/ntfs_vfsops.cntfs
 file ntfs/ntfs_vnops.c ntfs
+file tmpfs/tmpfs_mem.c tmpfs
+file tmpfs/tmpfs_subr.ctmpfs
+file tmpfs/tmpfs_vfsops.c  tmpfs
+file tmpfs/tmpfs_vnops.c   tmpfs
+file tmpfs/tmpfs_specops.c tmpfs
+file tmpfs/tmpfs_fifoops.c tmpfs  fifo
 file net/bpf.c bpfilterneeds-count
 file net/bpf_filter.c  bpfilter
 file net/if.c
Index: sys/kern/vfs_init.c
===
RCS file: /home/openbsd/cvs/src/sys/kern/vfs_init.c,v
retrieving revision 1.32
diff -u -p -r1.32 vfs_init.c
--- sys/kern/vfs_init.c 3 Jun 2013 15:54:48 -   1.32
+++ sys/kern/vfs_init.c 5 Jun 2013 10:42:54 -
@@ -90,6 +90,10 @@ extern  const struct vfsops udf_vfsops;
 extern const struct vfsops fusefs_vfsops;
 #endif
 
+#ifdef TMPFS
+extern  const struct vfsops tmpfs_vfsops;
+#endif
+
 /* Set up the filesystem operations for vnodes. */
 static struct vfsconf 

Re: -current diff Re: tmpfs

2013-06-05 Thread Marc Espie
On Wed, Jun 05, 2013 at 02:55:29PM +0200, Marc Espie wrote:
 Here's the diff I have to -current with just tmpfs
 (activate bits, uvm changes).
 
 pedro, I know some of your stuff is not in there (I dropped the mount_tmpfs
 diff), feel free to give me a full correct updated diff.

And of course, I keep forgetting to add sbin/Makefile...

Index: lib/libc/sys/mount.2
===
RCS file: /home/openbsd/cvs/src/lib/libc/sys/mount.2,v
retrieving revision 1.40
diff -u -p -r1.40 mount.2
--- lib/libc/sys/mount.217 Nov 2011 14:26:14 -  1.40
+++ lib/libc/sys/mount.22 May 2013 18:56:39 -
@@ -227,6 +227,23 @@ struct udf_args {
 };
 .Ed
 .Pp
+.Dv MOUNT_TMPFS
+.Bd -literal -offset indent -compact
+#define TMPFS_ARGS_VERSION 1
+struct tmpfs_args {
+   int ta_version;
+
+   /* Size counters. */
+   ino_t   ta_nodes_max;
+   off_t   ta_size_max;
+
+   /* Root node attributes. */
+   uid_t   ta_root_uid;
+   gid_t   ta_root_gid;
+   mode_t  ta_root_mode;
+};
+.Ed
+.Pp
 The
 .Fn unmount
 function call disassociates the filesystem from the specified
Index: sbin/mount/mount.8
===
RCS file: /home/openbsd/cvs/src/sbin/mount/mount.8,v
retrieving revision 1.70
diff -u -p -r1.70 mount.8
--- sbin/mount/mount.8  23 Aug 2012 14:43:04 -  1.70
+++ sbin/mount/mount.8  2 May 2013 18:56:39 -
@@ -390,6 +390,7 @@ with option
 .Xr mount_ntfs 8 ,
 .Xr mount_procfs 8 ,
 .Xr mount_udf 8 ,
+.Xr mount_tmpfs 8 ,
 .Xr mount_vnd 8 ,
 .Xr sysctl 8 ,
 .Xr umount 8
Index: sbin/Makefile
===
RCS file: /home/openbsd/cvs/src/sbin/Makefile,v
retrieving revision 1.97
diff -u -p -r1.97 Makefile
--- sbin/Makefile   23 Aug 2012 06:37:27 -  1.97
+++ sbin/Makefile   5 Jun 2013 12:59:47 -
@@ -5,7 +5,7 @@ SUBDIR= atactl badsect bioctl clri dhcli
fsck_msdos fsdb fsirand growfs ifconfig iked init iopctl ipsecctl  \
isakmpd kbd ldattach lmccontrol mknod modload modunload mount \
mount_cd9660 mount_ext2fs mount_ffs mount_msdos \
-   mount_nfs mount_ntfs mount_procfs mount_udf \
+   mount_nfs mount_ntfs mount_procfs mount_tmpfs mount_udf \
mount_vnd mountd ncheck_ffs newfs newfs_ext2fs newfs_msdos \
nfsd nologin pdisk pfctl pflogd ping ping6 quotacheck \
reboot restore route rtsol savecore scan_ffs \
Index: share/man/man4/options.4
===
RCS file: /home/openbsd/cvs/src/share/man/man4/options.4,v
retrieving revision 1.232
diff -u -p -r1.232 options.4
--- share/man/man4/options.423 May 2013 01:47:43 -  1.232
+++ share/man/man4/options.425 May 2013 14:56:27 -
@@ -273,6 +273,11 @@ Includes code for the UDF file systems t
 See
 .Xr mount_udf 8
 for details.
+.It Cd option TMPFS
+Includes code for the TMPFS efficient memory file system.
+See
+.Xr mount_tmpfs 8
+for details.
 .El
 .Sh FILE SYSTEM OPTIONS
 .Bl -ohang
Index: share/man/man5/fstab.5
===
RCS file: /home/openbsd/cvs/src/share/man/man5/fstab.5,v
retrieving revision 1.45
diff -u -p -r1.45 fstab.5
--- share/man/man5/fstab.5  17 Apr 2011 20:17:12 -  1.45
+++ share/man/man5/fstab.5  2 May 2013 18:56:39 -
@@ -127,6 +127,8 @@ A disk partition to be used for swapping
 A UDF filesystem.
 .It vnd
 A VND image file.
+.It tmpfs
+A local, efficient memory-based file system.
 .El
 .Pp
 The fourth field,
Index: sys/conf/GENERIC
===
RCS file: /home/openbsd/cvs/src/sys/conf/GENERIC,v
retrieving revision 1.196
diff -u -p -r1.196 GENERIC
--- sys/conf/GENERIC15 Apr 2013 15:32:19 -  1.196
+++ sys/conf/GENERIC2 May 2013 18:56:39 -
@@ -47,6 +47,7 @@ optionCD9660  # ISO 9660 + Rock Ridge 
 option UDF # UDF (DVD) file system
 option MSDOSFS # MS-DOS file system
 option FIFO# FIFOs; RECOMMENDED
+option TMPFS   # efficient memory file system
 
 option SOCKET_SPLICE   # Socket Splicing for TCP
 option TCP_SACK# Selective Acknowledgements for TCP
Index: sys/conf/files
===
RCS file: /home/openbsd/cvs/src/sys/conf/files,v
retrieving revision 1.547
diff -u -p -r1.547 files
--- sys/conf/files  3 Jun 2013 15:54:47 -   1.547
+++ sys/conf/files  5 Jun 2013 10:35:24 -
@@ -756,6 +756,12 @@ file ntfs/ntfs_ihash.c ntfs
 file ntfs/ntfs_subr.c  ntfs
 file ntfs/ntfs_vfsops.cntfs
 file ntfs/ntfs_vnops.c ntfs

Re: correct includes in man(2) pages

2013-06-05 Thread Jason McIntyre
On Wed, Jun 05, 2013 at 06:36:11PM +0200, Jan Klemkow wrote:
 
 The only special case is this one:
 
 Index: libc/sys/quotactl.2
 ===
 RCS file: /cvs/src/lib/libc/sys/quotactl.2,v
 retrieving revision 1.11
 diff -u -p -r1.11 quotactl.2
 --- libc/sys/quotactl.2 31 May 2007 19:19:33 -  1.11
 +++ libc/sys/quotactl.2 5 Jun 2013 16:25:27 -
 @@ -40,8 +40,8 @@
  .Nm quotactl
  .Nd manipulate filesystem quotas
  .Sh SYNOPSIS
 -.Fd #include ufs/ufs/quota.h /* for ufs quotas */
 -.Fd #include unistd.h
 +.In ufs/ufs/quota.h /* for ufs quotas */
 +.In unistd.h
  .Ft int
  .Fn quotactl const char *path int cmd int id char *addr
  .Sh DESCRIPTION
 
 I had to replace the tab between 'quota.h' and the comment with a normal
 space.  mandoc(1) do not render it properly with a tabulator.
 

we should be careful here. mandoc renders it like this:

 SYNOPSIS
  #include ufs/ufs/quota.h /* for ufs quotas */
  #include unistd.h

whereas groff does this:

 SYNOPSIS
  #include ufs/ufs/quota.h
  /* for ufs quotas */ #include unistd.h

our mdoc(7) states that .In should have exactly one argument. i don;t
think groff says the same, but it does document (groff_mdoc(7)) that .In
causes a newline after its argument.

we should probably not have more than one argument in our pages for the
.In lines, and, arguably, mandoc should behave the same as groff.

ingo?

jmc



Re: correct includes in man(2) pages

2013-06-05 Thread Ted Unangst
On Wed, Jun 05, 2013 at 17:56, Jason McIntyre wrote:
 we should be careful here. mandoc renders it like this:
 
 SYNOPSIS
 #include ufs/ufs/quota.h /* for ufs quotas */
 #include unistd.h
 
 whereas groff does this:
 
 SYNOPSIS
 #include ufs/ufs/quota.h
 /* for ufs quotas */ #include unistd.h
 
 our mdoc(7) states that .In should have exactly one argument. i don;t
 think groff says the same, but it does document (groff_mdoc(7)) that .In
 causes a newline after its argument.

I think we should delete the comment. It should not be surprising that
a function manipulating quotas needs to include the quota header.



Re: correct includes in man(2) pages

2013-06-05 Thread Jason McIntyre
On Wed, Jun 05, 2013 at 01:14:15PM -0400, Ted Unangst wrote:
 On Wed, Jun 05, 2013 at 17:56, Jason McIntyre wrote:
  we should be careful here. mandoc renders it like this:
  
  SYNOPSIS
  #include ufs/ufs/quota.h /* for ufs quotas */
  #include unistd.h
  
  whereas groff does this:
  
  SYNOPSIS
  #include ufs/ufs/quota.h
  /* for ufs quotas */ #include unistd.h
  
  our mdoc(7) states that .In should have exactly one argument. i don;t
  think groff says the same, but it does document (groff_mdoc(7)) that .In
  causes a newline after its argument.
 
 I think we should delete the comment. It should not be surprising that
 a function manipulating quotas needs to include the quota header.

that's fine. but i think there are other man pages that do this. so
fixing one page is not a solution. (might be wrong though - haven;t
checked)

jmc



correct mistake in logger(1) man page

2013-06-05 Thread André Stöbe
logger -f, as described in the man page,

-f file  Log to the specified file.

actually logs (the contents of) the specified file.

Regards
André


Index: src/usr.bin/logger/logger.1
===
RCS file: /cvs/src/usr.bin/logger/logger.1,v
retrieving revision 1.20
diff -u -p -r1.20 logger.1
--- src/usr.bin/logger/logger.1 28 Feb 2012 20:40:58 -  1.20
+++ src/usr.bin/logger/logger.1 5 Jun 2013 16:02:08 -
@@ -53,7 +53,7 @@ system log module.
 The options are as follows:
 .Bl -tag -width -f file
 .It Fl f Ar file
-Log to the specified
+Log the specified
 .Ar file .
 .It Fl i
 Log the process ID of the logger process



Re: correct mistake in logger(1) man page

2013-06-05 Thread Ted Unangst
On Wed, Jun 05, 2013 at 19:28, Andr? St?be wrote:
 logger -f, as described in the man page,
 
 -f file  Log to the specified file.
 
 actually logs (the contents of) the specified file.

Thanks. I changed the wording to Read from the specified file. so
it's even more clear.



Re: put procs on rb tree

2013-06-05 Thread Ted Unangst
On Wed, Jun 05, 2013 at 14:13, Alexandre Ratchov wrote:
 On Tue, Jun 04, 2013 at 11:33:12PM -0400, Ted Unangst wrote:
 Instead of using a fixed size hash table for procs, use an rb tree.

 Makes thread/process lookup even more web scale.

 
 any measurement?

o ye of little faith...

stock
54.65
57.29
54.54

rbproc
47.27
47.34
47.16

Benchmark code is below. Now you may well complain that I cooked the
test to give me the result I want. If you remove the pid colliding
code pertaining to 42, the results are different.

stock
37.16
37.52
37.07

rbproc
47.20
46.84
46.51

Perhaps a more realistic test is called for, like building a kernel.

stock
1m24.51s real 4m6.24s user 0m43.34s system
1m24.12s real 4m7.64s user 0m41.98s system

rbproc
1m24.02s real 4m6.90s user 0m43.65s system
1m23.88s real 4m6.07s user 0m41.73s system

rbproc wins by a hair, but I am happy to call it a draw.

Conclusion? You'll never notice the difference. Personally I have a
slight preference for improving worst case behavior. The hash table
isn't *that* large today, but as we increase maxthreads it will get
bigger. I prefer dynamic structures to statically sized structures.

#include errno.h
#include stdio.h
#include stdlib.h
#include unistd.h

static __inline uint64_t
rdtsc(void)
{
uint32_t hi, lo;

__asm __volatile(rdtsc : =d (hi), =a (lo));
return (((uint64_t)hi  32) | (uint64_t) lo);
}

const int loops = 256;
const int maxproc = 50;

int
main()
{
int pidhash = 511;
int nprocs;
int pids[200];
int i, p, pid;
uint64_t before, after;

printf(creating pids\n);
nprocs = 0;
while (nprocs  maxproc) {
pid = fork();
switch (pid) {
case 0:
if ((getpid()  pidhash) != 42)
_exit(0);
while (1)
sleep(1);
break;
case -1:
for (p = 0; p  nprocs; p++)
kill(pids[p], 9);
printf(failed after %d %d\n, nprocs, errno);
exit(1);
default:
if ((pid  pidhash) == 42)
pids[nprocs++] = pid;
else
waitpid(pid, NULL, 0);
}
}
printf(benchmarking...\n);
before = rdtsc();
for (i = 0; i  loops; i++)
for (p = 0; p  nprocs; p++)
kill(pids[p], 0);
after = rdtsc();
for (p = 0; p  nprocs; p++)
kill(pids[p], 9);
printf(%.2f\n, (after - before) / 10.0);
}



Re: correct includes in man(2) pages

2013-06-05 Thread Kent R. Spillner
 we should probably not have more than one argument in our pages for the
 .In lines, and, arguably, mandoc should behave the same as groff.

Regardless, the comment doesn't add much.  #include ufs/ufs/quota.h is 
pretty self-explanatory that it's for UFS quotas.  :)





[PATCH] amd.8 default configuration file

2013-06-05 Thread Ville Valkonen
Hi,

although amd's default configuration file placement is probably quite
self-explanatory, I thought it would be worth to mention that in the
man page. FreeBSD and NetBSD do the same.

As Gmail (a web client) mangles the patches, here's the link for it:
http://weezel.fsck.fi/amd8_defaultconfig.patch

--
Sincerely,
Ville Valkonen



Re: put procs on rb tree

2013-06-05 Thread Bob Beck

I'm ok with this. 


On Wed, Jun 05, 2013 at 02:12:36PM -0400, Ted Unangst wrote:
 On Wed, Jun 05, 2013 at 14:13, Alexandre Ratchov wrote:
  On Tue, Jun 04, 2013 at 11:33:12PM -0400, Ted Unangst wrote:
  Instead of using a fixed size hash table for procs, use an rb tree.
 
  Makes thread/process lookup even more web scale.
 
  
  any measurement?
 
 o ye of little faith...
 
 stock
 54.65
 57.29
 54.54
 
 rbproc
 47.27
 47.34
 47.16
 
 Benchmark code is below. Now you may well complain that I cooked the
 test to give me the result I want. If you remove the pid colliding
 code pertaining to 42, the results are different.
 
 stock
 37.16
 37.52
 37.07
 
 rbproc
 47.20
 46.84
 46.51
 
 Perhaps a more realistic test is called for, like building a kernel.
 
 stock
 1m24.51s real 4m6.24s user 0m43.34s system
 1m24.12s real 4m7.64s user 0m41.98s system
 
 rbproc
 1m24.02s real 4m6.90s user 0m43.65s system
 1m23.88s real 4m6.07s user 0m41.73s system
 
 rbproc wins by a hair, but I am happy to call it a draw.
 
 Conclusion? You'll never notice the difference. Personally I have a
 slight preference for improving worst case behavior. The hash table
 isn't *that* large today, but as we increase maxthreads it will get
 bigger. I prefer dynamic structures to statically sized structures.
 
 #include errno.h
 #include stdio.h
 #include stdlib.h
 #include unistd.h
 
 static __inline uint64_t
 rdtsc(void)
 {
   uint32_t hi, lo;
 
   __asm __volatile(rdtsc : =d (hi), =a (lo));
   return (((uint64_t)hi  32) | (uint64_t) lo);
 }
 
 const int loops = 256;
 const int maxproc = 50;
 
 int
 main()
 {
   int pidhash = 511;
   int nprocs;
   int pids[200];
   int i, p, pid;
   uint64_t before, after;
 
   printf(creating pids\n);
   nprocs = 0;
   while (nprocs  maxproc) {
   pid = fork();
   switch (pid) {
   case 0:
   if ((getpid()  pidhash) != 42)
   _exit(0);
   while (1)
   sleep(1);
   break;
   case -1:
   for (p = 0; p  nprocs; p++)
   kill(pids[p], 9);
   printf(failed after %d %d\n, nprocs, errno);
   exit(1);
   default:
   if ((pid  pidhash) == 42)
   pids[nprocs++] = pid;
   else
   waitpid(pid, NULL, 0);
   }
   }
   printf(benchmarking...\n);
   before = rdtsc();
   for (i = 0; i  loops; i++)
   for (p = 0; p  nprocs; p++)
   kill(pids[p], 0);
   after = rdtsc();
   for (p = 0; p  nprocs; p++)
   kill(pids[p], 9);
   printf(%.2f\n, (after - before) / 10.0);
 }
 



Re: put procs on rb tree

2013-06-05 Thread Mark Kettenis
 Date: Wed, 05 Jun 2013 14:12:36 -0400
 From: Ted Unangst t...@tedunangst.com
 
 On Wed, Jun 05, 2013 at 14:13, Alexandre Ratchov wrote:
  On Tue, Jun 04, 2013 at 11:33:12PM -0400, Ted Unangst wrote:
  Instead of using a fixed size hash table for procs, use an rb tree.
 
  Makes thread/process lookup even more web scale.
 
  
  any measurement?
 
 o ye of little faith...
 
 stock
 54.65
 57.29
 54.54
 
 rbproc
 47.27
 47.34
 47.16
 
 Benchmark code is below. Now you may well complain that I cooked the
 test to give me the result I want. If you remove the pid colliding
 code pertaining to 42, the results are different.
 
 stock
 37.16
 37.52
 37.07
 
 rbproc
 47.20
 46.84
 46.51
 
 Perhaps a more realistic test is called for, like building a kernel.
 
 stock
 1m24.51s real 4m6.24s user 0m43.34s system
 1m24.12s real 4m7.64s user 0m41.98s system
 
 rbproc
 1m24.02s real 4m6.90s user 0m43.65s system
 1m23.88s real 4m6.07s user 0m41.73s system
 
 rbproc wins by a hair, but I am happy to call it a draw.
 
 Conclusion? You'll never notice the difference. Personally I have a
 slight preference for improving worst case behavior. The hash table
 isn't *that* large today, but as we increase maxthreads it will get
 bigger. I prefer dynamic structures to statically sized structures.

If it ain't broke, don't fix it?

And I think there are some downsides you may be overlooking:

 * red-black trees tend to add a significant amount of code to the kernel

 * red-black trees are a PITA when debugging; it's difficult to find
   anything in them when you're in ddb/gdb

Cheers,

Mark



bzip2

2013-06-05 Thread Ted Unangst
Something that comes up from time to time is the question of whether
to import bzip2 into base or not. Turns out the question is moot
because already have imported it. There's a copy in perl. (I didn't
know this until I happened to be watching a build closer than usual.)

Since we already have the code built, why not let people use it? This
is a small perl script that implements the 90% subset of functionality
people expect from the regular bzip2 and bunzip2 utilities. It's not
really complete or perfect, but I haven't spent all that much time on
it.

--- /dev/null   Wed Jun  5 20:54:56 2013
+++ bzip2/Makefile  Wed Jun  5 20:51:51 2013
@@ -0,0 +1,15 @@
+# $OpenBSD$
+
+.include bsd.own.mk
+
+MAN=
+
+SCRIPT=bzip2.pl
+LINKS=${BINDIR}/bzip2 ${BINDIR}/bunzip2
+
+realinstall:
+   ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+   ${.CURDIR}/${SCRIPT} ${DESTDIR}${BINDIR}/bzip2
+
+
+.include bsd.prog.mk
--- /dev/null   Wed Jun  5 20:55:02 2013
+++ bzip2/bzip2.pl  Wed Jun  5 20:53:23 2013
@@ -0,0 +1,113 @@
+#!/usr/bin/perl -w
+# $OpenBSD$
+# Copyright (c) Ted Unangst t...@openbsd.org
+#
+# 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 permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+use strict;
+use Getopt::Long qw(:config posix_default bundling no_ignore_case);
+use IO::Compress::Bzip2 qw(bzip2);
+
+
+my $usestdout;
+my $level = 9;
+my $reqlevel; # requested level, who cares?
+GetOptions(
+   c|stdout = \$usestdout,
+   1|2|3|4|5|6|7|8|9|fast|best = \$reqlevel
+);
+
+sub bzipfile {
+   my $fname = shift;
+   my $ofname;
+   my $in;
+   if ($fname ne -) {
+   if ($usestdout) {
+   $ofname = -;
+   } else {
+   $ofname = $fname . .bz2;
+   if (-e $ofname) {
+   warn Output file $ofname already exists.\n;
+   return;
+   }
+   }
+   $in = new IO::File $fname;
+   if (!$in) {
+   warn Can't open input file $fname.\n;
+   return;
+   }
+   } else {
+   $in = -;
+   $ofname = -;
+   }
+   if ($ofname eq -  -t STDOUT) {
+   warn I won't write compressed data to a terminal.\n;
+   return;
+   }
+   if (not bzip2 $in = $ofname, BlockSize100K = $level) {
+   warn failz;
+   return;
+   }
+   if ($ofname ne -) {
+   unlink($fname);
+   }
+}
+
+sub bunzipfile {
+print bunzipping\n;
+   my $fname = shift;
+   my $ofname;
+   my $in;
+   if ($fname ne -) {
+   if ($usestdout) {
+   $ofname = -;
+   } else {
+   $ofname = $fname;
+   $ofname =~ s/\.bz2$//;
+   if (-e $ofname) {
+   warn Output file $ofname already exists.\n;
+   return;
+   }
+   }
+   $in = new IO::File $fname;
+   if (!$in) {
+   warn Can't open input file $fname.\n;
+   return;
+   }
+   } else {
+   $in = -;
+   $ofname = -;
+   }
+   if (not bunzip2 $in = $ofname) {
+   warn failz;
+   return;
+   }
+   if ($ofname ne -) {
+   unlink($fname);
+   }
+}
+
+my $main;
+if ($0 =~ /bunzip2$/) {
+   $main = \bunzipfile;
+} else {
+   $main = \bzipfile;
+}
+
+if (@ARGV == 0) {
+   $main(-);
+} else {
+   foreach my $f (@ARGV) {
+   $main($f);
+   }
+}



iked address pools

2013-06-05 Thread Ryan Slack
I wish to submit a working implementation of address pools for iked,
however as it's my first real code contribution and has 643 lines
(mostly patch context) I'm wondering if posting here is the correct
channel.

Also, what is the preferred/normal way to include new files in a patch?

--Ryan Slack