Commit Graph

1567 Commits

Author SHA1 Message Date
John Dyson
74b2192ae6 We have had support for running the kernel daemons as threads for
quite a while, but forgot to do so.  For now, this code supports
most daemons  running as kernel threads in UP kernels, and as
full processes in SMP.  We will soon be able to run them as
threads in SMP, but not yet.
1997-12-12 04:00:59 +00:00
John Dyson
648899413d Quiet some lint. 1997-12-10 04:14:23 +00:00
Steve Passe
eae8fc2c8a The improvements to clock statistics by Tor Egge
Wrappered and enabled by the define BETTER_CLOCK (on by default in smpyests.h)

Reviewed by:	smp@csn.net
Submitted by:	Tor Egge <Tor.Egge@idi.ntnu.no>
1997-12-08 23:00:24 +00:00
John-Mark Gurney
0c2a51b49e add process id to tmp files... this prevents two runs from stomping
over each other's tmp files...  (usr.bin/truss uncovered this bug)
1997-12-08 09:00:47 +00:00
John Dyson
78922e413c Correct prototypes to match POSIX. Correct return code for aio_cancel.
Submitted by:	Alex Nash <nash@mcs.com>
1997-12-08 02:18:25 +00:00
Sean Eric Fagan
847e5f5f9a Use at_exit() to invoke procfs_exit() instead of calling it directly.
Note that an unload facility should be used to call rm_at_exit() (if
procfs is being loaded as an LKM and is subsequently removed), but it
was non-obvious how to do this in the VFS framework.

Reviewed by:	Julian Elischer
1997-12-08 01:06:36 +00:00
Sean Eric Fagan
ed1b05436a Surround the call to procfs_exit() by #ifdef PROCFS/#endif -- much to my
surprise, procfs actually is optional, and some people truly do generate
kernels without it.  Wow.  I built a kernel without 'options PROCFS' and
it compiled and linked.
1997-12-07 18:16:43 +00:00
John Dyson
f2e6e69d92 Slight performance improvement, removal of unneeded SPLs. 1997-12-07 04:06:41 +00:00
Bruce Evans
df1c78063c Use ENOIOCTL instead of -1 (= ERESTART) for diskslice ioctls that are
not handled at a particular level.
1997-12-06 14:27:56 +00:00
Bruce Evans
239b7b699e Use ENOIOCTL instead of -1 (= ERESTART) for tty ioctls that are
not handled at a particular level.  This fixes mainly restarting
of interrupted TIOCDRAINs and TIOCSETA{W,F}s.
1997-12-06 13:25:01 +00:00
Sean Eric Fagan
2a024a2b05 Changes to allow event-based process monitoring and control. 1997-12-06 04:11:14 +00:00
Bruce Evans
1cd52ec333 Don't include <sys/lock.h> in headers when only `struct simplelock' is
required.  Fixed everything that depended on the pollution.
1997-12-05 19:55:52 +00:00
John Dyson
d4060a8751 Some fixes from John Hood:
1) Fix the initialization of malloc structure that changed
		due to perf opt.
	2) Remove unneeded include.
	3) An initialization assert added to malloc.
Submitted by:	John Hood <cgull@smoke.marlboro.vt.us>
1997-12-05 05:36:58 +00:00
John-Mark Gurney
4d9deedb49 document and make the NO_F00F_HACK a proper option...
also, sort some option includes while I'm here..

Forgotten by:	sef
1997-12-04 21:21:26 +00:00
Jordan K. Hubbard
e41b6f2db7 After consultation with David, change
#ifndef NO_F00F_HACK
to
#if defined(I586_CPU) && !defined(NO_F00F_HACK)
1997-12-04 14:35:40 +00:00
Sean Eric Fagan
c4fbf2774d Work around for the Intel Pentium F00F bug; this is Intel's recommended
workaround.  Note that this currently eats up two pages extra in the system;
this could be alleviated by aligning idt correctly, and then only dealing with
that (as opposed to the current method of allocated two pages and copying the
IDT table to that, and then setting that to be the IDT table).
1997-12-03 02:45:50 +00:00
Poul-Henning Kamp
ab3f746966 In all such uses of struct buf: 's/b_un.b_addr/b_data/g' 1997-12-02 21:07:20 +00:00
Bruce Evans
52aef196f7 Cleaned up __getcwd(). This should be cosmetic except disabled calls
are now counted.

