Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Aug 1995 00:04:09 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, dyson@freefall.cdrom.com
Cc:        CVS-commiters@freefall.cdrom.com, cvs-sys@freefall.cdrom.com, jkh@time.cdrom.com
Subject:   Re: cvs commit: src/sys/i386/isa syscons.cy
Message-ID:  <199508081404.AAA11579@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>Actually, I believe that the drivers should generally try to handle the
>low memory conditions correctly.  I don't want to have sporadic program
>failures just because memory is low.  I would like to see ENOMEM to mostly
>mean "out of VM".  Note that memory can be low fairly often...  For
>example my syscons problem in 4MB!!!  There would probably be more
>program failures (and then that would reflect on the system quality,
>whether or not the calling program should handle the problem "correctly".)
>Right now, the syscons changes mostly keep the system from crashing, and
>a proper fix should be implemented in the next couple of days.

Also, backing out cleanly may be harder than (correctly) waiting.  I used
M_WAITOK in the tty driver and in the slice non-driver because backing
out would be hard.  However, at least the slice non-driver should be
_much_ more careful: what happens memory runs out when a swap device is
being opened?

The fixed version of scopen() should look something like this:

#ifdef new
loop:
#endif
	if (!(tp->t_state & TS_ISOPEN))
	...
	if (!console[minor(dev)]) {
#ifndef new
		console[minor(dev)] = alloc_scp();
#else
		sc_stat *tmp;
		tmp = alloc_scp();
		if (console[minor(dev)])
			free_scp(tmp);
		else
			console[minor(dev)] = tmp;
		/*
		 * Restart open to check for changed conditions.   scopen()
		 * is simple, but there's still TS_XCLUDE to worry about.
		 * Note that we have to loop even if TS_ISOPEN is now clear,
		 * because another process may have opened and closed the
		 * device and messed up the settings while alloc_scp()
		 * was asleep.
		 */
		goto loop;
#endif
	}

This can be simplified a bit by allocating all resources before checking
TS_ISOPEN, but that may not be practical in all cases.

Are you going to rewrite 238 cases like this? :-)

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199508081404.AAA11579>