From owner-freebsd-smp Fri Oct 27 9:14:11 2000 Delivered-To: freebsd-smp@freebsd.org Received: from berserker.bsdi.com (berserker.twistedbit.com [199.79.183.1]) by hub.freebsd.org (Postfix) with ESMTP id 22E6E37B479; Fri, 27 Oct 2000 09:14:08 -0700 (PDT) Received: from berserker.bsdi.com (cp@localhost.bsdi.com [127.0.0.1]) by berserker.bsdi.com (8.9.3/8.9.3) with ESMTP id KAA12094; Fri, 27 Oct 2000 10:14:07 -0600 (MDT) (envelope-from cp@berserker.bsdi.com) Message-Id: <200010271614.KAA12094@berserker.bsdi.com> To: Poul-Henning Kamp Cc: smp@FreeBSD.ORG Subject: Re: ktr.h improvement In-reply-to: Your message of "Fri, 27 Oct 2000 15:46:41 +0200." <10863.972654401@critter> From: Chuck Paterson Date: Fri, 27 Oct 2000 10:14:07 -0600 Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The macros that came from BSD/OS actually can be improved very little my changing. In the case of Sparc a small section is done in a function to set up the pointer and then the rest is inline. In X86 the upfront code is quite small so everything was done inline. The code in question is +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- movl $ KTR_ESIZE,reg; /* How much to incr */ \ xaddl reg,%fs:PCPU_KTR_IDX; /* get a slot */ \ rdtsc; /* time -> eax/edx */ \ andl seg ktr_size_mask,reg; /* wrap buffer */ \ addl %fs:PCPU_KTR_BUF,reg; /* Point to actual spot in buffer */ \ movl %eax,seg KTR_CLKV(reg);/* Time low */ \ movl %edx,seg KTR_CLKV+4(reg); /* Time high */ \ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- The rest of the macros as little or less space as passing the data to a function so there really isn't anything to be gained, and speed to be lost. In the case of FreeBSD there is also the KTR_EXTEND. This should be pushed into a function as much as possible. It is already so slow that it really can't be used in any kind of live kernel so any space to time overhead is a win. There is another big issue with the KTR macros which really needs to be addressed. Macros which are defined to not be compiled in are removed by the optimizer. This removes the code, but doesn't remove the strings. I have include a sample to show how this could be done so that the preprocessor rather than the optimizer leave this stuff out. Chuck #include #define KTR_TRACE 2 #define TRACE_KTR_FOO_BIT 2 /* some random bit */ #if KTR_TRACE & TRACE_KTR_FOO_BIT #define TRACE_KTR_FOO(x) printf ("%s\n", x) #else #define TRACE_KTR_FOO(x) #endif #define CTR0(x,y) __CONCAT(TRACE_, x)(y) int main(int ac, char **av) { CTR0(KTR_FOO, "now is the time"); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message