From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10b612,3966722040aa4fe,start X-Google-Attributes: gid10b612,public X-Google-Thread: 1164f8,3966722040aa4fe,start X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1993-03-12 11:27:58 PST Xref: sparky comp.unix.ultrix:10283 comp.sys.dec:7828 Path: sparky!uunet!gatekeeper.us.oracle.com!decwrl!usenet.coe.montana.edu!news.u.washington.edu!corey From: corey@cac.washington.edu (Corey Satten) Newsgroups: comp.unix.ultrix,comp.sys.dec Subject: 4 Ultrix kernel bugs + fixes Date: 12 Mar 1993 19:05:30 GMT Organization: University of Washington, Seattle Distribution: world Message-ID: <1nqmtqINNifg@shelley.u.washington.edu> NNTP-Posting-Host: shiva2.cac.washington.edu Summary: load spikes, TCP delays, select bug : ----- cut here ----- cut here ----- cut here ----- cut here ----- : This is a "shell archive". Save everything after the cut mark : in a file called thisstuff, then feed it to sh by typing sh thisstuff. : SHAR archive format. Archive created Fri Mar 12 10:46:54 PST 1993 echo x - READ_ME echo '-rw-r--r-- 1 corey 8395 Mar 12 10:46 READ_ME (as sent)' sed 's/^-//' >READ_ME <<'+FUNKY+STUFF+' - - Ultrix Load Spikes, - Network Delays - & - Best of all: Fixes - - Corey Satten, corey@cac.washington.edu - Networks and Distributed Computing - University of Washington - Seattle, Washington - 3/8/93 - -Summary: - - Four unrelated Ultrix kernel bugs are presented along with fixes. - They are bundled together mostly for my convenience in posting. - This contains information I promised to post at the Q&A after - Jonathan Kay and Joseph Pasquale's paper at San Diego 1/93 Usenix. - - Bug 1: bogus select collisions cause load spikes. - Bug 2: select is broken on ptys causing programs to burn CPU cycles. - Bug 3: TCP delayed ACKs are not being sent properly causing retransmissions. - Bug 4: TCP retransmission delays may grow very large. - -Detail: - - Bug 1: - - On 9/30/91 I posted an article discussing select collisions and - provided programs which cause them to happen improperly on Ultrix. - Bogus select collisions came to my attention because they were so - common on our systems that they made the load average a useless metric - and caused occasional problems with programs which alter their behavior - based upon load average (such as sendmail). That former posting is - included for reference as "old_post.shar" (because I have learned from - experience that I will be flooded with requests for it anyway). - - Credit for the fix is due Nancy Johnson Burr in our CS department. - The fix is to file fifo_gnodeops.c. - - Bug 2: - - While investigating the occasional runaway xterm process, I discovered - that pasting into a program which doesn't read the data in a timely - fashion can cause the xterm to burn CPU cycles on Ultrix. To witness - this, try pasting several hundred bytes into sleep 1000 and watch your - xterm rack up cycles. Although this sounds like a perverse thing to - do, remember that one need only accidently hit the wrong mouse button. - Furthermore, even when the paste is intentional, if the program receiving - the data is slow enough that the xterm gets a couple hundred bytes - ahead, the bug can cause the xterm to loop trying to paste and thus - compete with the already slow receiver. - - To fix this, I adapted the 4.3BSD code for the offending case. - The fix is to the file tty_pty.c. - - Bug 3: - - Five times per second, a timer in the kernel causes Ultrix to look - through the list of established TCP connections for those which need - to have a delayed ack sent. The proper action is to handle all the - connections but according to a comment, someone at DEC changed this - to only ack the first one in the list, figuring the next ones would - probably get ack'd on the next pass. If there are sufficiently few - TCP connections or they are mostly not needing delayed acks, this may - be true, however on a busy system, it can happen that delayed ack - processing never gets to the connections at the end of the list (the - older connections). We had users complaining that TCP connections - would start out OK but get worse and worse. On one system, reportedly - the connections became unusable after as little as 20 minutes. I - discovered that a certain "expect script" I have which communicates - over an rsh would have the unusual property that only the most recently - started instance would run at normal speed, starting a new one would - slow down the older ones and killing the newer ones would speed them - back up in reverse order. - - This bug interacts in a particularly unfortunate way with bug #4. - - Again, the solution was to compare 4.3BSD to Ultrix to see what DEC - broke. Credit is due my associate, Martin Hunt for doing the work. - This fix is to file tcp_timer.c. - - Bug 4: - - Under some conditions, the TCP code increases (properly) the delay - before attempting to retransmit. This is part of the adaptive strategy - to avoid unnecessary retransmissions. Unfortunately, there is a bug - in this code (possibly originating at Berkeley since it seems that - some old versions of NCD software may also have it) which can cause - this timeout to grow when retransmissions are needed but never to - shrink again later. This, interacts most unfortunately with bug #3 - and can cause the consequences of not sending a delayed ack to be a - delay of many tens of seconds before retrying. Of course, acks are - also piggy-backed on outbound traffic, so this bug was often noticed - as output being one keystroke behind what it should have been. - - I am told DEC partially fixed this in Ultrix 4.2a but a better fix - (below) was provided to comp.protocols.tcp-ip and comp.windows.x last - year by Paul Barton-Davis (pauld@cs.washington.edu) and Dan Lanciani - (Harvard). This fix is to file tcp_input.c. I have not tested this - code because it was accidently left out of our last round of kernel - builds and it's not important enough to us to force another round of - new kernels and reboots. It will probably go in next time but we seem - to be running pretty well now even without it. This is what Paul said: - - OK, so here's a better patch [than in Ultrix 4.2a]. - This one gets as close as possible to the "right" answer - that one could get without a timer for each outstanding - packet, which is overkill. Its not a diff, but hopefully - Dave or someone else will get the idea. A key point to - notice is that rxtshift is reset at a point whther ti_ack - has already been found to be greater than snd_una. This is - a key difference to the simplistic approach that DEC took - in the Ultrix 4.2 code. Again, thanks to Dan Lanciani for - this. - - ----piece of tcp_input------ - - - } else { - /* - * No rtt measurement yet - use the - * unsmoothed rtt. Set the variance - * to half the rtt (so our first - * retransmit happens at 2*rtt) - */ - tp->t_srtt = tp->t_rtt << 3; - tp->t_rttvar = tp->t_rtt << 1; - } - tp->t_rtt = 0; - #ifndef ORIG - } - if (tp->t_timer[TCPT_PERSIST] == 0) - #endif - tp->t_rxtshift = 0; - TCPT_RANGESET(tp->t_rxtcur, - (((tp->t_srtt >> 2) + tp->t_rttvar) >> 1) + 1, - TCPTV_MIN, TCPTV_REXMTMAX); - #ifdef ORIG - } - #endif - - /* - * If all outstanding data is acked, stop retransmit - * timer and remember to restart (more output or persist). - * If there is more data to be acked, restart retransmit - * timer, using current (possibly backed-off) value. - */ - if (ti->ti_ack == tp->snd_max) { - tp->t_timer[TCPT_REXMT] = 0; - needoutput = 1; - } else if (tp->t_timer[TCPT_PERSIST] == 0) - tp->t_timer[TCPT_REXMT] = tp->t_rxtcur; - - -DISCLAIMER: - -On our systems, the fixes presented below were applied on top of various -other changes. I believe I accurately backed out these other changes -before producing the enclosed diffs against vanilla Ultrix 4.2a, however -please remember that the burden of validating the code I'm providing -remains on you, especially for fix #4 which even I haven't tried. - -DONT ASK FOR BINARIES - -In the past, I've asked our DEC rep. whether I can supply patched binaries -to those on the net who request them and the answer was always no, so -don't even bother to ask me. You are supposed to ask *your* DEC rep for -the patched binaries and if enough people ask, who knows, they may even -make it into a release. Happy patching. - --------- -Corey Satten, corey@cac.washington.edu -Networks and Distributed Computing -University of Washington +FUNKY+STUFF+ chmod u=rw,g=r,o=r READ_ME ls -l READ_ME echo x - diffs echo '-rw-r--r-- 1 corey 5453 Mar 11 14:43 diffs (as sent)' sed 's/^-//' >diffs <<'+FUNKY+STUFF+' -*** ../orig/fifo_gnodeops.c Mon Apr 29 13:16:00 1991 ---- ../patched/fifo_gnodeops.c Mon Mar 8 10:53:10 1993 -*************** -*** 36,41 **** ---- 36,44 ---- - /************************************************************************ - * Modification History - * -+ * 13 Jan 93 -- burr@cs via fmf -+ * Select collision on pipes fix from Nancy Johnson Burr. -+ * - * 27 Feb 91 -- chet - * Fix filesystem timestamping - * -*************** -*** 624,630 **** - if ((fp->fn_size != 0) || (fp->fn_wcnt == 0)) - ret_val = 1; - else { -! if (fp->fn_rselp) - fp->fn_flag |= IF_RCOLL; - else - fp->fn_rselp = u.u_procp; ---- 627,633 ---- - if ((fp->fn_size != 0) || (fp->fn_wcnt == 0)) - ret_val = 1; - else { -! if (fp->fn_rselp && fp->fn_rselp->p_wchan == (caddr_t)& selwait) - fp->fn_flag |= IF_RCOLL; - else - fp->fn_rselp = u.u_procp; -*************** -*** 635,641 **** - if ((fp->fn_size < PIPE_BUF) || (fp->fn_rcnt == 0)) - ret_val=1; - else { -! if (fp->fn_wselp) - fp->fn_flag |= IF_WCOLL; - else - fp->fn_wselp = u.u_procp; ---- 638,644 ---- - if ((fp->fn_size < PIPE_BUF) || (fp->fn_rcnt == 0)) - ret_val=1; - else { -! if (fp->fn_wselp && fp->fn_wselp->p_wchan == (caddr_t)& selwait) - fp->fn_flag |= IF_WCOLL; - else - fp->fn_wselp = u.u_procp; -*** ../orig/tty_pty.c Thu May 23 11:39:35 1991 ---- ../patched/tty_pty.c Mon Mar 8 11:18:09 1993 -*************** -*** 38,43 **** ---- 38,48 ---- - /* - * Modification History - * -+ * -+ * 11-Jan-93 - corey via fmf -+ * Don't always say ptys are ready for write even if if the write -+ * would block. -+ * - * 27-Mar-91 - Randall Brown - * Fix to ptcwrite(). Check for overflow of the slave's input queues - * even if the slave is in raw mode or cbreak mode. -*************** -*** 743,749 **** - /* - * Device ready to accept output. - */ -! if ((pti->pt_flags & PF_REMOTE) == 0 || tp->t_rawq.c_cc == 0) - error = 1; - /* - * Wait for output to drain. ---- 748,769 ---- - /* - * Device ready to accept output. - */ -! /* -! * fixes a problem whereby select always says ptys are ready for -! * output even if a write would block because they aren't (such as -! * when xterm pastes into sleep or a slow process). -! * -! * If you think read locking is needed here, remember that after select -! * returns that a FD is ready for write, another process could have changed -! * that before your write happened anyway. Corey 12/23/92 -! */ -! if (pti->pt_flags & PF_REMOTE) { /* corey ala 4.3bsd */ -! if (tp->t_canq.c_cc == 0) -! error = 1; -! } -! else if (tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG-2 || -! tp->t_canq.c_cc == 0 && -! (tp->t_flags & (RAW|CBREAK)) == 0) - error = 1; - /* - * Wait for output to drain. -*************** -*** 756,762 **** - /* - * Recheck conditions now that we have lock. - */ -! if ((pti->pt_flags & PF_REMOTE) == 0 || tp->t_rawq.c_cc == 0) { - error = 1; - smp_unlock(&pti->pt_lk_pty_sel); - TTY_UNLOCK(tp, s); ---- 776,789 ---- - /* - * Recheck conditions now that we have lock. - */ -! if (pti->pt_flags & PF_REMOTE) { /* corey ala 4.3bsd */ -! if (tp->t_canq.c_cc == 0) -! error = 1; -! } -! else if (tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG-2 || -! tp->t_canq.c_cc == 0 && -! (tp->t_flags & (RAW|CBREAK)) == 0) -! { - error = 1; - smp_unlock(&pti->pt_lk_pty_sel); - TTY_UNLOCK(tp, s); -*** ../orig/tcp_timer.c Thu May 23 11:38:15 1991 ---- ../patched/tcp_timer.c Mon Mar 8 11:27:11 1993 -*************** -*** 33,38 **** ---- 33,41 ---- - /************************************************************************ - * Modification History * - * -+ * 13-Jan-93 corey via fmf -+ * Back out 7/1/89 DEC change to only process one DELACK -+ * every 200ms. - * 28-Apr-91 jsd, woodward - * Add debug code to see if udb lock is being lost - * -*************** -*** 92,105 **** - /* - * Fast timeout routine for processing delayed acks - */ -- /* new 7/1/89: tcp_fasttimo no longer goes through the tcb chain -- * when it finds a DELACK. Now it acts on the first DELACK and -- * returns (early). This avoids the overhead of unlocking and -- * re-locking the lk_tcb, as well as worrying whether the inp->inp_next -- * is valid. We probably get a DELACK once a second, and if there -- * are two DELACKs in the chain, we will just pick up the second -- * in another 200ms. -- */ - tcp_fasttimo() - { - register struct inpcb *inp, *inpnxt; ---- 95,100 ---- -*************** -*** 122,131 **** - tp->t_flags &= ~TF_DELACK; - tp->t_flags |= TF_ACKNOW; - TCPSTAT(tcps_delack++); -! smp_unlock(&lk_tcb); - (void) tcp_output(tp); - smp_unlock(&so->lk_socket); -! goto quit; - } - } - } ---- 117,132 ---- - tp->t_flags &= ~TF_DELACK; - tp->t_flags |= TF_ACKNOW; - TCPSTAT(tcps_delack++); -! /* -! * back this bad change out! corey 1/12/93 -! * smp_unlock(&lk_tcb); -! */ - (void) tcp_output(tp); - smp_unlock(&so->lk_socket); -! /* -! * back this bad change out! corey 1/12/93 -! * goto quit; -! */ - } - } - } +FUNKY+STUFF+ chmod u=rw,g=r,o=r diffs ls -l diffs echo x - old_post.shar echo '-rw-r--r-- 1 corey 14989 Sep 26 1991 old_post.shar (as sent)' sed 's/^-//' >old_post.shar <<'+FUNKY+STUFF+' -: ----- cut here ----- cut here ----- cut here ----- cut here ----- -: This is a "shell archive". Save everything after the cut mark -: in a file called thisstuff, then feed it to sh by typing sh thisstuff. -: SHAR archive format. Archive created Thu Sep 26 13:12:34 PDT 1991 -echo x - READ_ME -echo '-rw-r--r-- 1 corey 5534 Sep 24 13:27 READ_ME (as sent)' -sed 's/^-//' >READ_ME <<'+FUNKY+STUFF+' -- -- Load Spikes on Ultrix -- traced to -- Bogus Select Collisions -- -- Corey Satten, corey@cac.washington.edu -- Networks and Distributed Computing -- University of Washington -- Seattle, Washington -- 9/24/91 -- --If you have been experiencing load spikes on your Ultrix system, the --following may be of considerable interest to you. -- --Background -- -- The implementation of the select(2) system call found in versions of -- BSD up though 4.3 Tahoe (not to imply anything about later versions) -- has a simple but expensive way of handling "select collisions". True -- "collisions" occur very rarely and refer to a situation in which two -- or more processes are blocked in select on a single device or network -- connection. Since the data structures used to wake up processes when -- they have input contain space for only a single process id, when two -- or more processes must be awakened, all processes blocked in select -- for any reason are slightly awakened and most quickly roll over and -- go back to sleep. If any of these processes are swapped out, some -- small part of them is swapped back in before they go back to sleep. -- -- All X clients, when idle, are blocked in select, so if you have -- a lot of X clients and you experience a select collision, a large -- number of processes can be affected. If these programs happen to run -- at the very moment the load average measurements are done, a very -- large load spike can result. -- -- A short program, spike.c, (enclosed) will generate a true select -- collisions for each newline typed. -- --Ultrix Bugs -- -- RISC Ultrix version 4.1 and 4.2 (not to imply anything about other -- versions) generates select collisions in circumstances which do -- not appear to be proper. I call these "bogus select collisions". -- On our system the collisions are quite common (often several per -- minute) and affect roughly 300 processes out of 550 on our system. -- -- Two short programs: spike2.c and spike3.c (enclosed) will generate -- bogus select collisions only on our Ultrix systems. -- -- It is unclear whether select collisions are mostly a measurement -- anomaly or a real performance problem. Clearly there is some -- unnecessary disk I/O associated with them and some CPU time is wasted -- but they are over almost as soon as they start so it's hard to tell -- how much of a problem they really are. They certainly make the load -- average a useless number on our system since it spikes from a baseline -- of around one up to as much as 40 and then exponentially decays back -- down (often only part way before the next spike). -- --Detecting the problem -- -- There are several ways to look for select collisions on Ultrix. The -- most direct is to examine the kernel variable which counts them. It -- is called "nselcoll" and can be viewed with my kmem program (previously -- posted and included below for completeness) or with dbx: -- -- kmem nselcoll -- echo print nselcoll | dbx -k /vmunix -- -- You can also see the effect of the select collisions by running: -- -- vmstat -v 5 -- -- and watching the number of "sleepers" (sl: the number of processes -- which have not run within the last 20 seconds). When a select collision -- happens, the number will jump to include all the processes blocked in -- select: -- -- % vmstat -v 5 -- procs memory -- r dw pw sl w vm avm rm arm fre -- 1 0 0 86 0 203k 69k 93k 37k 4564 -- 0 0 0 80 0 202k 62k 92k 35k 4612 -- 1 0 0 80 0 202k 62k 92k 32k 4740 -- 1 0 0294 0 202k 153k 92k 78k 4516 -- 0 0 0288 0 202k 153k 92k 77k 4404 -- 0 0 0287 0 202k 151k 92k 76k 4364 -- 1 0 0286 0 202k 151k 92k 76k 4344 -- 0 0 0 65 0 202k 53k 92k 28k 4344 -- 3 0 0 66 0 202k 58k 92k 31k 4344 -- -- The more "sleepers" were swapped out, the longer it takes the system -- to wake them and then put them back to sleep so the greater the chance -- of having the collision show up as a spike in the load average. -- --Programs which generate "bogus select collisions" -- -- X clients which use XtAddInput (to incorporate a pipe into the list -- of file descriptors watched in the X event loop) or in some other way -- cause the X event loop to select on a pipe seem to be the largest -- source of bogus select collisions. Xmh is probably a widely available -- example of this but the work I've done has been on home-grown clients -- so there is a chance xmh is doing something different. -- -- Without getting into any custom software, you can generate collisions -- on the console by starting and ending a dxterm from the session -- manager (dxsession). -- -- As an aid to tracking down this problem, I hacked our kernel to save -- the PID of the process which generates the collision. As a result, -- I have a list of processes which have "collided", (though I don't have -- what they collided with). I find the *vast* majority are caused by -- IslandLIC (3rd party software) and xmh (the X version of the mh mail -- agent) however the following other programs have also shown up: -- -- Xprompter dxcardfiler -- emacs rlogin -- rlogind rsh -- rshd sh -- telnet telnetd -- xterm -- --Closing remarks -- -- I haven't tried to fix the kernel and I'm not sure I will. I'm curious -- what feedback I'll get from posting what I've discovered so far. -- I assume it's too much to hope that someone has already found and fixed -- this but asking is cheap... -- --This posting contains the following files: -- -- READ_ME -- spike.c -- spike2.c -- spike3.c -- kmem.c -+FUNKY+STUFF+ -chmod u=rw,g=r,o=r READ_ME -ls -l READ_ME -echo x - spike.c -echo '-rw-r--r-- 1 corey 2161 Sep 26 12:51 spike.c (as sent)' -sed 's/^-//' >spike.c <<'+FUNKY+STUFF+' --/* -- * This program demonstrates a quirk in the implementation of -- * select on 4.3BSD, Ultrix 4.1, SUNOS 4.1.1 (and maybe others). -- * -- * Looking at the kernel source for the routine "selwakeup", I find -- * that if there is more than one process using select to wait for -- * I/O on the same device; when I/O is ready, *ALL* processes on the -- * system sleeping on "selwait" (waiting for any select) are awakened. -- * Since most have no input they don't seem to run much (judging from -- * how many can "run" like this per second and have no significant -- * impact on idle CPU). If, however, any were swapped out, they swap -- * in (or maybe only a tiny part swaps in since so little disk -- * traffic results from the swapping) and this stretches the real-time -- * over which the number of processes "runable" is high and increases -- * the chances that a system load average spike will result. I believe -- * the load spike is mostly a measurement anomaly however the active -- * real memory does goes up a little. Another indication of these -- * processes running is that the "SL" field of a "ps avx" shows all -- * of these processes have recently run. On ultrix, the "vmstat -v 5" -- * command will show the number of "sl" (short term sleepers) has also -- * jumped accordingly. -- * -- * To see which processes are waiting in select, do a "ps axl" and look -- * at the WCHAN field. If it is numeric, do a "nm /vmunix|grep selwait" -- * and look for the least significant part of that number in the WCHAN -- * field; otherwise, look for the word "selwait" directly in the ps list. -- * All the processes in selwait will be affected -- on our system, of -- * the roughly 550 processes, there are about 300 in selwait. -- * -- * To generate a spike, run this program and type return for each spike -- * -- * Corey Satten, corey@cac.washington.edu 5/24/91 -- */ --#include --#include --main(){ -- int i; -- char buf[100]; -- if (fcntl(0,F_SETFL,O_NDELAY) < 0) { -- fprintf(stderr, "fcntl failed\n"); -- exit(1); -- } -- fork(); /* both parent and child select on stdin */ -- for (;;) { -- i=1; -- printf ("select in pid %d returned %d\n", getpid(), select(1,&i,0,0,0)); -- read(0,buf,100); -- } -- } -+FUNKY+STUFF+ -chmod u=rw,g=r,o=r spike.c -ls -l spike.c -echo x - spike2.c -echo '-rw-r--r-- 1 corey 779 Sep 26 13:09 spike2.c (as sent)' -sed 's/^-//' >spike2.c <<'+FUNKY+STUFF+' --/* -- * generate a bogus select collision on Ultrix by selecting for input -- * with timeout on a pipe descriptor. -- */ --#include --#include --#include --#define IN 0 --#define OUT 1 -- --main() { -- int pipedes[2]; -- int ret; -- struct timeval tv; -- fd_set readfds, writefds, exceptfds; -- extern int errno; -- -- pipe(pipedes); -- fprintf(stderr, "process ID %d\n", getpid()); -- fprintf(stderr, "pipe descriptors %d %d\n", pipedes[IN], pipedes[OUT]); -- -- tv.tv_sec = 1; -- tv.tv_usec = 0; -- -- FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds); -- FD_SET(pipedes[IN], &readfds); -- -- fprintf(stderr, "mask = 0x%x\n", readfds); -- ret = select(pipedes[IN]+1, &readfds, 0, 0, &tv); -- fprintf(stderr, "ret=%d errno=%d\n", ret, errno); --} -+FUNKY+STUFF+ -chmod u=rw,g=r,o=r spike2.c -ls -l spike2.c -echo x - spike3.c -echo '-rw-r--r-- 1 corey 963 Sep 26 13:06 spike3.c (as sent)' -sed 's/^-//' >spike3.c <<'+FUNKY+STUFF+' --/* -- * generate a bogus select collision on Ultrix by selecting for input on -- * both descriptors of a pipe. This is probably not a sensible thing for a -- * program to do, but it probably shouldn't generate a collision either. -- */ --#include --#include --#define IN 0 --#define OUT 1 --main(){ -- int i,j; -- int child; -- char buf[100]; -- int pipedes[2]; -- -- pipe(pipedes); -- fprintf(stderr, "pipe descriptors: %d, %d\n", pipedes[IN], pipedes[OUT]); -- -- if (child=fork()) { /* parent */ --#ifdef NOSPIKE -- i = (1<<(pipedes[IN])); --#else -- i = (1<<(pipedes[IN])) | (1<<(pipedes[OUT])); --#endif -- printf ("select in pid %d returned %d\n", -- getpid(), -- select(pipedes[OUT]+1,&i,0,0,0)); -- i = read(pipedes[IN], buf, 100); -- write(1,buf,i); -- wait(&i); -- sleep(10); -- exit(0); -- } -- else { /* child */ -- close(1); dup(pipedes[OUT]); -- close(0); -- close(2); -- close(pipedes[IN]); -- close(pipedes[OUT]); -- sleep(5); -- execlp("date", "date", 0); -- exit(0); -- } -- } -+FUNKY+STUFF+ -chmod u=rw,g=r,o=r spike3.c -ls -l spike3.c -echo x - kmem.c -echo '-rw-r--r-- 1 corey 3925 Apr 25 10:24 kmem.c (as sent)' -sed 's/^-//' >kmem.c <<'+FUNKY+STUFF+' --/* -- * a tool to use in place of adb (on systems without adb) which lets you -- * peek and poke at the values of kernel variables in /dev/kmem -- * -- * usage: kmem [-s#] var1 var2 ... varN -- * or -- * usage: kmem -w var1=val1 var2=val2 ... varN=valN -- * -- * If -s# is given, loop every # seconds and repeat. This is handy for -- * watching variables like freemem or debugging flags. The following simple -- * awk script can postprocess the output filtering out values which don't -- * change: -- * { if (NF > 2) date = $0 -- * else if (seen[$1] != $2) { -- * seen[$1] = $2 -- * if (date != "") { -- * print ""; print date -- * date = "" -- * } -- * print -- * } -- * } -- * -- * Corey Satten, corey@cac.washington.edu, 9/6/90 - Ultrix 4.0 version -- */ --#include --#include --#include --#include -- --struct nlist *nl; /* how we find locations of names */ --int *nv; /* the new values for each name */ --int w_flag = 0; /* write new values? */ --char *file = "/vmunix"; /* default file to read symbols from */ --int kmem; -- --main(argc, argv) -- int argc; -- char *argv[]; --{ -- int f; /* walks argv upto index of first non-flag */ -- int i; /* walks through remaining arguments */ -- int value = 0; -- int rc = 0; -- int sleeptime = 0; /* if set nonzero with -s#, repeat every # secs */ -- -- /* -- * flag parsing -- */ -- for (f=1; f %d", value); -- if ( write(kmem, &value, sizeof(int)) != sizeof(int) ) { -- perror("/dev/kmem write"); exit(2); -- } -- } -- putchar('\n'); -- } -- -- if (sleeptime) { -- fflush(stdout); -- sleep(sleeptime); -- goto sleeploop; -- } --} --/* -- * print ascii version of current date and time -- */ --date() { -- char *at; -- static char db[30]; -- int i; -- -- time(&i); -- at = asctime(localtime(&i)); -- strcpy(db, at+4); -- db[20] = 0; -- puts(db); -- } -+FUNKY+STUFF+ -chmod u=rw,g=r,o=r kmem.c -ls -l kmem.c -exit 0 +FUNKY+STUFF+ chmod u=rw,g=r,o=r old_post.shar ls -l old_post.shar exit 0