Reviewed by:	phk
1997-12-02 10:32:21 +00:00
John Dyson
b4b3edc1f4 Fix a serious problem during resizing buffers where old buffers
address space wasn't being properly reclaimed.
Submitted by:	Bruce Evans <bde@freebsd.org>
1997-12-01 19:04:00 +00:00
John Dyson
e499ed6f86 Fix a problem when creating a new kernel thread. In some cases, aio_read
or aio_write can return the pid of the new thread.  This is due to the
way that return values from system calls being passed by side-effect in
the proc structure now.  This commit fixes the problem with aio_read and
aio_write.
1997-12-01 18:41:08 +00:00
Julian Elischer
1b0493988c Cleanup my last patch here
Reviewed by: sef@kthrup.com and phk@freebsd.org
1997-12-01 11:34:41 +00:00
John Dyson
11783b142b Fix error handling for VCHR type I/O. Also, fix another spl problem, and
remove alot of overly verbose debugging statements.
ioproclist {
	int aioprocflags;			/* AIO proc flags */
	TAILQ_ENTRY(aioproclist) list;		/* List of processes */
	struct proc *aioproc;			/* The AIO thread */
	TAILQ_HEAD (,aiocblist) jobtorun;	/* suggested job to run */
};

/*
 * data-structure for lio signal management
 */
struct aio_liojob {
	int lioj_flags;
	int	lioj_buffer_count;
	int	lioj_buffer_finished_count;
	int	lioj_queue_count;
	int	lioj_queue_finished_count;
	struct sigevent lioj_signal;	/* signal on all I/O done */
	TAILQ_ENTRY (aio_liojob) lioj_list;
	struct kaioinfo *lioj_ki;
};
#define	LIOJ_SIGNAL			0x1 /* signal on all done (lio) */
#define	LIOJ_SIGNAL_POSTED	0x2	/* signal has been posted */

/*
 * per process aio data structure
 */
struct kaioinfo {
	int	kaio_flags;			/* per process kaio flags */
	int	kaio_maxactive_count;	/* maximum number of AIOs */
	int	kaio_active_count;	/* number of currently used AIOs */
	int	kaio_qallowed_count;	/* maxiumu size of AIO queue */
	int	kaio_queue_count;	/* size of AIO queue */
	int	kaio_ballowed_count;	/* maximum number of buffers */
	int	kaio_queue_finished_count;	/* number of daemon jobs finished */
	int	kaio_buffer_count;	/* number of physio buffers */
	int	kaio_buffer_finished_count;	/* count of I/O done */
	struct proc *kaio_p;			/* process that uses this kaio block */
	TAILQ_HEAD (,aio_liojob) kaio_liojoblist;	/* list of lio jobs */
	TAILQ_HEAD (,aiocblist)	kaio_jobqueue;	/* job queue for process */
	TAILQ_HEAD (,aiocblist)	kaio_jobdone;	/* done queue for process */
	TAILQ_HEAD (,aiocblist)	kaio_bufqueue;	/* buffer job queue for process */
	TAILQ_HEAD (,aiocblist)	kaio_bufdone;	/* buffer done queue for process */
};

#define KAIO_RUNDOWN 0x1		/* process is being run down */
#define KAIO_WAKEUP 0x2			/* wakeup process when there is a significant
								   event */


TAILQ_HEAD (,aioproclist) aio_freeproc, aio_activeproc;
TAILQ_HEAD(,aiocblist) aio_jobs;			/* Async job list */
TAILQ_HEAD(,aiocblist) aio_bufjobs;			/* Phys I/O job list */
TAILQ_HEAD(,aiocblist) aio_freejobs;		/* Pool of free jobs */

static void aio_init_aioinfo(struct proc *p) ;
static void aio_onceonly(void *) ;
static int aio_free_entry(struct aiocblist *aiocbe);
static void aio_process(struct aiocblist *aiocbe);
static int aio_newproc(void) ;
static int aio_aqueue(struct proc *p, struct aiocb *job, int type) ;
static void aio_physwakeup(struct buf *bp);
static int aio_fphysio(struct proc *p, struct aiocblist *aiocbe, int type);
static int aio_qphysio(struct proc *p, struct aiocblist *iocb);
static void aio_daemon(void *uproc);

SYSINIT(aio, SI_SUB_VFS, SI_ORDER_ANY, aio_onceonly, NULL);

static vm_zone_t kaio_zone=0, aiop_zone=0,
	aiocb_zone=0, aiol_zone=0, aiolio_zone=0;

/*
 * Single AIOD vmspace shared amongst all of them
 */
static struct vmspace *aiovmspace = NULL;

/*
 * Startup initialization
 */
