Skip to contentSkip to conversation

High-res-timers part 4 (support-lib) take 2

PATCH In review george anzinger 1 participant 1 message Sep 28, 2002 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 4/6 High-res-timers part 4 (support-lib) take 2

The 4th, 5th, and 6th parts are support code and not really part of the kernel.

This part contains the user land library build code, change log, and readme stuff.

There are two library stub generation bits, one for a shared library and one for an archive library. The archive library is arch neutral, the share is i386 only.

The whole of this patch will create and populate the Documentation/high-res-timers/ directory. It , with the remaining parts, is very useful for testing correct functioning of the new system calls. It
also contains a test program (performance.c) that will generate graph data for gnuplot showing interesting performance numbers WRT to large numbers timers.

Signature · 5 lines
George Anzinger   [email protected]
High-res-timers: 
http://sourceforge.net/projects/high-res-timers/
Preemption patch:
http://www.kernel.org/pub/linux/kernel/people/rml
Documentation/high-res-timers/CHANGELOG +107 -0
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.36-kb/Documentation/high-res-timers/CHANGELOG linux/Documentation/high-res-timers/CHANGELOG
@@ -0,0 +1,107 @@
+For version 2.4.18-3.0
+
+This version is the first to have the clock_nanosleep absolute feature
+which POSIX says, if the clock is set under the sleep, it will still
+expire when it should (unless that time is now past, in which case it
+should expire immediately).
+
+We now have a clock_nanosleep test with help from Robert Love and
+George.	 It actually verifies the above feature as well as that signals
+that don't get delivered to the user do not cause clock_nanosleep to
+stop, while those that do, do.	We tested using SIGSTOP and SIGCONT.
+
+It turns out that, if we are not doing high res (either because it is
+turned off or because there are no high res timers expiring) that the
+PIT (which is to give us periodic interrupts) drifts with respect to the
+clock, be it TSC or ACPI pm timer.  This causes the jiffie interrupts to
+drift around causing varying and significant latency in the delivery
+of low res timers.  We now have code to detect this drift and "touch"
+the PIT as needed to get it to give us interrupts much closer to when we
+want them.  I suppose we could use this as an indication that we have
+not done as good a job of calibrating the TSC as we would like.	 But
+even the ACPI drifts and it should be on the same "rock".
+
+The man pages have been updated to (hopefully) get the arguments right.
+
+A bug was found and fixed in the test to see if a timer was referenced
+to CLOCK_MONOTONIC.  It caused nasty errors when converting such timers
+to the system base.
+
+After spending a LOT of time getting clock_nanosleep and its test to
+work, I decided to error out requests for times beyond what can be fit
+in the (size of long) jiffie.  In the past these were just set to the
+max value.  This just caused such obvious errors to look like normal
+timers, not fun to debug.
+
+AND, least I forget, we have moved to a shared system call stub library.
+This should allow you to not reload your using code, even if the system
+call numbers change.  It did take a few more files (purloined from
+glibc) to do it, however.
+
+The library make file will also figure out if the itimer struct is needed
+in posix_lib.h and do the right thing.
+
+For version 2.4.18-1.0
+
+Made the sub_expire member of the timer_list structure unconditional.
+This should allow modules compiled against high res on or off to play
+regardless of how the kernel is compiled.
+
+Also moved jiffies out of the #define name space.  It is now defined by
+the linker and is only in the extern name space.  You are free to use it
+as a dummy variable, local variable or member of a struct or union.
+
+For version 2.4.17-3.0
+
+Found a fixed a major bug that lost (or delayed) timers for a LONG time.
+All timers, not just POSIX timers.
+
+Also removed changes to limits.h and changed config.in to default to
+3000 timers and to use the TSC clock.  Also disabled some debug code
+that was getting turned on if CONFIG_KGDB was defined.
+
+For version 2.4.17-2.2
+
+Fixed the set up of the arch_to_latch conversion constant so we actually
+do get sub jiffies interrupts, thanks to Jim Houston for spotting this
+one.
+
+Put normalize code in the clock_gettime() call so we no longer return
+un-normalized time (i.e. nanoseconds > 1 sec.).
+
+Changed the run_timer_list code to get the latest version of "NOW" just
+prior to the scan.
+
+Changed schedule_next_interrupt() to accept a flag indicating how to
+return if the requested time has already elapsed (it was indicating
+"time elapsed" and not scheduling an interrupt which does not work well
+if we REALLY need the interrupt).
+
+For version 2.4.17-2.1
+
+Since 2.4.17-3.1 (the last to go to sourceforge)
+
+Fixed compile problems with high-res-timers turned off (who would do
+such a thing?)
+
+Changed all the ex_ math code to sc_ (it is scaled math after all).
+
+Added man pages
+
+Changed to no longer try to measure the minimun interval we can
+support.  It is now fixed at 500 micro seconds.	 Looking for a new way
+to do this.  The old one ran into NMI issues on SMP machines.
+
+Fixed config.in "] problem (must be " ]).
+
+Picked up several more name space collisions on jiffies.
+
+Added the rest of the system call links for all archs, save, I think sh.
+
+Fixed a bug where a call to clock_gettime messed up gettimeofday.
+
+Simplified the lib stuff and moved the whole thing into the kernel tree.
+It no longer depends on links in /usr/include.
+
+I am sure I am forgetting something, but sigh, lets ship this thing.
+
Documentation/high-res-timers/README +138 -0

