From owner-freebsd-hackers@FreeBSD.ORG Mon Mar 21 15:16:31 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9934816A4CE for ; Mon, 21 Mar 2005 15:16:31 +0000 (GMT) Received: from duchess.speedfactory.net (duchess.speedfactory.net [66.23.201.84]) by mx1.FreeBSD.org (Postfix) with SMTP id D62B143D5A for ; Mon, 21 Mar 2005 15:16:30 +0000 (GMT) (envelope-from ups@tree.com) Received: (qmail 12211 invoked by uid 89); 21 Mar 2005 15:16:28 -0000 Received: from duchess.speedfactory.net (66.23.201.84) by duchess.speedfactory.net with SMTP; 21 Mar 2005 15:16:28 -0000 Received: (qmail 12161 invoked by uid 89); 21 Mar 2005 15:16:27 -0000 Received: from unknown (HELO palm.tree.com) (66.23.216.49) by duchess.speedfactory.net with SMTP; 21 Mar 2005 15:16:27 -0000 Received: from [127.0.0.1] (localhost.tree.com [127.0.0.1]) by palm.tree.com (8.12.10/8.12.10) with ESMTP id j2LFGQw6026487; Mon, 21 Mar 2005 10:16:27 -0500 (EST) (envelope-from ups@tree.com) From: Stephan Uphoff To: matthew@digitalstratum.com In-Reply-To: <423ED74C.1050705@digitalstratum.com> References: <423DE326.9000203@digitalstratum.com> <423ED74C.1050705@digitalstratum.com> Content-Type: text/plain Message-Id: <1111418186.29804.130653.camel@palm> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 21 Mar 2005 10:16:26 -0500 Content-Transfer-Encoding: 7bit cc: FreeBSD Hackers cc: Zera William Holladay Subject: Re: Causing a process switch to test a theory. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Mar 2005 15:16:31 -0000 On Mon, 2005-03-21 at 09:16, Matthew Hagerty wrote: > Zera William Holladay wrote: > > >If you post the section(s) of code in question, then you'll probably > >elicit some responses. PIPE_BUF is a POSIX defined minimum, so you might > >grep for sections of code that contain fpathconf(*, _PC_PIPE_BUF) to > >determine if the programmers took this into consideration. At least > >you'll be able to follow the logical flow of the program from fpathconf() > >forward. > > > >Further, if you do some fancy programming (like preempting a process > >unnaturally) to determine if there is an error in this particular aspect > >of Apache, then you'll also have to show that you have not inflicted the > >error too, which will probably be harder than what you set out to solve or > >figure out. > > > >Good luck, Zera Holladay > >_______________________________________________ > >freebsd-hackers@freebsd.org mailing list > >http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > >To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > > > > > > I was not wanting to preempt any of the processes unnaturally, I was > looking more for suggestions as to how I can reliably cause preemption > for testing. Without knowing the details of how FreeBSD's scheduler > works, I could only assume that making a heavy load might cause such > preemption to happen, but that is just an under educated guess. > > I'm not familiar with fpathconf(), I'll go look that up for sure and > check Apache's code for it's use. Thanks! > > As for code, below is the portion that does to actual writing to the log > file, opened as either a normal file or a pipe depending on the config > file. Also note that BUFFERED_LOGS is not normally defined (must be > passed to make at compile time), and even then it only makes sure there > is *at least* LOG_BUFSIZE bytes to write before writing. It does not > prevent longer than LOG_BUFSIZE bytes from being written. > > Matthew > > < SNIP -- CODE DELETED > Why not just replace the write() call with a small test function? There is really no need to modify the kernel for your experiments. size_t test_pipe_write(int d, const void *buf, size_t nbytes) { size_t n; size_t done=0; while (nbytes > ATOMIC_WRITE_MAX) { n = write(d,buf,ATOMIC_WRITE_MAX); if (n <= 0) return done; buf = (char *) buf + n; nbytes -= n; usleep(NAP_TIME); } n = write(d,buf,nbytes); if (n <= 0) return done; else return n + done; } Stephan