void
aio_onceonly(void *na)
{
	TAILQ_INIT(&aio_freeproc);
	TAILQ_INIT(&aio_activeproc);
	TAILQ_INIT(&aio_jobs);
	TAILQ_INIT(&aio_bufjobs);
	TAILQ_INIT(&aio_freejobs);
	kaio_zone = zinit("AIO", sizeof (struct kaioinfo), 0, 0, 1);
	aiop_zone = zinit("AIOP", sizeof (struct aioproclist), 0, 0, 1);
	aiocb_zone = zinit("AIOCB", sizeof (struct aiocblist), 0, 0, 1);
	aiol_zone = zinit("AIOL", AIO_LISTIO_MAX * sizeof (int), 0, 0, 1);
	aiolio_zone = zinit("AIOLIO",
		AIO_LISTIO_MAX * sizeof (struct aio_liojob), 0, 0, 1);
	aiod_timeout = AIOD_TIMEOUT_DEFAULT;
	aiod_lifetime = AIOD_LIFETIME_DEFAULT;
	jobrefid = 1;
}

/*
 * Init the per-process aioinfo structure.
 * The aioinfo limits are set per-process for user limit (resource) management.
 */
void
aio_init_aioinfo(struct proc *p)
{
	struct kaioinfo *ki;
	if (p->p_aioinfo == NULL) {
		ki = zalloc(kaio_zone);
		p->p_aioinfo = ki
1997-12-01 07:01:45 +00:00
John Dyson
f4f0ecefab Correct a last minute code change. Would have been an infinite loop under
certain error conditions.
Submitted by:	pst@shockwave.com
1997-11-30 23:21:08 +00:00
John Dyson
c5efdcbdec Fix an spl nit. 1997-11-30 21:47:36 +00:00
John Dyson
84af4da65a Finish up the vast majority of the AIO/LIO functionality. Proper signal
support was missing in the previous version of the AIO code.  More
tunables added, and very efficient support for VCHR files has been added.
Kernel threads are not used for VCHR files, all work for such files is
done for the requesting process directly.  Some attempt has been made to
charge the requesting process for resource utilization, but more work
is needed.  aio_fsync is still missing (but the original fsync system
call can be used for now.)  aio_cancel is essentially a noop, but that
is okay per POSIX.  More aio_cancel functionality can be added later,
if it is found to be needed.

The functions implemented include:
	aio_read, aio_write, lio_listio, aio_error, aio_return,
	aio_cancel, aio_suspend.

The code has been implemented to support the POSIX spec 1003.1b
(formerly known as POSIX 1003.4 spec) features of the above.  The
async I/O features are truly async, with the VCHR mode of operation
being essentially the same as physio (for appropriate files) for
maximum efficiency.  This code also supports the signal capability,
is highly tunable, allowing management of resource usage, and
has been written to allow a per process usage quota.

Both the O'Reilly POSIX.4 book and the actual POSIX 1003.1b document
were the reference specs used.  Any filedescriptor can be used with
these new system calls.  I know of no exceptions where these
system calls will not work.  (TTY's will also probably work.)
1997-11-30 04:36:31 +00:00
John Dyson
f4feb04e1f Disable the VCHR optimization for AIO until I have implemented it. Just in
case anyone wants to play with the POSIX AIO/LIO stuff.  (As it is, it should
work with ANY vnode, on UP systems only, for now.)
1997-11-29 02:57:46 +00:00
John Dyson
fd3bf77574 Fix and complete the AIO syscalls. There are some performance enhancements
coming up soon, but the code is functional.  Docs will be forthcoming.
1997-11-29 01:33:10 +00:00
Julian Elischer
95802bf803 Shift a few SYSINT() calls around.
this results in a few functions becoming static, and
the SYSINITs being close to the code they are related to.
setting up the dump device is with dumpsys() and
kicking off the scheduler is with the scheduler.
Mounting root is with the code that does it.

Reviewed by: phk
1997-11-25 07:07:48 +00:00
Bruce Evans
c463cf1cae Fixed multiple definitions of boothowto.
Fixed bitrot in the read-only access to kern.boottime.
1997-11-24 18:35:04 +00:00
Bruce Evans
b672aa4ba6 Removed all traces of P_IDLEPROC. It was tested but never set. 1997-11-24 15:15:33 +00:00
Bruce Evans
21e5241572 Fixed some #include messes.
Hid the check of the user %cs in syscall() under `#ifdef DIAGNOSTIC'.
1997-11-24 13:25:37 +00:00
John Dyson
4ced7dd5bf Avoid manipulating the buffer map at interrupt time by deferring bfreekva
to getnewbuf, and remove from brelse.
Reviewed by:	dg@root.com
1997-11-24 06:18:27 +00:00
John Dyson
289500ad9e Fix the buffer flag frobbing. Note: It is invalid to gratuitiously modify
b_flags, and this patch removes unneeded modifications.  Only the needed b_flags
bits are modified now.  (Specifically, it is usually wrong to zero b_flags.)
Submitted by:	bde@freebsd.org
1997-11-24 04:14:21 +00:00
Bruce Evans
a3c78a768e Fixed a missing conversion of retval to p_retval in disabled code.
Fixed overflow of FFLAGS() in fcntl(F_SETFL, ...).  This was not
a security hole, but gave wrong results for silly flags values.
E.g., it make fcntl(F_SETFL, -1) equivalent to fcntl(F_SETFL, 0).
POSIX requires ignoring the open mode bits in fcntl() (even if
they would be invalid for open()).
1997-11-23 12:24:59 +00:00
Bruce Evans
d826c47904 Fixed duplicate definitions of M_FILE (one static). 1997-11-23 10:43:49 +00:00
Bruce Evans
2087c8967c Fixed some style bugs in the poll() code.
Removed dead code to "Avoid inadvertently sleeping forever".  hzto()
never returns 0.
1997-11-23 10:30:50 +00:00
Bruce Evans
cb451ebdbd Staticized. 1997-11-22 08:35:46 +00:00
Bruce Evans
865737f450 Staticized.
Use OID_AUTO instead of a magic number for the debug.syncprt sysctl.
(This sysctl doesn't actually work.  FreeBSD nuked it, but parts
of it were mismerged from Lite2.  It is not very good, but better
than nothing.)
1997-11-22 06:41:21 +00:00
Bruce Evans
d02601f8cf Fixed rev.1.81. mp->mnt_kern_flag was restored in the non-error case of
`mount -u'.  This only matters for `mount -u' competing with unmounts.
If I understand the locking correctly: if mount() blocks, then unmount()
may run and set mp->kern_flag for the same mp.  Then unmount() blocks
waiting for mount() to finish.  When unmount() continues, its MNTK flags
(MNTK_UNMOUNT and MNTK_MWAIT) may have been clobbered.

Didn't fix old bugs:
- restoring mp->mnt_kern_flag is wrong for the same reasons in the error
  case.
- the error case of unmount() seems to be broken too:
  (a) MNTK_UNMOUNT gets clobbered, although another unmount() may have
      set it.  Perhaps it shouldn't be set until after the full lock is
      aquired.
  (b) MNTK_MWAIT isn't honoured.

Fixed a nearby style bug.
1997-11-22 06:10:36 +00:00
Bruce Evans
6881d20fbb Const poisoning from ks_shortdesc. 1997-11-21 11:37:03 +00:00
Bruce Evans
d73424aa6b Fixed a sloppy common-style definitions. 1997-11-20 20:07:59 +00:00
Bruce Evans
01166e9245 Avoid passing a `retval' to wait1()
Disallow wait options that are not a combination of the standard POSIX
options WUNTRACED and WNOHANG, as is required by POSIX.  BSD doesn't
have any extensions here, but the code was `#ifdef notyet' for some
reason.
1997-11-20 19:09:43 +00:00
Bruce Evans
be67169a57 Removed unused includes.
Staticized.

Avoid passing a `retval' to fork1().

Fixed some style bugs.
1997-11-20 16:36:17 +00:00
Bruce Evans
d96bc99dac Removed unused #includes. Ifdefed a conditionally used #include.
Fixed nonblocking mode.  It was per-device instead of per-file.

Don't depend on gcc's misfeature of rewriting char args in old-style
function definitions to match wrong prototypes.  Break K&R1 support
to fix this quickly.
1997-11-18 16:12:51 +00:00
Bruce Evans
fc8f7066d2 Get buffer stuff by #including <sys/buf.h> instead of <sys/vnode.h>.
Staticized boot().

Fixed a gratuitous ANSIism.
1997-11-18 15:16:43 +00:00
Bruce Evans
d662024a0d Removed an unused #include.
Fixed a style bug (one of many KNF breakages in vfs_subr.c moved here).
1997-11-18 13:03:48 +00:00
Bruce Evans
1fe5398ce7 Get tty ioctl numbers by #including <sys/ttycom.h> instead of
<sys/tty.h>.  Don't #include <sys/fcntl.h> (the select -> poll
changes removed all dependencies on it).
1997-11-18 12:59:09 +00:00
Bruce Evans
b7f5d5b54d Removed an unused #include. Added an unsed #include of <sys/ucred.h>
to prepare for not including it in <sys/param.h>.  Moved conditionally
used #includes inside an ifdef.
1997-11-18 12:52:10 +00:00
Bruce Evans
e4474ce8bf Removed an unused #include. Ifdefed a conditionally used #include. 1997-11-18 12:43:41 +00:00
Bruce Evans
99af8d4e43 Removed unused #include. 1997-11-18 12:24:22 +00:00