Re: kern+world / ports make options

2010-04-25 Thread Ulrich Spörlein
On Sat, 24.04.2010 at 16:42:37 +, Pegasus Mc Cleaft wrote:
> Hello Hackers & Current, 
> 
>   I was wondering it if is possible, or if it can be done so a separate 
> set 
> of CC, CXX, etc can be specified for building the world and kernel 
> independently of a ports build?
> 
>   Right now, I use the base GCC to compile the world and kernel, and 
> GCC44 
> for most of the other ports (when it complies cleanly). But I have to keep 
> editing the /etc/make.conf file to switch between the two. 
> 
>   It may already be implemented, but it would be nice if there was 
> something defined while the kernel and/or world is being built to that a 
> nested block of ifdefs can select which env variables to be set. 

src.conf has already been mentioned, I don't use it myself but have the
following set in make.conf

.if ${.CURDIR:M*/usr/ports/*}
NOCLEANDEPENDS= true
WRKDIRPREFIX=   /usr/obj
.include "/etc/ports.conf"
.endif

I guess you can figure it out from there ...

hth
Ulrich Spörlein
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: [PATCH] RUSAGE_THREAD

2010-04-25 Thread Kostik Belousov
On Mon, Apr 19, 2010 at 12:46:48AM +, Alexander Krizhanovsky wrote:
> Hi all!
> 
> This patch implements per-thread rusage statistic (like RUSAGE_THREAD in 
> Linux and RUSAGE_LWP in OpenSolaris).
> 
> Unfortunately, we have to acquire a number of locks to read/update 
> system and user times for current thread rusage information because it's 
> also used for whole process statistic and needs to be zeroed.
> 
> Any comments are very appreciated.
> 
> It's tested against 8.0-RELEASE. Appropriate PR is submitted.
> 
> -- 
> Alexander Krizhanovsky
> NatSys Lab. (http://natsys-lab.com)
> tel: +7 (916) 717-3899, +7 (499) 747-6304
> e-mail: a...@natsys-lab.com
> 
I think this should be somewhat modified before commit.

First, please separate patch into two pieces. One would introduce
ruxagg_tlock() helper and use it in existing locations instead of
three-liners. Possibly, add K&R->ANSI C kern_getrusage definition
change.

Second would actually add RUSAGE_THREAD. There, please follow
the style(9), in particular, do not initialize the local variables
at the declaration, instead, use explicit initialization in the code.

Should calctru() share the code with calcru1() ? I am esp. concerned
with sanity check like negative runtime etc. Possibly, this code
from calcru1() should be separated into function used from both
calcru1() and calctru().

Man page for getrusage(2) should be updated.

Thanks for the submission.

> --- sys/sys/resource.h.orig   2009-10-25 01:10:29.0 +
> +++ sys/sys/resource.h2010-04-11 23:31:14.0 +
> @@ -56,6 +56,7 @@
>  
>  #define  RUSAGE_SELF 0
>  #define  RUSAGE_CHILDREN -1
> +#define  RUSAGE_THREAD   1
>  
>  struct rusage {
>   struct timeval ru_utime;/* user time used */
> --- sys/kern/kern_resource.c.orig 2009-10-25 01:10:29.0 +
> +++ sys/kern/kern_resource.c  2010-04-18 23:49:04.0 +
> @@ -76,6 +76,7 @@ static void calcru1(struct proc *p, stru
>   struct timeval *up, struct timeval *sp);
>  static int   donice(struct thread *td, struct proc *chgp, int n);
>  static struct uidinfo *uilookup(uid_t uid);
> +static void ruxagg_tlock(struct proc *p, struct thread *td);
>  
>  /*
>   * Resource controls and accounting.
> @@ -623,9 +624,7 @@ lim_cb(void *arg)
>   return;
>   PROC_SLOCK(p);
>   FOREACH_THREAD_IN_PROC(p, td) {
> - thread_lock(td);
> - ruxagg(&p->p_rux, td);
> - thread_unlock(td);
> + ruxagg_tlock(p, td);
>   }
>   PROC_SUNLOCK(p);
>   if (p->p_rux.rux_runtime > p->p_cpulimit * cpu_tickrate()) {
> @@ -836,9 +835,7 @@ calcru(struct proc *p, struct timeval *u
>   FOREACH_THREAD_IN_PROC(p, td) {
>   if (td->td_incruntime == 0)
>   continue;
> - thread_lock(td);
> - ruxagg(&p->p_rux, td);
> - thread_unlock(td);
> + ruxagg_tlock(p, td);
>   }
>   calcru1(p, &p->p_rux, up, sp);
>  }
> @@ -918,6 +915,29 @@ calcru1(struct proc *p, struct rusage_ex
>   sp->tv_usec = su % 100;
>  }
>  
> +static void
> +calctru(struct thread *td)
> +{
> + u_int64_t tu = cputick2usec(td->td_incruntime);
> + u_int64_t ut = td->td_uticks;
> + u_int64_t it = td->td_iticks;
> + u_int64_t st = td->td_sticks;
> + u_int64_t tt, uu, su;
> +
> + tt = ut + st + it;
> + if (!tt) {
> + /* Avoid divide by zero */
> + st = 1;
> + tt = 1;
> + }
> + uu = td->td_ru.ru_utime.tv_usec + (ut * tu) / tt;
> + su = td->td_ru.ru_stime.tv_usec + (st * tu) / tt;
> + td->td_ru.ru_utime.tv_sec += uu / 100;
> + td->td_ru.ru_utime.tv_usec = uu % 100;
> + td->td_ru.ru_stime.tv_sec += su / 100;
> + td->td_ru.ru_stime.tv_usec = su % 100;
> +}
> +
>  #ifndef _SYS_SYSPROTO_H_
>  struct getrusage_args {
>   int who;
> @@ -939,10 +959,7 @@ getrusage(td, uap)
>  }
>  
>  int
> -kern_getrusage(td, who, rup)
> - struct thread *td;
> - int who;
> - struct rusage *rup;
> +kern_getrusage(struct thread *td, int who, struct rusage *rup)
>  {
>   struct proc *p;
>   int error;
> @@ -961,6 +978,13 @@ kern_getrusage(td, who, rup)
>   calccru(p, &rup->ru_utime, &rup->ru_stime);
>   break;
>  
> + case RUSAGE_THREAD:
> + PROC_SLOCK(p);
> + ruxagg_tlock(p, td);
> + PROC_SUNLOCK(p);
> + *rup = td->td_ru;
> + break;
> +
>   default:
>   error = EINVAL;
>   }
> @@ -1010,12 +1034,24 @@ ruxagg(struct rusage_ext *rux, struct th
>   rux->rux_uticks += td->td_uticks;
>   rux->rux_sticks += td->td_sticks;
>   rux->rux_iticks += td->td_iticks;
> +
> + /* update thread rusage before ticks counters cleaning */
> + calctru(td);
> +
>   td->td_incruntime = 0;
>   td->td_uticks = 0;
>   td->td_iticks = 0;
>   td->td_sti

Re: kern+world / ports make options

2010-04-25 Thread Pegasus Mc Cleaft
On Sunday 25 April 2010 11:17:40 Ulrich Spörlein wrote:
> On Sat, 24.04.2010 at 16:42:37 +, Pegasus Mc Cleaft wrote:
> > It may already be implemented, but it would be nice if there was
> > something defined while the kernel and/or world is being built to that a
> > nested block of ifdefs can select which env variables to be set.
> 
> src.conf has already been mentioned, I don't use it myself but have the
> following set in make.conf
> 
> .if ${.CURDIR:M*/usr/ports/*}
> NOCLEANDEPENDS=   true
> WRKDIRPREFIX= /usr/obj
> .include "/etc/ports.conf"
> .endif

Hi Ulrich, 

Thank you for that. This is pretty much what I was looking for as I can 
use the .if block to add in only the pieces I want. The src.conf solution was 
an option, but since both make.conf and src.conf are called, I ended up 
basically undoing everything in src.conf that I did in make.conf; and that 
didn't work so well as I kept breaking the build (couldn't find headers and 
all sorts of thing). No doubt, it was the way that I did it.. Your solution is 
cleaner and makes sense to me. 

Thanks again, 
Peg
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


unquoted variables in /usr/share/mk/*.mk

2010-04-25 Thread Alexander Best
hi there,

i was wondering why almost all variables in /usr/share/mk/*.mk are unquoted?
it's pretty obvious that something like

mkdir "(test)" ; echo ".include " > "(test)"/Makefile ; make -C
"(test)" cleandir

will fail.

-- 
Alexander Best
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: regenerating /var/db/pkg

2010-04-25 Thread Doug Barton
FWIW, this looks fine to me. Have you submitted a PR?


Doug


On 04/22/10 10:05, Eitan Adler wrote:
> Same as before - if all is good I'll send a PR
> 
> #!/bin/sh
> #
> # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1
> 2009/10/25 01:10:29 kensmith Exp $
> #
> 
> # If there is a global system configuration file, suck it in.
> #
> if [ -r /etc/defaults/periodic.conf ]
> then
> . /etc/defaults/periodic.conf
> source_periodic_confs
> fi
> 
> bak=/var/backups
> db_loc=$(/usr/bin/make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2>/dev/null)
> bk_loc="$bak/pkgdb.bak.tar.bz2"
> 
> case "$daily_backup_pkgdb_enable" in
> [Yy][Ee][Ss])
>   if [ ! -d $db_loc ]
>   then
>   echo '$daily_backup_pkgdb_enable is enabled but' \
>   "$db_loc doesn't exist"
>   rc=2
>   else
>   rc=0
> 
>   echo ""
>   echo "Backing up package db directory:"
> 
>   [ -e $bk_loc ] && unlink $bk_loc
>   tar -cjf $bk_loc $db_loc || rc=3
>   fi;;
> 
> *)  rc=0;;
> esac
> 
> exit $rc
> 



-- 

... and that's just a little bit of history repeating.
-- Propellerheads

Improve the effectiveness of your Internet presence with
a domain name makeover!http://SupersetSolutions.com/

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: regenerating /var/db/pkg

2010-04-25 Thread Garrett Cooper
On Thu, Apr 22, 2010 at 10:05 AM, Eitan Adler  wrote:
> Same as before - if all is good I'll send a PR
>
> #!/bin/sh
> #
> # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1
> 2009/10/25 01:10:29 kensmith Exp $
> #
>
> # If there is a global system configuration file, suck it in.
> #
> if [ -r /etc/defaults/periodic.conf ]
> then
>    . /etc/defaults/periodic.conf
>    source_periodic_confs
> fi
>
> bak=/var/backups
> db_loc=$(/usr/bin/make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2>/dev/null)
> bk_loc="$bak/pkgdb.bak.tar.bz2"
>
> case "$daily_backup_pkgdb_enable" in
>    [Yy][Ee][Ss])

This could be done via rc.subr's checkyesno function.

>        if [ ! -d $db_loc ]

Please quote the string.

>        then
>            echo '$daily_backup_pkgdb_enable is enabled but' \
>                "$db_loc doesn't exist"
>            rc=2
>        else
>            rc=0
>
>            echo ""
>            echo "Backing up package db directory:"
>
>            [ -e $bk_loc ] && unlink $bk_loc

Please quote.

>            tar -cjf $bk_loc $db_loc || rc=3

Same here.

>        fi;;
>
>    *)  rc=0;;
> esac
>
> exit $rc

Thanks,
-Garrett
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: regenerating /var/db/pkg

2010-04-25 Thread Doug Barton
On 04/25/10 19:44, Garrett Cooper wrote:
> On Thu, Apr 22, 2010 at 10:05 AM, Eitan Adler  
> wrote:
>> Same as before - if all is good I'll send a PR
>>
>> #!/bin/sh
>> #
>> # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1
>> 2009/10/25 01:10:29 kensmith Exp $
>> #
>>
>> # If there is a global system configuration file, suck it in.
>> #
>> if [ -r /etc/defaults/periodic.conf ]
>> then
>>. /etc/defaults/periodic.conf
>>source_periodic_confs
>> fi
>>
>> bak=/var/backups
>> db_loc=$(/usr/bin/make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2>/dev/null)
>> bk_loc="$bak/pkgdb.bak.tar.bz2"
>>
>> case "$daily_backup_pkgdb_enable" in
>>[Yy][Ee][Ss])
> 
> This could be done via rc.subr's checkyesno function.

It's periodic, not rc.d.  :)

>>if [ ! -d $db_loc ]
> 
> Please quote the string.

I generally do quote the string as a matter of paranoia, however the
practical result is likely to be the same.


Doug

-- 

... and that's just a little bit of history repeating.
-- Propellerheads

Improve the effectiveness of your Internet presence with
a domain name makeover!http://SupersetSolutions.com/

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: regenerating /var/db/pkg

2010-04-25 Thread Doug Barton
On 04/25/10 19:55, Doug Barton wrote:
>>>if [ ! -d $db_loc ]
>
> I generally do quote the string as a matter of paranoia, however the
> practical result is likely to be the same.

... unless it's possible that the path name will have spaces in it,
which is the main reason for my paranoia.



-- 

... and that's just a little bit of history repeating.
-- Propellerheads

Improve the effectiveness of your Internet presence with
a domain name makeover!http://SupersetSolutions.com/

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"