138 lines not on this page · raw message

Documentation/high-res-timers/lib/Makefile +24 -0
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.36-kb/Documentation/high-res-timers/lib/Makefile linux/Documentation/high-res-timers/lib/Makefile
@@ -0,0 +1,24 @@
+LIBPOSIXTIME = libposixtime.so
+
+SOURCES = syscall_timer.c 
+OBJECTS = $(SOURCES:.c=.o)
+
+SYSASM =  -I../../../include/ -I../usr_incl/
+CPPFLAGS = -D_POSIX_TIMERS=1 -D_POSIX_C_SOURCE=199309L -D_XOPEN_SOURCE -D_LIBC $(SYSASM)
+CFLAGS = -g -Wall -shared -fpic -fPIC
+
+all: $(LIBPOSIXTIME)($(OBJECTS))
+
+clean:
+	rm -f *.o *.a *.so *~ core .depend t--* tmp
+
+.depend: $(SOURCES) test_itimerspec
+	$(CC) $(CPPFLAGS)  -M $(SOURCES) | \
+		sed -e '/:/s|^[^ :]*|$(LIBPOSIXTIME)(&)|' > .depend
+	chmod +x test_itimerspec
+	./test_itimerspec $(CC) $(CPPFLAGS) &>/dev/null
+	make
+
+# The above make insures that "all:" is done with the newly created .depend
+
+include .depend

Binary files linux-2.5.36-kb/Documentation/high-res-timers/lib/libposixtime.so and linux/Documentation/high-res-timers/lib/libposixtime.so differ

Documentation/high-res-timers/lib/posix_time.h +151 -0

151 lines not on this page · raw message

Documentation/high-res-timers/lib/syscall_timer.c +94 -0

94 lines not on this page · raw message

Documentation/high-res-timers/lib/test_itimerspec +32 -0
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.36-kb/Documentation/high-res-timers/lib/test_itimerspec linux/Documentation/high-res-timers/lib/test_itimerspec
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# This bit of nonsense fixes up posix_time.h to either define
+# sturct itimerspec or not, depending on if the library headers
+# have already defined it.  It does a test by compiling a trivial
+# program and testing if there are errors.  If there are errors
+# it inverts the inclusion of the definition.  That is it does not
+# matter if posix_time.h starts with the struc defined or not, if
+# the assumption is wrong we just change it.
+
+# The interesting thing is that even if the lib does not define it
+# the definition is still there, it is just not exposed because of
+# some dumb rules having to do with what flags are defined. 
+
+FILE="posix_time.h"
+OUTFILE="tmp"
+
+tf="t--st"
+	rm -f $tf.c
+	echo "#include <linux/unistd.h>" >$tf.c
+	echo "#include \"$FILE\"">>$tf.c
+	echo "int main(struct itimerspec *t){t->it_interval.tv_sec++;return 0;}">>$tf.c
+	foo=`$* $tf.c -o $tf`&>/dev/null
+	result="$?"
+#	echo $result
+#	echo "from file"$foo
+	if [ "$result" != "0" ] ; then 
+	    awk '$0 == "#ifdef NEED_ITIMERSPEC" {$0 = "#ifndef NEED_ITIMERSPEC";print;next} $0 == "#ifndef NEED_ITIMERSPEC" {$0="#ifdef NEED_ITIMERSPEC"}{print}' $FILE >$OUTFILE
+	    rm $FILE
+	    mv $OUTFILE $FILE
+	 fi
+	 rm -f $tf*
Documentation/high-res-timers/libX/Makefile +25 -0
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.36-kb/Documentation/high-res-timers/libX/Makefile linux/Documentation/high-res-timers/libX/Makefile
@@ -0,0 +1,25 @@
+LIBPOSIXTIME = libposixtime.so
+
+SOURCES = syscall_timer.c 
+OBJECTS = $(SOURCES:.c=.o)
+
+SYSASM =  -I../../../include/ -I../usr_incl/
+CPPFLAGS = -D_POSIX_TIMERS=1 -D_POSIX_C_SOURCE=199309L -D_XOPEN_SOURCE $(SYSASM)
+CFLAGS = -g -Wall -shared 
+
+all: $(LIBPOSIXTIME)($(OBJECTS))
+
+clean:
+	rm -f *.o *.a *.so *~ core .depend t--* tmp
+
+tf = t--st.c
+.depend: $(SOURCES)
+	$(CC) $(CPPFLAGS)  -M $(SOURCES) | \
+		sed -e '/:/s|^[^ :]*|$(LIBPOSIXTIME)(&)|' > .depend
+	rm -f $(tf)
+	./test_itimerspec $(CC) $(CPPFLAGS) &>/dev/null
+	make
+
+# The above make insures that "all:" is done with the newly created .depend
+
+include .depend
Documentation/high-res-timers/libX/posix_time.h +151 -0

