Re: If you are one of the cool kids who cranks kern.bufcachepercent up..

2010-01-09 Thread Grumpy
  @@ -350,7 +359,7 @@
   * referencing buffers.
   */
  toggle ^= 1;
  -   if (numvnodes  2 * maxvnodes)
  +   if (numvnodes / 2  maxvnodes)
  toggle = 0;
 
 + if ((numvnodes  1)  maxvnodes)
 
 slightly better?

I find your lack of faith in the compiler disturbing.



Re: If you are one of the cool kids who cranks kern.bufcachepercent up..

2010-01-09 Thread patrick keshishian
On Sat, Jan 09, 2010 at 04:05:13AM -0700, Bob Beck wrote:
[dd]
 -Bob
 
 
 Index: kern/vfs_subr.c
 ===
 RCS file: /cvs/src/sys/kern/vfs_subr.c,v
 retrieving revision 1.184
 diff -u -r1.184 vfs_subr.c
 @@ -350,7 +359,7 @@
* referencing buffers.
*/
   toggle ^= 1;
 - if (numvnodes  2 * maxvnodes)
 + if (numvnodes / 2  maxvnodes)
   toggle = 0;

+   if ((numvnodes  1)  maxvnodes)

slightly better?

--patrick



Re: If you are one of the cool kids who cranks kern.bufcachepercent up..

2010-01-09 Thread Philip Guenther
On Saturday, January 9, 2010, Joerg Sonnenberger
jo...@britannica.bec.de wrote:
 On Sat, Jan 09, 2010 at 08:15:20PM +, Grumpy wrote:
   @@ -350,7 +359,7 @@
  * referencing buffers.
  */
 toggle ^= 1;
   - if (numvnodes  2 * maxvnodes)
   + if (numvnodes / 2  maxvnodes)
 toggle = 0;
 
  +   if ((numvnodes  1)  maxvnodes)
 
  slightly better?

 I find your lack of faith in the compiler disturbing.

 I find your lack of type checking before trolling disturbing.

stares at the code

Ummm, what?

AFAICT, the only difference between the two variants that I can see is
that the shift version might behave differently if numvnodes is
negative, which can't happen.  Can you be less funny and more clear
about what type checking issue you see?

Philip Guenther



Re: If you are one of the cool kids who cranks kern.bufcachepercent up..

2010-01-09 Thread Joerg Sonnenberger
On Sat, Jan 09, 2010 at 02:41:02PM -0800, Philip Guenther wrote:
  I find your lack of faith in the compiler disturbing.
 
  I find your lack of type checking before trolling disturbing.
 
 stares at the code
 
 Ummm, what?
 
 AFAICT, the only difference between the two variants that I can see is
 that the shift version might behave differently if numvnodes is
 negative, which can't happen.  Can you be less funny and more clear
 about what type checking issue you see?

You have analysed the situation correctly. The problem is that the
compiler does not know that the signed numvnodes is never negative, so
it creates different code. E.g. on AMD64 it is 6 instructions for the
signed division by 2 compared to one instruction for the explicit shift
or the unsigned division.

Joerg



Re: If you are one of the cool kids who cranks kern.bufcachepercent up..

2010-01-09 Thread Ted Unangst
On Sat, Jan 9, 2010 at 6:22 PM, Joerg Sonnenberger
jo...@britannica.bec.de wrote:
 You have analysed the situation correctly. The problem is that the
 compiler does not know that the signed numvnodes is never negative, so
 it creates different code. E.g. on AMD64 it is 6 instructions for the
 signed division by 2 compared to one instruction for the explicit shift
 or the unsigned division.

That's a good argument for making numvnodes unsigned, but not for
obfuscating the code.



Re: [patch] user/6104: newsyslog count off by one

2010-01-09 Thread Ingo Schwarze
Hi David,

 --- newsyslog.c.bak Thu Oct 22 21:18:12 2009
 +++ newsyslog.c Thu Oct 22 22:00:09 2009
 @@ -756,6 +756,9 @@
 char file1[MAXPATHLEN], file2[MAXPATHLEN], *suffix;
 int numdays = ent-numlogs;
 
 +   /* We start counting at 0 so reduce for correct maximum */
 +   numdays--;
 +
 /* Remove oldest log (may not exist) */
 (void)snprintf(file1, sizeof(file1), %s.%d, oldlog, numdays);
 (void)snprintf(file2, sizeof(file2), %s.%d%s, oldlog, numdays,

That does part of the job, but looks slightly ugly.

When applied to a running system, it lets the excessive archive file
sit around forever, or until you manually delete it.

I like the following better:
Remove all _consecutive_ archive files above the requested limit.
That's also useful after lowering the count in newsyslog.conf.

Note that the loop may be terminated earlier when rotating for real
than in -n mode; specifically, when unlink() fails.
But that's fine because -n is supposed to tell you what would be tried.
Of course, what you try to do may still fail.

Any OKs?


Index: newsyslog.c
===
RCS file: /cvs/src/usr.bin/newsyslog/newsyslog.c,v
retrieving revision 1.86
diff -u -p -r1.86 newsyslog.c
--- newsyslog.c 27 Oct 2009 23:59:40 -  1.86
+++ newsyslog.c 10 Jan 2010 00:36:43 -
@@ -750,22 +750,25 @@ void
 rotate(struct conf_entry *ent, const char *oldlog)
 {
char file1[MAXPATHLEN], file2[MAXPATHLEN], *suffix;
-   int numdays = ent-numlogs;
+   int numdays = ent-numlogs - 1;
+   int done = 0;
 
-   /* Remove oldest log (may not exist) */
-   (void)snprintf(file1, sizeof(file1), %s.%d, oldlog, numdays);
-   (void)snprintf(file2, sizeof(file2), %s.%d%s, oldlog, numdays,
-   COMPRESS_POSTFIX);
-
-   if (noaction) {
-   printf(\trm -f %s %s\n, file1, file2);
-   } else {
-   (void)unlink(file1);
-   (void)unlink(file2);
-   }
+   /* Remove old logs */
+   do {
+   (void)snprintf(file1, sizeof(file1), %s.%d, oldlog, numdays);
+   (void)snprintf(file2, sizeof(file2), %s.%d%s, oldlog,
+   numdays, COMPRESS_POSTFIX);
+   if (noaction) {
+   printf(\trm -f %s %s\n, file1, file2);
+   done = access(file1, 0)  access(file2, 0);
+   } else {
+   done = unlink(file1)  unlink(file2);
+   }
+   numdays++;
+   } while (done == 0);
 
/* Move down log files */
-   while (numdays--) {
+   for (numdays = ent-numlogs - 1; numdays = 0; numdays--) {
/*
 * If both the compressed archive and the non-compressed archive
 * exist, we decide which to rotate based on the CE_COMPACT flag



Re: If you are one of the cool kids who cranks kern.bufcachepercent up..

2010-01-09 Thread patrick keshishian
On Sat, Jan 09, 2010 at 06:35:45PM -0500, Ted Unangst wrote:
 On Sat, Jan 9, 2010 at 6:22 PM, Joerg Sonnenberger
 jo...@britannica.bec.de wrote:
  You have analysed the situation correctly. The problem is that the
  compiler does not know that the signed numvnodes is never negative, so
  it creates different code. E.g. on AMD64 it is 6 instructions for the
  signed division by 2 compared to one instruction for the explicit shift
  or the unsigned division.
 
 That's a good argument for making numvnodes unsigned, but not for
 obfuscating the code.

With respect to 'obfuscating', I would agree with you, except
using shift to divide (or multiply) by two, or multiples of two,
is very common.

--patrick



Re: If you are one of the cool kids who cranks kern.bufcachepercent up..

2010-01-09 Thread Bob Beck
Good god people. just test the fscking diff and stop the chestbeating
and cockpulling already.