Re: Static linking without PIE

2017-06-14 Thread Ted Unangst
Charles Collicutt wrote:
> On 14 June 2017 at 19:22, Ted Unangst  wrote:
> 
> > Charles Collicutt wrote:
> > > That works, thank you. gcc-local(1) only mentions -nopie as an option for
> > > the linker, so I thought it ought to be passed with -Wl,...
> >
> > I think I would interpret that sentence to mean linker as in the gcc
> > invoked
> > to link stuff. gcc -c is the compiler, gcc is the linker...
> >
> 
> ​Fair enough. But evidently -nopie is also a valid (but undocumented?)
> option for ​ld(1).
> 
> ​This came up because Go passes -Wl,-nopie to gcc if you run `go build` on
> OpenBSD. See:
> 
> https://github.com/golang/go/blob/master/src/cmd/link/internal/ld/lib.go#L1092
> 
> ​From what you're saying, this sounds like a bug in Go. They should just be
> passing -nopie. Is that right?

good question? sorry, there's some subtleties that I can never really keep
track of, but generally I follow the rule that it's best to let the compiler
sort things out instead of trying to manipulate ld options. doesn't help if
you really need to use ld directly. OpenBSD also changed some defaults, so
what works elsewhere may be different here. But I think passing -nopie to gcc
consistently (at least on openbsd) is the path of least resistance.



install.sub: ieee80211_{scan,config}: Allow quoted SSIDs

2017-06-14 Thread Klemens Nanni

Instead of ignoring SSIDs containing whitespaces, slightly adjust the
commands to take everything in between 'nwid ' and ' chan' as SSID; if
it has double quotes at start *and* end, simply remove those.

This enables users to select networks such as "Unitymedia WifiSpot"
"FRITZ!Box 7490" for example which are common among the quoted ones at
least here in germany.

The only SSIDs known to break this are those containing ' chan ' as this
substring is used as delimiter. Picking "some chan 4 me" would therefore
result in _nwid being assigned '"some' (literal double quote), but than
reasonably acceptable (compared to the current behaviour).


Since cat's -n flag already takes care of the space between numbers and
input lines, remove the leading tab to avoid excessive widths for lines
with long SSIDs.

Feedback/OK?