151 lines not on this page · raw message

Documentation/high-res-timers/libX/syscall_timer.c +64 -0

64 lines not on this page · raw message

Documentation/high-res-timers/libX/test_itimerspec +32 -0
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.36-kb/Documentation/high-res-timers/libX/test_itimerspec linux/Documentation/high-res-timers/libX/test_itimerspec
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# This bit of nonsense fixes up posix_time.h to either define
+# sturct itimerspec or not, depending on if the library headers
+# have already defined it.  It does a test by compiling a trivial
+# program and testing if there are errors.  If there are errors
+# it inverts the inclusion of the definition.  That is it does not
+# matter if posix_time.h starts with the struc defined or not, if
+# the assumption is wrong we just change it.
+
+# The interesting thing is that even if the lib does not define it
+# the definition is still there, it is just not exposed because of
+# some dumb rules having to do with what flags are defined. 
+
+FILE="posix_time.h"
+OUTFILE="tmp"
+
+tf="t--st"
+	rm -f $tf.c
+	echo "#include <linux/unistd.h>" >$tf.c
+	echo "#include \"$FILE\"">>$tf.c
+	echo "int main(struct itimerspec *t){t->it_interval.tv_sec++;return 0;}">>$tf.c
+	foo=`$* $tf.c`&>/dev/null
+	result="$?"
+#	echo $result
+#	echo "from file"$foo
+	if [ "$result" != "0" ] ; then 
+	    awk '$0 == "#ifdef NEED_ITIMERSPEC" {$0 = "#ifndef NEED_ITIMERSPEC";print;next} $0 == "#ifndef NEED_ITIMERSPEC" {$0="#ifdef NEED_ITIMERSPEC"}{print}' $FILE >$OUTFILE
+	    rm $FILE
+	    mv $OUTFILE $FILE
+	 fi
+	 rm -f $tf*
Documentation/high-res-timers/usr_incl/bits/siginfo.h +292 -0

292 lines not on this page · raw message

Documentation/high-res-timers/usr_incl/bits/siginfo.h-old +314 -0

314 lines not on this page · raw message

Documentation/high-res-timers/usr_incl/bits/types.h-should-not-need +155 -0

155 lines not on this page · raw message

Documentation/high-res-timers/usr_incl/bp-asm.h +144 -0

144 lines not on this page · raw message

Documentation/high-res-timers/usr_incl/bp-sym.h +26 -0
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.36-kb/Documentation/high-res-timers/usr_incl/bp-sym.h linux/Documentation/high-res-timers/usr_incl/bp-sym.h
@@ -0,0 +1,26 @@
+/* Bounded-pointer symbol modifier.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Greg McGary <[email protected]>
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define BP_SYM(name) _BP_SYM (name)
+#if __BOUNDED_POINTERS__
+# define _BP_SYM(name) __BP_##name
+#else
+# define _BP_SYM(name) name
+#endif
Documentation/high-res-timers/usr_incl/siginfo.patch +65 -0

65 lines not on this page · raw message

Documentation/high-res-timers/usr_incl/sysdeps/generic/sysdep.h +43 -0

43 lines not on this page · raw message

Documentation/high-res-timers/usr_incl/sysdeps/i386/sysdep.h +294 -0

294 lines not on this page · raw message

Documentation/high-res-timers/usr_incl/sysdeps/unix/i386/sysdep.h +36 -0
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.36-kb/Documentation/high-res-timers/usr_incl/sysdeps/unix/i386/sysdep.h linux/Documentation/high-res-timers/usr_incl/sysdeps/unix/i386/sysdep.h
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 92, 93, 95, 96, 97 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sysdeps/unix/sysdep.h>
+#include <sysdeps/i386/sysdep.h>
+
+#ifdef	__ASSEMBLER__
+
+/* This is defined as a separate macro so that other sysdep.h files
+   can include this one and then redefine DO_CALL.  */
+
+#define DO_CALL(syscall_name, args)					      \
+  lea SYS_ify (syscall_name), %eax;					      \
+  lcall $7, $0
+
+#define	r0		%eax	/* Normal return-value register.  */
+#define	r1		%edx	/* Secondary return-value register.  */
+#define scratch 	%ecx	/* Call-clobbered register for random use.  */
+#define MOVE(x,y)	movl x, y
+
+#endif	/* __ASSEMBLER__ */
Documentation/high-res-timers/usr_incl/sysdeps/unix/sysdep.h +53 -0

53 lines not on this page · raw message