[ARM_LINUX] ioremap() allowing to map system memory...

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Fri Mar 1 12:29:17 EST 2013


On Fri, 01 Mar 2013 16:48:12 +0530, sandeep kumar said:

> Don't you think it should throw panic()while calling the ioremap() itself.
> Because this sounds like a serious violation...

As you noted, it does give you a warning.

That's a kernel design philosophy - to reserve the panic() and BUG()
calls for cases where it is *known* that proceeding further is
unsafe or impossible.  So the kernel does a panic() if it can't start
/sbin/init at system boot-up - because without that, further progress
is impossible.  But once the system is up, we don't panic if PID 1 goes
away - because it's possible that the user has an open window, and can su
and at least do an orderly shutdown.

Similarly, if a device driver gets confused, the driver code may
do a BUG_ON() and end up locking up that device because to do anything
else may scramble the disk further.  But we don't panic() because that
will basically wedge the system - and the user loses any chance at dumping
the dmesg buffer for debugging or other attempts at an orderly shutdown (in
particular, panic() won't sync the filesystems.  So even though a BUG()
often kills a thread while it holds an important lock, which often leads
to the system eventually deadlocking one process at a time, it's still
a net win if it doesn't panic but lets the user at least try to run sync.

And even BUG_ON() is frowned upon if further progress in a degraded mode
is possible (for instance, a networking error that totally locks up one
TCP connection, but other connections are still working) - at that point,
warn() is the correct thing to do.

As in this case - it *is* a serious violation, but the kernel (a) can
at least possibly keep going and (b) it's at least possible that the
user can recover from it.  There's a *very* good chance that if the
kernel just does a warn(), the user will say "*facepalm* Stupid typo
in the address", fix the typo, and re-try with the correct address.

So that's the design philosophy of why it gives you a warning rather than
a panic.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130301/88ae50b7/attachment.bin 


More information about the Kernelnewbies mailing list