Index: install.sub
===
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1014
diff -u -p -r1.1014 install.sub
--- install.sub 3 Jun 2017 22:27:41 -   1.1014
+++ install.sub 14 Jun 2017 22:06:47 -
@@ -1060,10 +1060,9 @@ v6_config() {
# Perform an 802.11 network scan on interface $1.
# The result is cached in $WLANLIST.
ieee80211_scan() {
-   # N.B. Skipping quoted nwid's for now.
[[ -f $WLANLIST ]] ||
ifconfig $1 scan |
-   sed -n 's/^ nwid \([^"]\)/\1/p' >$WLANLIST
+   sed -n 's/^[[:space:]]*nwid //p' >$WLANLIST
cat $WLANLIST
}

@@ -1078,15 +1077,16 @@ ieee80211_config() {
# Empty scan cache.
rm -f $WLANLIST

-   while [[ -z $_nwid ]]; do
+   while [[ -z "$_nwid" ]]; do
ask_until "Access point? (ESSID, 'any', list# or '?')" "any"
case "$resp" in
+([0-9]))
-   _nwid=$(ieee80211_scan $_if | sed -n "${resp}s/ .*//p")
+   _nwid=$(ieee80211_scan $_if | sed -n ${resp}'{s/ chan 
.*//p;q;}')
[[ -z $_nwid ]] && echo "There is no line $resp."
+   [[ $_nwid = \"*\" ]] && _nwid=${_nwid#\"} 
_nwid=${_nwid%\"}
;;
\?) ieee80211_scan $_if |
-   sed -n 's/^\([^ ]*\) chan .* bssid \([^ ]*\) 
.*$/   \1 (\2)/p' |
+   sed -n 's/^\(.*\) chan .* bssid \([^ ]*\) 
.*$/\1 (\2)/p' |
cat -n | more -c
;;
*)  _nwid=$resp



Re: Static linking without PIE

2017-06-14 Thread Charles Collicutt
On 14 June 2017 at 19:22, Ted Unangst  wrote:

> Charles Collicutt wrote:
> > That works, thank you. gcc-local(1) only mentions -nopie as an option for
> > the linker, so I thought it ought to be passed with -Wl,...
>
> I think I would interpret that sentence to mean linker as in the gcc
> invoked
> to link stuff. gcc -c is the compiler, gcc is the linker...
>

​Fair enough. But evidently -nopie is also a valid (but undocumented?)
option for ​ld(1).

​This came up because Go passes -Wl,-nopie to gcc if you run `go build` on
OpenBSD. See:

https://github.com/golang/go/blob/master/src/cmd/link/internal/ld/lib.go#L1092

​From what you're saying, this sounds like a bug in Go. They should just be
passing -nopie. Is that right?

-- 
Charles


tweak installer to use vnetid/parent for vlan config

2017-06-14 Thread David Gwynne
the installer uses the vlan/vlandev ifconfig params to configure
vlan interfaces. this updates it to use vnetid and parent.

there's some semantic tweaks in here too. firstly, instead of
creating a vlan interface so it can be selected to configure, this
adds the next vlan interface to the list of options passed to
ask_which().

secondly, if you reconfigure a vlan interface, itll read the parent
as well as the tag off the parent to present as the default.

thanks to rpe@ for helping me with this.

ok?

Index: install.sub
===
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1014
diff -u -p -r1.1014 install.sub
--- install.sub 3 Jun 2017 22:27:41 -   1.1014
+++ install.sub 9 Jun 2017 08:28:57 -
@@ -1131,14 +1131,12 @@ ieee80211_config() {
 
 # Set up IPv4 and IPv6 interface configuration.
 configure_ifs() {
-   local _first _ifs _if _name _hn _vl=0 _vd _vi _p _tags
+   local _first _ifs _if _name _hn _vl=0 _vd _vi _p
 
# In case of restart, discover last vlan configured.
while :; do
_vd=$(ifconfig vlan$_vl 2>&1)
[[ $_vd == @(*no such interface*) ]] && break
-   [[ $_vd == @(*vlan: +([[:digit:]]) parent interface:*) ]] ||
-   break
((_vl++))
done
_vd=
@@ -1150,11 +1148,8 @@ configure_ifs() {
rm -f /tmp/i/mygate
 
while :; do
-   # Create new vlan if possible.
-   ifconfig vlan$_vl create >/dev/null 2>&1
-
ask_which "network interface" "do you wish to configure" \
-   '$(get_ifs)' \
+   "\$(get_ifs) vlan$_vl" \
${_p:-'$( (get_ifs netboot; get_ifs) | sed q )'}
[[ $resp == done ]] && break
 
@@ -1165,25 +1160,24 @@ configure_ifs() {
# If the offered vlan is chosen, ask the relevant
# questions and bring it up.
if [[ $_if == vlan+([0-9]) ]]; then
-   # Get existing tag for this vlan.
-   _vi=$(ifconfig $_if 2>/dev/null |
-   sed -n 's/vlan: \([0-9]*\).*/\1/p')
-   # Get list of all in-use tags.
-   _tags=$(ifconfig vlan 2>/dev/null |
-   sed -n 's/vlan: \([0-9]*\).*/\1/p')
-   # Current tag is a valid tag for this vlan.
-   [[ -n $_tags ]] && _tags=$(rmel "$_vi" $_tags)
+   # Get existing parent and tag for this vlan.
+   resp=$(ifconfig $_if 2>/dev/null |
+   sed -En 's/.encap: vnetid ([[:alnum:]]+) parent 
([[:alnum:]]+)/\2:\1/p')
+   _vd=${resp%%:*}
+   _vi=${resp##*:}
+
+   # If there's no existing tag, use the interface minor
if [[ -z $_vi ]]; then
-   _vi=0
-   while ((++_vi < 4096)); do
-   ! isin "$_vi" $_tags && break
-   done
+   _vi=${_if##vlan}
+   [[ $_vi -eq 0 ]] && _vi=none
fi
+
_ifs=$(get_ifs)
set -- $_ifs
while [[ $1 == vlan+([0-9]) ]]; do
shift
done
+   [[ $_vd == none ]] && _vd=
ask "Which interface:tag should $_if be on?" \
"${_vd:=$1}:$_vi"
_vd=${resp%%:*}
@@ -1193,13 +1187,16 @@ configure_ifs() {
if ! (isin "$_vd" $_ifs &&
[[ $_vd != vlan+([0-9]) ]]); then
echo "Invalid interface choice '$_vd'"
-   _vd=
continue
fi
 
-   # Validate range of $_vi as 1-4095, and $_vi not in use.
-   if ((_vi < 1 || _vi > 4095)) || isin "$_vi" $_tags; then
-   echo "Invalid or in-use vlan tag '$_vi'"
+   # Validate $_vi as 1-4095, or none
+   if [[ "$_vi" -ge 1 && "$_vi" -le 4095 ]]; then
+   _vi="vnetid $_vi"
+   elif [[ "$_vi" == "none" ]]; then
+   _vi="-vnetid"
+   else
+   echo "Invalid vlan tag '$_vi'"
continue
fi
 
@@ -1212,8 +1209,10 @@ configure_ifs() {
 
# Make sure a hostname.$_if is created with this info.
ifconfig $_if destroy >/dev/null 2>&1
- 

Re: Add support for rdonly keyword in fstab

2017-06-14 Thread Klemens Nanni

On Wed, Jun 14, 2017 at 07:54:48PM +0200, Jérôme FRGACIC wrote:
I recently realized that the word "rdonly" is not an alias for "ro" in 
the fstab file, which is inconsistent with the mount(1) command. I 
would suggest to add support for it with this small patch.

fstab(5) has always used ro/rw for this exclusively, which is sufficient
enough imho.

I dare say mount(8) actually has too many ways to say the same thing:
-r
-o ro
-r norw
-o rdonly

How about removing some of those?



Add support for rdonly keyword in fstab

2017-06-14 Thread Jérôme FRGACIC

Hi @tech,

I recently realized that the word "rdonly" is not an alias for "ro" in 
the fstab file, which is inconsistent with the mount(1) command. I would 
suggest to add support for it with this small patch.


Index: fstab.c
===
RCS file: /cvs/src/lib/libc/gen/fstab.c,v
retrieving revision 1.22
diff -u -p -u -r1.22 fstab.c
--- fstab.c 17 Mar 2016 23:48:42 -  1.22
+++ fstab.c 14 Jun 2017 17:53:24 -
@@ -116,8 +116,6 @@ fstabscan(void)
strlcpy(subline, _fs_fstab.fs_mntops, sizeof subline);
for (typexx = 0, cp = strtok_r(subline, ",", ); cp;
 cp = strtok_r(NULL, ",", )) {
-   if (strlen(cp) != 2)
-   continue;
if (!strcmp(cp, FSTAB_RW)) {
_fs_fstab.fs_type = FSTAB_RW;
break;
@@ -127,6 +125,10 @@ fstabscan(void)
break;
}
if (!strcmp(cp, FSTAB_RO)) {
+   _fs_fstab.fs_type = FSTAB_RO;
+   break;
+   }
+   if (!strcmp(cp, FSTAB_RDONLY)) {
_fs_fstab.fs_type = FSTAB_RO;
break;
}


Kind regards,


Jérôme FRGACIC



Re: Static linking without PIE

2017-06-14 Thread Ted Unangst
Charles Collicutt wrote:
> On 14 June 2017 at 17:34, Ted Unangst  wrote:
> 
> > gcc -static -nopie -o foo foo.c
> >
> 
> That works, thank you. gcc-local(1) only mentions -nopie as an option for
> the linker, so I thought it ought to be passed with -Wl,...
> 
> So passing -nopie to gcc both causes it to link against the correct crt0
> and also passes -nopie to the linker? And passing -nopie to the linker
> disables PIE generation but doesn't affect which crt0 it uses?

I think I would interpret that sentence to mean linker as in the gcc invoked
to link stuff. gcc -c is the compiler, gcc is the linker... 



Re: Static linking without PIE

2017-06-14 Thread Charles Collicutt
On 14 June 2017 at 17:34, Ted Unangst  wrote:

> gcc -static -nopie -o foo foo.c
>

That works, thank you. gcc-local(1) only mentions -nopie as an option for
the linker, so I thought it ought to be passed with -Wl,...

So passing -nopie to gcc both causes it to link against the correct crt0
and also passes -nopie to the linker? And passing -nopie to the linker
disables PIE generation but doesn't affect which crt0 it uses?

-- 
Charles


Re: Better handling of short reads

2017-06-14 Thread Ted Unangst
Mike Belopuhov wrote:
> On Wed, Jun 14, 2017 at 11:43 -0400, Ted Unangst wrote:
> > Mike Belopuhov wrote:
> > > still looking forward to replies to the original set of changes.
> > 
> > i'm a little in between. on the one hand, yes, ok, it's good that we don't
> > leave corrupted buffers around with bad data. on the other hand, don't we 
> > want
> > to learn about these problems and fix them? i don't think the change is 
> > wrong,
> > but it seems like it covers up another issue.
> 
> Device drivers do not consider such situations as issues.
> Yes, they're edge cases that we can't normally trigger,
> but they're not bugs in drivers since over the years
> developers have deliberately put such code there.

What I'm getting at is if these edge cases start happening in regular use,
we'd like to know about and fix the driver. :)

But I agree it's bad to pass weird stuff to the filesystem.

anyway, ok if you like it.

> 
> So I'm not entirely sure what do you think this is papering
> over.  There's a clear violation of contract between buffer
> cache and the filesystem: FFS asked for 16k, got 16k plus
> resid of 20k which is weird to say the least.



csh(1): close less file descriptors

2017-06-14 Thread Anton Lindqvist
Hi,
While studying the behavior of csh using ktrace I did notice it trying
to close every single fd up to _SC_OPEN_MAX except for the ones in use.
This seems a bit excessive, here's a different approach: since the fds
in use can vary one can't make assumptions about the largest fd in use.
Instead of looping over [0, _SC_OPEN_MAX), close all fds that reside in
between the gaps of fds in use. Once the largest fd in use is reached,
use closefrom().

Comments? OK?

Index: misc.c
===
RCS file: /cvs/src/bin/csh/misc.c,v
retrieving revision 1.19
diff -u -p -r1.19 misc.c
--- misc.c  14 Aug 2016 19:45:24 -  1.19
+++ misc.c  14 Jun 2017 16:50:38 -
@@ -38,6 +38,7 @@
 #include "csh.h"
 #include "extern.h"
 
+static int fdcmp(int);
 static int renum(int, int);
 
 int
@@ -163,6 +164,29 @@ lastchr(Char *cp)
 }
 
 /*
+ * Returns 0 if fd is in use, 1 if fd is greater than the largest used file
+ * descriptor and -1 otherwise.
+ */
+static int
+fdcmp(int fd)
+{
+int fds[] = { SHIN, SHOUT, SHERR, OLDSTD, FSHTTY };
+int i, max;
+
+max = -1;
+for (i = 0; i < sizeof(fds)/sizeof(fds[0]); i++) {
+   if (fd == fds[i])
+   return (0);
+   if (fds[i] > max)
+   max = fds[i];
+}
+if (fd > max)
+   return (1);
+
+return (-1);
+}
+
+/*
  * This routine is called after an error to close up
  * any units which may have been left open accidentally.
  */
@@ -173,9 +197,15 @@ closem(void)
 int max = sysconf(_SC_OPEN_MAX);
 
 for (f = 0; f < max; f++)
-   if (f != SHIN && f != SHOUT && f != SHERR && f != OLDSTD &&
-   f != FSHTTY)
-   (void) close(f);
+   switch (fdcmp(f)) {
+   case 0:
+   continue;
+   case 1:
+   closefrom(f);
+   return;
+   default:
+   close(f);
+   }
 }
 
 void



Re: CPU_LIDSUSPEND in init(8) and reboot(8)

2017-06-14 Thread Mike Larkin
On Wed, Jun 14, 2017 at 07:45:42AM +0200, Martin Natano wrote:
> ping?
> 

I think I said ok a long time ago.

-ml

> 
> On Sun, May 21, 2017 at 09:46:45AM +0200, Martin Natano wrote:
> > While switching init and reboot to CPU_LIDACTION, I forgot about the
> > #ifdef's. Ok?
> > 
> > natano
> > 
> > 
> > Index: init/init.c
> > ===
> > RCS file: /cvs/src/sbin/init/init.c,v
> > retrieving revision 1.64
> > diff -u -p -r1.64 init.c
> > --- init/init.c 3 May 2017 09:51:39 -   1.64
> > +++ init/init.c 21 May 2017 07:25:07 -
> > @@ -1325,7 +1325,7 @@ f_nice_death(void)
> > static const int death_sigs[3] = { SIGHUP, SIGTERM, SIGKILL };
> > int status;
> >  
> > -#ifdef CPU_LIDSUSPEND
> > +#ifdef CPU_LIDACTION
> > int mib[] = {CTL_MACHDEP, CPU_LIDACTION};
> > int lidaction = 0;
> >  
> > Index: reboot/reboot.c
> > ===
> > RCS file: /cvs/src/sbin/reboot/reboot.c,v
> > retrieving revision 1.36
> > diff -u -p -r1.36 reboot.c
> > --- reboot/reboot.c 2 Mar 2017 10:38:09 -   1.36
> > +++ reboot/reboot.c 21 May 2017 07:25:31 -
> > @@ -112,7 +112,7 @@ main(int argc, char *argv[])
> > if (geteuid())
> > errx(1, "%s", strerror(EPERM));
> >  
> > -#ifdef CPU_LIDSUSPEND
> > +#ifdef CPU_LIDACTION
> > if (howto & RB_POWERDOWN) {
> > /* Disable suspending on laptop lid close */
> > int mib[] = {CTL_MACHDEP, CPU_LIDACTION};
> > @@ -122,7 +122,7 @@ main(int argc, char *argv[])
> > sizeof(lidaction)) == -1 && errno != EOPNOTSUPP)
> > warn("sysctl");
> > }
> > -#endif /* CPU_LIDSUSPEND */
> > +#endif /* CPU_LIDACTION */
> >  
> > if (qflag) {
> > reboot(howto);
> 



Re: Static linking without PIE

2017-06-14 Thread Ted Unangst
Charles Collicutt wrote:
> Hi,
> 
> Is the following expected behaviour?
> 
> $ gcc -static -Wl,-nopie -Wl,-v -o foo foo.c

gcc -static -nopie -o foo foo.c



Re: Better handling of short reads

2017-06-14 Thread Mike Belopuhov
On Wed, Jun 14, 2017 at 11:43 -0400, Ted Unangst wrote:
> Mike Belopuhov wrote:
> > still looking forward to replies to the original set of changes.
> 
> i'm a little in between. on the one hand, yes, ok, it's good that we don't
> leave corrupted buffers around with bad data. on the other hand, don't we want
> to learn about these problems and fix them? i don't think the change is wrong,
> but it seems like it covers up another issue.

Device drivers do not consider such situations as issues.
Yes, they're edge cases that we can't normally trigger,
but they're not bugs in drivers since over the years
developers have deliberately put such code there.

So I'm not entirely sure what do you think this is papering
over.  There's a clear violation of contract between buffer
cache and the filesystem: FFS asked for 16k, got 16k plus
resid of 20k which is weird to say the least.



Static linking without PIE

2017-06-14 Thread Charles Collicutt
Hi,

Is the following expected behaviour?

$ gcc -static -Wl,-nopie -Wl,-v -o foo foo.c

collect2 version 4.2.1 20070719  (OpenBSD/x86-64 ELF)
/usr/bin/ld -e __start -Bstatic -dynamic-linker /usr/libexec/ld.so -o foo
/usr/lib/rcrt0.o /usr/lib/crtbegin.o
-L/usr/lib/gcc-lib/amd64-unknown-openbsd6.1/4.2.1 -nopie -v
/tmp//ccZ7VS0V.o -lgcc -lc -lgcc /usr/lib/crtend.o
GNU ld version 2.17
/usr/lib/rcrt0.o: In function `__start':
(.text+0x1a): undefined reference to `_DYNAMIC'
collect2: ld returned 1 exit status


I was
​expecting the -Wl,-nopie option to cause it to link against crt0.o but
instead it seems to try to link against rcrt0.o but fails.

This was using 6.1-release.

-- 
Charles


Re: Better handling of short reads

2017-06-14 Thread Ted Unangst
Mike Belopuhov wrote:
> still looking forward to replies to the original set of changes.

i'm a little in between. on the one hand, yes, ok, it's good that we don't
leave corrupted buffers around with bad data. on the other hand, don't we want
to learn about these problems and fix them? i don't think the change is wrong,
but it seems like it covers up another issue.



install.sub: Clean v[46]_info() ouput

2017-06-14 Thread Klemens Nanni

With this patch, v[46]_info() both output exactly what their description
says.

As of now, these functions are only used through
set -- $(v4_info $_if)
which gracefully handles any constellation of whitespaces in the output
just fine. However future usage might change (or not) and being precise
about a function's output doesn't hurt.

The sed command itself is a tad clearer/smarter that way as well, imho.

Here's what I mean (whitespaces visualised):

$ v4_info trunk0
UP
›   ·192.168.1.2··0xff00·broadcast·192.168.1.255
$ v4_info_clean trunk0
UP
192.168.1.2·0xff00·broadcast·192.168.1.255


Feeback/OK?

Index: install.sub
===
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1014
diff -u -p -r1.1014 install.sub
--- install.sub 3 Jun 2017 22:27:41 -   1.1014
+++ install.sub 14 Jun 2017 15:13:05 -
@@ -896,13 +896,14 @@ __EOT
}

# Obtain and output the inet information related to interface $1.
-# Should output '   '.
+# Outputs '\n  '.
v4_info() {
ifconfig $1 inet | sed -n '
-   1s/.*

Re: Better handling of short reads

2017-06-14 Thread Mike Belopuhov
On Wed, Jun 14, 2017 at 09:12 -0600, Bob Beck wrote:
> 
> > As you all might have gathered by now Amit has jumped the gun
> > but was wrong to do so.  His setup is not affected by this change.
> > That was expected so please don't get distracted by this as I'm
> > still looking forward to replies to the original set of changes.
> > beck@?
> > 
> > > diff --git sys/kern/vfs_bio.c sys/kern/vfs_bio.c
> > > index 95bc80bc0e6..9316e6e0eb2 100644
> > > --- sys/kern/vfs_bio.c
> > > +++ sys/kern/vfs_bio.c
> > > @@ -534,10 +534,27 @@ bread_cluster_callback(struct buf *bp)
> > >*/
> > >   buf_fix_mapping(bp, newsize);
> > >   bp->b_bcount = newsize;
> > >   }
> > >  
> > > + /* Invalidate read-ahead buffers if read short */
> > > + if (bp->b_resid > 0) {
> > > + printf("read %ld resid %ld\n", bp->b_bcount, bp->b_resid);
> 
> Should the printf actually be here?  I'm not thinking this thing 
> spewing dmesg like a banshee if we get short reads is really going
> to help anything
>

You're looking at the wrong diff.  Please look at the first mail in
the thread.  This one was for Amit.

> > > + for (i = 0; xbpp[i] != NULL; i++)
> > > + continue;
> > > + for (i = i - 1; i != 0; i--) {
> > > + if (xbpp[i]->b_bufsize <= bp->b_resid) {
> > > + bp->b_resid -= xbpp[i]->b_bufsize;
> > > + SET(xbpp[i]->b_flags, B_INVAL);
> > > + } else if (bp->b_resid > 0) {
> > > + bp->b_resid = 0;
> > > + SET(xbpp[i]->b_flags, B_INVAL);
> > > + } else
> > > + break;
> > > + }
> > > + }
> > > +
> > >   for (i = 1; xbpp[i] != 0; i++) {
> > >   if (ISSET(bp->b_flags, B_ERROR))
> > >   SET(xbpp[i]->b_flags, B_INVAL | B_ERROR);
> > >   biodone(xbpp[i]);
> > >   }
> > 



Re: Better handling of short reads

2017-06-14 Thread Bob Beck

> As you all might have gathered by now Amit has jumped the gun
> but was wrong to do so.  His setup is not affected by this change.
> That was expected so please don't get distracted by this as I'm
> still looking forward to replies to the original set of changes.
> beck@?
> 
> > diff --git sys/kern/vfs_bio.c sys/kern/vfs_bio.c
> > index 95bc80bc0e6..9316e6e0eb2 100644
> > --- sys/kern/vfs_bio.c
> > +++ sys/kern/vfs_bio.c
> > @@ -534,10 +534,27 @@ bread_cluster_callback(struct buf *bp)
> >  */
> > buf_fix_mapping(bp, newsize);
> > bp->b_bcount = newsize;
> > }
> >  
> > +   /* Invalidate read-ahead buffers if read short */
> > +   if (bp->b_resid > 0) {
> > +   printf("read %ld resid %ld\n", bp->b_bcount, bp->b_resid);

Should the printf actually be here?  I'm not thinking this thing 
spewing dmesg like a banshee if we get short reads is really going
to help anything

> > +   for (i = 0; xbpp[i] != NULL; i++)
> > +   continue;
> > +   for (i = i - 1; i != 0; i--) {
> > +   if (xbpp[i]->b_bufsize <= bp->b_resid) {
> > +   bp->b_resid -= xbpp[i]->b_bufsize;
> > +   SET(xbpp[i]->b_flags, B_INVAL);
> > +   } else if (bp->b_resid > 0) {
> > +   bp->b_resid = 0;
> > +   SET(xbpp[i]->b_flags, B_INVAL);
> > +   } else
> > +   break;
> > +   }
> > +   }
> > +
> > for (i = 1; xbpp[i] != 0; i++) {
> > if (ISSET(bp->b_flags, B_ERROR))
> > SET(xbpp[i]->b_flags, B_INVAL | B_ERROR);
> > biodone(xbpp[i]);
> > }
> 



Re: Better handling of short reads

2017-06-14 Thread Bob Beck
 - ok mike, I'm looking at it..   Allow me a short while to beat my
head against a wall for a bit to get it into readahead mode...


On Wed, Jun 14, 2017 at 3:56 AM, Mike Belopuhov  wrote:

> On Thu, Jun 08, 2017 at 11:55 +0200, Mike Belopuhov wrote:
> > On Wed, Jun 07, 2017 at 23:04 -0500, Amit Kulkarni wrote:
> > > On Wed, 7 Jun 2017 21:27:27 -0500
> > > Amit Kulkarni  wrote:
> > >
> > > > On Thu, 8 Jun 2017 01:57:25 +0200
> > > > Mike Belopuhov  wrote:
> > > >
> > > > > On Wed, Jun 07, 2017 at 18:35 -0500, Amit Kulkarni wrote:
> > > > > > Wow, please get this in!!!
> > > > > >
> > > > > > This fixes cvs update on hard disks, to go much much faster.
> When I am
> > > > > > updating the entire set of cvs trees: www, src, xenocara, ports,
> I can
> > > > > > still use firefox and have it perfectly usable. There's a night
> and
> > > > > > day improvement, before and after. Thanks for debugging and
> fixing
> > > > > > this.
> > > > > >
> > > > >
> > > > > What kind of broken hardware do you have that this diff helps you?
> > > > > Can you show us your dmesg?
> > > > >
> > >
> > > Please ignore previous dmesg, it was incomplete.
> > >
> >
> > Are you 100% sure this diff changes anything for you?
> > Can you please try the one below.  It adds a printf.
> >
>
> As you all might have gathered by now Amit has jumped the gun
> but was wrong to do so.  His setup is not affected by this change.
> That was expected so please don't get distracted by this as I'm
> still looking forward to replies to the original set of changes.
> beck@?
>
> > diff --git sys/kern/vfs_bio.c sys/kern/vfs_bio.c
> > index 95bc80bc0e6..9316e6e0eb2 100644
> > --- sys/kern/vfs_bio.c
> > +++ sys/kern/vfs_bio.c
> > @@ -534,10 +534,27 @@ bread_cluster_callback(struct buf *bp)
> >*/
> >   buf_fix_mapping(bp, newsize);
> >   bp->b_bcount = newsize;
> >   }
> >
> > + /* Invalidate read-ahead buffers if read short */
> > + if (bp->b_resid > 0) {
> > + printf("read %ld resid %ld\n", bp->b_bcount, bp->b_resid);
> > + for (i = 0; xbpp[i] != NULL; i++)
> > + continue;
> > + for (i = i - 1; i != 0; i--) {
> > + if (xbpp[i]->b_bufsize <= bp->b_resid) {
> > + bp->b_resid -= xbpp[i]->b_bufsize;
> > + SET(xbpp[i]->b_flags, B_INVAL);
> > + } else if (bp->b_resid > 0) {
> > + bp->b_resid = 0;
> > + SET(xbpp[i]->b_flags, B_INVAL);
> > + } else
> > + break;
> > + }
> > + }
> > +
> >   for (i = 1; xbpp[i] != 0; i++) {
> >   if (ISSET(bp->b_flags, B_ERROR))
> >   SET(xbpp[i]->b_flags, B_INVAL | B_ERROR);
> >   biodone(xbpp[i]);
> >   }
>
>


Re: Better handling of short reads

2017-06-14 Thread Amit Kulkarni
On Wed, Jun 14, 2017 at 4:56 AM, Mike Belopuhov  wrote:
> On Thu, Jun 08, 2017 at 11:55 +0200, Mike Belopuhov wrote:
>> On Wed, Jun 07, 2017 at 23:04 -0500, Amit Kulkarni wrote:
>> > On Wed, 7 Jun 2017 21:27:27 -0500
>> > Amit Kulkarni  wrote:
>> >
>> > > On Thu, 8 Jun 2017 01:57:25 +0200
>> > > Mike Belopuhov  wrote:
>> > >
>> > > > On Wed, Jun 07, 2017 at 18:35 -0500, Amit Kulkarni wrote:
>> > > > > Wow, please get this in!!!
>> > > > >
>> > > > > This fixes cvs update on hard disks, to go much much faster. When I 
>> > > > > am
>> > > > > updating the entire set of cvs trees: www, src, xenocara, ports, I 
>> > > > > can
>> > > > > still use firefox and have it perfectly usable. There's a night and
>> > > > > day improvement, before and after. Thanks for debugging and fixing
>> > > > > this.
>> > > > >
>> > > >
>> > > > What kind of broken hardware do you have that this diff helps you?
>> > > > Can you show us your dmesg?
>> > > >
>> >
>> > Please ignore previous dmesg, it was incomplete.
>> >
>>
>> Are you 100% sure this diff changes anything for you?
>> Can you please try the one below.  It adds a printf.
>>
>
> As you all might have gathered by now Amit has jumped the gun
> but was wrong to do so.  His setup is not affected by this change.
> That was expected so please don't get distracted by this as I'm
> still looking forward to replies to the original set of changes.
> beck@?
>

Yes, my fault.

But some change has seriously improved cvs update during the timeframe
when mike posted this diff.

Thanks



Re: m4(1): add -e flag support

2017-06-14 Thread Brian Callahan


On 6/14/2017 10:18 AM, marc espie wrote:
> on wed, jun 14, 2017 at 09:58:54am -0400, brian callahan wrote:
>> hi marc --
>>
>> how's this version?
>> also includes a slight tweak to the single -e flag regress test.
>>
>> ~brian
> comment nit, otherwise good.
>
>> +extern int error_warns; /* make warnings cause exit_code > 0 */
> exit_code = 1, why > 0 when you actually specify the result everywhere ?

Hmm... it's just supposed to be non-zero. Guess that morphed into > 0 in
my head. No reason to not just specify it since that's what the code does.



Re: m4(1): add -e flag support

2017-06-14 Thread marc espie
on wed, jun 14, 2017 at 09:58:54am -0400, brian callahan wrote:
> hi marc --
> 
> how's this version?
> also includes a slight tweak to the single -e flag regress test.
> 
> ~brian
comment nit, otherwise good.

> +extern int error_warns;  /* make warnings cause exit_code > 0 */
exit_code = 1, why > 0 when you actually specify the result everywhere ?



Re: m4(1): add -E flag support

2017-06-14 Thread Brian Callahan
Hi Marc --

How's this version?
Also includes a slight tweak to the single -E flag regress test.

~Brian

Index: usr.bin/m4/eval.c
===
RCS file: /cvs/src/usr.bin/m4/eval.c,v
retrieving revision 1.74
diff -u -p -u -p -r1.74 eval.c
--- usr.bin/m4/eval.c   5 Feb 2015 12:59:57 -   1.74
+++ usr.bin/m4/eval.c   14 Jun 2017 13:50:07 -
@@ -269,6 +269,10 @@ expand_builtin(const char *argv[], int a
warn("%s at line %lu: include(%s)",
CURRENT_NAME, CURRENT_LINE, 
argv[2]);
exit_code = 1;
+   if (fatal_warns) {
+   killdiv();
+   exit(exit_code);
+   }
} else
err(1, "%s at line %lu: include(%s)",
CURRENT_NAME, CURRENT_LINE, 
argv[2]);
Index: usr.bin/m4/extern.h
===
RCS file: /cvs/src/usr.bin/m4/extern.h,v
retrieving revision 1.54
diff -u -p -u -p -r1.54 extern.h
--- usr.bin/m4/extern.h 12 May 2014 19:11:19 -  1.54
+++ usr.bin/m4/extern.h 14 Jun 2017 13:50:07 -
@@ -58,6 +58,8 @@ extern void doesyscmd(const char *);
 extern void getdivfile(const char *);
 extern void doformat(const char *[], int);
 
+extern void m4_warnx(const char *, ...);
+
 /* look.c */
 
 #define FLAG_UNTRACED 0
@@ -175,4 +177,6 @@ extern int  synch_lines;/* line synchro
 
 extern int mimic_gnu;  /* behaves like gnu-m4 */
 extern int prefix_builtins;/* prefix builtin macros with m4_ */
+extern int error_warns;/* make warnings cause exit_code > 0 */
+extern int fatal_warns;/* make warnings fatal */
 
Index: usr.bin/m4/gnum4.c
===
RCS file: /cvs/src/usr.bin/m4/gnum4.c,v
retrieving revision 1.50
diff -u -p -u -p -r1.50 gnum4.c
--- usr.bin/m4/gnum4.c  29 Apr 2015 00:13:26 -  1.50
+++ usr.bin/m4/gnum4.c  14 Jun 2017 13:50:07 -
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -234,7 +235,7 @@ addchar(int c)
 }
 
 static char *
-getstring()
+getstring(void)
 {
addchar('\0');
current = 0;
@@ -255,11 +256,29 @@ exit_regerror(int er, regex_t *re, const
m4errx(1, "regular expression error in %s: %s.", source, errbuf);
 }
 
+/* warnx() plus check to see if we need to change exit code or exit.
+ * -E flag functionality.
+ */
+void
+m4_warnx(const char *fmt, ...)
+{
+   va_list ap;
+
+   va_start(ap, fmt);
+   vwarnx(fmt, ap);
+   va_end(ap);
+
+   if (fatal_warns)
+   exit(1);
+   if (error_warns)
+   exit_code = 1;
+}
+
 static void
 add_sub(int n, const char *string, regex_t *re, regmatch_t *pm)
 {
if (n > re->re_nsub)
-   warnx("No subexpression %d", n);
+   m4_warnx("No subexpression %d", n);
/* Subexpressions that did not match are
 * not an error.  */
else if (pm[n].rm_so != -1 &&
@@ -442,7 +461,7 @@ void
 dopatsubst(const char *argv[], int argc)
 {
if (argc <= 3) {
-   warnx("Too few arguments to patsubst");
+   m4_warnx("Too few arguments to patsubst");
return;
}
/* special case: empty regexp */
@@ -494,7 +513,7 @@ doregexp(const char *argv[], int argc)
const char *source;
 
if (argc <= 3) {
-   warnx("Too few arguments to regexp");
+   m4_warnx("Too few arguments to regexp");
return;
}
/* special gnu case */
Index: usr.bin/m4/m4.1
===
RCS file: /cvs/src/usr.bin/m4/m4.1,v
retrieving revision 1.63
diff -u -p -u -p -r1.63 m4.1
--- usr.bin/m4/m4.1 14 Sep 2015 20:06:58 -  1.63
+++ usr.bin/m4/m4.1 14 Jun 2017 13:50:07 -
@@ -38,7 +38,7 @@
 .Nd macro language processor
 .Sh SYNOPSIS
 .Nm
-.Op Fl gPs
+.Op Fl EgPs
 .Oo
 .Sm off
 .Fl D Ar name Op No = Ar value
@@ -127,6 +127,19 @@ turn on all options.
 .Pp
 By default, trace is set to
 .Qq eq .
+.It Fl E
+Set warnings to be fatal.
+When a single
+.Fl E
+flag is specified, if warnings are issued, execution continues but
+.Nm
+will exit with a non-zero exit status.
+When multiple
+.Fl E
+flags are specified, execution will halt upon issuing the first warning and
+.Nm
+will exit with a non-zero exit status.
+This behaviour matches GNU-m4 1.4.9 and later.
 .It Fl g
 Activate GNU-m4 compatibility mode.
 In this mode, translit handles simple character
@@ -434,7 +447,9 @@ Returns the current file's name.
 .Pp
 But note that the
 .Ic m4exit
-macro can modify the exit 

Re: pool cpu caches and a systat view of them

2017-06-14 Thread Todd C. Miller
This looks useful to me.  Do you plan to do anything with the fails
stats?

 - todd



Re: tweak txp to avoid ifq_deq_begin/commit/rollback

2017-06-14 Thread Mike Belopuhov
On Mon, Jun 05, 2017 at 16:13 +0200, Mike Belopuhov wrote:
> On Wed, May 31, 2017 at 20:40 +0200, Mike Belopuhov wrote:
> > According to the FreeBSD driver, txp(4) is not setting up its TX
> > ring correctly.  FreeBSD driver uses up to 16 fragments, while we
> > use up to 252 which is suspicious.
> > 
> > This gets us in line with FreeBSD, introduces goodness of m_defrag
> > and removes pesky if_deq_* thingies.
> > 
> > Does anyone still have the hardware (3com 3CR900 Typhoon) to test?
> > OK's are welcome.
> >
> 
> Any OKs? Tests? Should I go ahead with this?
>

I've heard no objections to this so the best way to test it
would be to get this in.

> > diff --git sys/dev/pci/if_txp.c sys/dev/pci/if_txp.c
> > index deede70e9de..1aed06765c0 100644
> > --- sys/dev/pci/if_txp.c
> > +++ sys/dev/pci/if_txp.c
> > @@ -883,12 +883,12 @@ txp_alloc_rings(struct txp_softc *sc)
> > sc->sc_txhir.r_desc = (struct txp_tx_desc 
> > *)sc->sc_txhiring_dma.dma_vaddr;
> > sc->sc_txhir.r_cons = sc->sc_txhir.r_prod = sc->sc_txhir.r_cnt = 0;
> > sc->sc_txhir.r_off = >sc_hostvar->hv_tx_hi_desc_read_idx;
> > for (i = 0; i < TX_ENTRIES; i++) {
> > if (bus_dmamap_create(sc->sc_dmat, TXP_MAX_PKTLEN,
> > -   TX_ENTRIES - 4, TXP_MAX_SEGLEN, 0,
> > -   BUS_DMA_NOWAIT, >sc_txd[i].sd_map) != 0) {
> > +   TXP_MAXTXSEGS, MCLBYTES, 0, BUS_DMA_NOWAIT,
> > +   >sc_txd[i].sd_map) != 0) {
> > for (j = 0; j < i; j++) {
> > bus_dmamap_destroy(sc->sc_dmat,
> > sc->sc_txd[j].sd_map);
> > sc->sc_txd[j].sd_map = NULL;
> > }
> > @@ -1261,57 +1261,48 @@ txp_start(struct ifnet *ifp)
> > struct txp_softc *sc = ifp->if_softc;
> > struct txp_tx_ring *r = >sc_txhir;
> > struct txp_tx_desc *txd;
> > int txdidx;
> > struct txp_frag_desc *fxd;
> > -   struct mbuf *m, *mnew;
> > +   struct mbuf *m;
> > struct txp_swdesc *sd;
> > u_int32_t firstprod, firstcnt, prod, cnt, i;
> >  
> > if (!(ifp->if_flags & IFF_RUNNING) || ifq_is_oactive(>if_snd))
> > return;
> >  
> > prod = r->r_prod;
> > cnt = r->r_cnt;
> >  
> > while (1) {
> > -   m = ifq_deq_begin(>if_snd);
> > +   if (cnt >= TX_ENTRIES - TXP_MAXTXSEGS - 4)
> > +   goto oactive;
> > +
> > +   m = ifq_dequeue(>if_snd);
> > if (m == NULL)
> > break;
> > -   mnew = NULL;
> >  
> > firstprod = prod;
> > firstcnt = cnt;
> >  
> > sd = sc->sc_txd + prod;
> > sd->sd_mbuf = m;
> >  
> > -   if (bus_dmamap_load_mbuf(sc->sc_dmat, sd->sd_map, m,
> > +   switch (bus_dmamap_load_mbuf(sc->sc_dmat, sd->sd_map, m,
> > BUS_DMA_NOWAIT)) {
> > -   MGETHDR(mnew, M_DONTWAIT, MT_DATA);
> > -   if (mnew == NULL)
> > -   goto oactive1;
> > -   if (m->m_pkthdr.len > MHLEN) {
> > -   MCLGET(mnew, M_DONTWAIT);
> > -   if ((mnew->m_flags & M_EXT) == 0) {
> > -   m_freem(mnew);
> > -   goto oactive1;
> > -   }
> > -   }
> > -   m_copydata(m, 0, m->m_pkthdr.len, mtod(mnew, caddr_t));
> > -   mnew->m_pkthdr.len = mnew->m_len = m->m_pkthdr.len;
> > -   ifq_deq_commit(>if_snd, m);
> > +   case 0:
> > +   break;
> > +   case EFBIG:
> > +   if (m_defrag(m, M_DONTWAIT) == 0 &&
> > +   bus_dmamap_load_mbuf(sc->sc_dmat, sd->sd_map, m,
> > +   BUS_DMA_NOWAIT) == 0)
> > +   break;
> > +   default:
> > m_freem(m);
> > -   m = mnew;
> > -   if (bus_dmamap_load_mbuf(sc->sc_dmat, sd->sd_map, m,
> > -   BUS_DMA_NOWAIT))
> > -   goto oactive1;
> > +   continue;
> > }
> >  
> > -   if ((TX_ENTRIES - cnt) < 4)
> > -   goto oactive;
> > -
> > txd = r->r_desc + prod;
> > txdidx = prod;
> > txd->tx_flags = TX_FLAGS_TYPE_DATA;
> > txd->tx_numdesc = 0;
> > txd->tx_addrlo = 0;
> > @@ -1321,13 +1312,10 @@ txp_start(struct ifnet *ifp)
> > txd->tx_numdesc = sd->sd_map->dm_nsegs;
> >  
> > if (++prod == TX_ENTRIES)
> > prod = 0;
> >  
> > -   if (++cnt >= (TX_ENTRIES - 4))
> > -   goto oactive;
> > -
> >  #if NVLAN > 0
> > if (m->m_flags & M_VLANTAG) {
> > txd->tx_pflags = TX_PFLAGS_VLAN |
> > (htons(m->m_pkthdr.ether_vtag) << 
> > 

Re: Better handling of short reads

2017-06-14 Thread Mike Belopuhov
On Thu, Jun 08, 2017 at 11:55 +0200, Mike Belopuhov wrote:
> On Wed, Jun 07, 2017 at 23:04 -0500, Amit Kulkarni wrote:
> > On Wed, 7 Jun 2017 21:27:27 -0500
> > Amit Kulkarni  wrote:
> > 
> > > On Thu, 8 Jun 2017 01:57:25 +0200
> > > Mike Belopuhov  wrote:
> > > 
> > > > On Wed, Jun 07, 2017 at 18:35 -0500, Amit Kulkarni wrote:
> > > > > Wow, please get this in!!!
> > > > > 
> > > > > This fixes cvs update on hard disks, to go much much faster. When I am
> > > > > updating the entire set of cvs trees: www, src, xenocara, ports, I can
> > > > > still use firefox and have it perfectly usable. There's a night and
> > > > > day improvement, before and after. Thanks for debugging and fixing
> > > > > this.
> > > > >
> > > > 
> > > > What kind of broken hardware do you have that this diff helps you?
> > > > Can you show us your dmesg?
> > > > 
> > 
> > Please ignore previous dmesg, it was incomplete.
> > 
> 
> Are you 100% sure this diff changes anything for you?
> Can you please try the one below.  It adds a printf.
>

As you all might have gathered by now Amit has jumped the gun
but was wrong to do so.  His setup is not affected by this change.
That was expected so please don't get distracted by this as I'm
still looking forward to replies to the original set of changes.
beck@?

> diff --git sys/kern/vfs_bio.c sys/kern/vfs_bio.c
> index 95bc80bc0e6..9316e6e0eb2 100644
> --- sys/kern/vfs_bio.c
> +++ sys/kern/vfs_bio.c
> @@ -534,10 +534,27 @@ bread_cluster_callback(struct buf *bp)
>*/
>   buf_fix_mapping(bp, newsize);
>   bp->b_bcount = newsize;
>   }
>  
> + /* Invalidate read-ahead buffers if read short */
> + if (bp->b_resid > 0) {
> + printf("read %ld resid %ld\n", bp->b_bcount, bp->b_resid);
> + for (i = 0; xbpp[i] != NULL; i++)
> + continue;
> + for (i = i - 1; i != 0; i--) {
> + if (xbpp[i]->b_bufsize <= bp->b_resid) {
> + bp->b_resid -= xbpp[i]->b_bufsize;
> + SET(xbpp[i]->b_flags, B_INVAL);
> + } else if (bp->b_resid > 0) {
> + bp->b_resid = 0;
> + SET(xbpp[i]->b_flags, B_INVAL);
> + } else
> + break;
> + }
> + }
> +
>   for (i = 1; xbpp[i] != 0; i++) {
>   if (ISSET(bp->b_flags, B_ERROR))
>   SET(xbpp[i]->b_flags, B_INVAL | B_ERROR);
>   biodone(xbpp[i]);
>   }



Re: Copying a file on msdos FS (fat32) changes content

2017-06-14 Thread Stefan Fritsch
On Tue, 13 Jun 2017, Martijn Rijkeboer wrote:
> Yes, this patch fixes the problem.

Thanks for the report and the testing. I have committed the revert 
yesterday.



Re: m4(1): add -E flag support

2017-06-14 Thread Marc Espie
On Tue, Jun 13, 2017 at 05:05:56PM -0400, Brian Callahan wrote:
> Hi --
> 
> Whoops, that was unintentional. Fixed.
> 
> ~Brian

Sorry for not looking sooner.

I would rather you use two variables for -E flags. e.g., set
error_warns for one -E flag, and  fatal_warns for multiple -E flags.

That way, most of your comments would be no longer necessary at all. ;)

I mean:

> Index: usr.bin/m4/eval.c
> ===
> RCS file: /cvs/src/usr.bin/m4/eval.c,v
> retrieving revision 1.74
> diff -u -p -u -p -r1.74 eval.c
> --- usr.bin/m4/eval.c 5 Feb 2015 12:59:57 -   1.74
> +++ usr.bin/m4/eval.c 13 Jun 2017 21:03:15 -
> @@ -269,6 +269,12 @@ expand_builtin(const char *argv[], int a
>   warn("%s at line %lu: include(%s)",
>   CURRENT_NAME, CURRENT_LINE, 
> argv[2]);
>   exit_code = 1;
That comment:
> + /* exit immediately if multiple -E flags
> +  */
> + if (fatal_warns == 2) {
> + killdiv();
> + exit(exit_code);
> + }
>   } else
>   err(1, "%s at line %lu: include(%s)",
>   CURRENT_NAME, CURRENT_LINE, 
> argv[2]);
> Index: usr.bin/m4/gnum4.c
> ===
> RCS file: /cvs/src/usr.bin/m4/gnum4.c,v
> retrieving revision 1.50
> diff -u -p -u -p -r1.50 gnum4.c
> --- usr.bin/m4/gnum4.c29 Apr 2015 00:13:26 -  1.50
> +++ usr.bin/m4/gnum4.c13 Jun 2017 21:03:15 -
> @@ -255,11 +256,35 @@ exit_regerror(int er, regex_t *re, const
>   m4errx(1, "regular expression error in %s: %s.", source, errbuf);
>  }
>  
> +/* warnx() plus check to see if we need to change exit code or exit.
> + * -E flag functionality.
> + */
> +void
> +m4_warnx(const char *fmt, ...)
> +{
> + va_list ap;
> +
> + va_start(ap, fmt);
> + vwarnx(fmt, ap);
> + va_end(ap);
> +
and that code:
> + /* Do nothing if no -E flags, set exit_code > 0 but keep going
> +  * if one -E flag, exit immediately with exit status > 0 if
> +  * two or more -E flags.
> +  */
> + if (fatal_warns == 0)
> + return;
> + else if (fatal_warns == 1)
> + exit_code = 1;
> + else
> + exit(1);
> +}
> +
which would become something like:
if (fatal_warns)
exit(1);
if (error_warns)
exit_code = 1;

no need for any comment



Re: pool cpu caches and a systat view of them

2017-06-14 Thread Mike Belopuhov
On Wed, Jun 14, 2017 at 13:50 +1000, David Gwynne wrote:
> i have a few things left to do in the pools per cpu caches, one of
> which is make their activity visibile. to that end, here's a diff
> provides a way for userland to request stats from the per cpu caches,
> and uses that in systat so you can watch them.
> 
> there are two added pool sysctls. one copies an array of stats from
> each cpus cache. the interesting bits in those stats are how many
> items each cpu handled, and how many list operations the cpu did
> against the global pool cache.
> 
> the second sysctl reports stats about the global pool cache. currently
> this is the target for the list length the cpus build is, how many
> lists its holding, and how many times the gc has moved a list of
> items back into the pool for recovery.
> 
> these are used by sysctl for a new view which ive called pcaches,
> short for pool caches.
> 

I think this is a nice addition.  It would be nice to have some
(at least terse) description of fields in the man page itself.
In any case, OK mikeb



mailwrapper(8): remove main() prototype

2017-06-14 Thread Anton Lindqvist
Hi,
The prototype for main() is inherited from the import of mailwrapper
back in 1999. While at it, my understanding is that the envp argument
can also be removed since the environ is unaltered. This however
requires changing the calls from execve() to execv(). Where execv() is
appropriate since every entry in /etc/mailer.conf should resolve to an
executable path as I read it the manual.

Comments? OK?

Index: mailwrapper.c
===
RCS file: /cvs/src/usr.sbin/mailwrapper/mailwrapper.c,v
retrieving revision 1.22
diff -u -p -r1.22 mailwrapper.c
--- mailwrapper.c   28 Dec 2015 16:27:28 -  1.22
+++ mailwrapper.c   13 Jun 2017 18:00:24 -
@@ -48,8 +48,6 @@ struct arglist {
char **argv;
 };
 
-int main(int, char *[], char *[]);
-
 static void initarg(struct arglist *);
 static void addarg(struct arglist *, const char *);
 
@@ -78,7 +76,7 @@ addarg(struct arglist *al, const char *a
 }
 
 int
-main(int argc, char *argv[], char *envp[])
+main(int argc, char *argv[])
 {
FILE *config;
char *line, *cp, *from, *to, *ap;
@@ -108,7 +106,7 @@ main(int argc, char *argv[], char *envp[
syslog(LOG_INFO, "cannot open %s, using %s as default MTA",
_PATH_MAILERCONF, _PATH_DEFAULTMTA);
closelog();
-   execve(_PATH_DEFAULTMTA, al.argv, envp);
+   execv(_PATH_DEFAULTMTA, al.argv);
err(1, "cannot exec %s", _PATH_DEFAULTMTA);
/*NOTREACHED*/
}
@@ -153,7 +151,7 @@ main(int argc, char *argv[], char *envp[
 
addarg(, NULL);
 
-   execve(to, al.argv, envp);
+   execv(to, al.argv);
err(1, "cannot exec %s", to);
/*NOTREACHED*/
 parse_error: