public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pete Zaitcev <zaitcev@redhat.com>
To: Keith Owens <kaos@ocs.com.au>
Cc: Pete Zaitcev <zaitcev@redhat.com>, linux-kernel@vger.kernel.org
Subject: Re: [RFC] [PATCH] C exceptions in kernel
Date: Sat, 23 Feb 2002 07:50:02 -0500	[thread overview]
Message-ID: <20020223075002.A23666@devserv.devel.redhat.com> (raw)
In-Reply-To: <200202231011.g1NABaU10984@devserv.devel.redhat.com> <25097.1014467212@ocs3.intra.ocs.com.au>
In-Reply-To: <25097.1014467212@ocs3.intra.ocs.com.au>; from kaos@ocs.com.au on Sat, Feb 23, 2002 at 11:26:52PM +1100

> From: Keith Owens <kaos@ocs.com.au>
> Date: Sat, 23 Feb 2002 23:26:52 +1100

> Kernel code already has exception tables to handle invalid addresses,
> invalid opcodes etc.  See copy_to_user and wrmsr_eio for examples.

I think you confuse hardware interrupts or exceptions with
language exceptions (which are the topic of current discussion).
Language exceptions constitute a fancy equivalent of return
code checking. Every time you see the following code, an exception
is handled:

int foo () {
   int rc;
   bar_t *x;

   if ((x = do_bar()) == NULL) { rc = -ENOMEM; goto out_nobar; }
   if ((rc = quux()) != 0) goto out_noquux;
   more_stuff();
   return 0;

 out_noquux;
   undo_bar(x);
 out_nobar:
   return rc;
}

> The kernel model is "get it right the first time, so we don't need
> exception handlers".  You have not given any reason why the existing
> mechanisms are failing.

If you understand that we are not talking about oopses here,
you will see that we emulate quite a bit of stuff with gotos.
The problem with current practice is that it takes a fair bit
of discipline to prevent it from growing into spaghetti [*].

Personally, I have no problem handling current practices.
But I may see the point of the guy with the try/catch patch.
Do not make me to defend him though. I am trying to learn
is those exceptions are actually helpful. BTW, we all know
where they come from (all of Cutler's NT is written that way),
but let it not cloud our judgement.

[*] List of subtlietes in the example, that a number of driver
monkeys get wrong:
1. rc must always be set right. Sometimes it's extracted from ERR_PTR,
   sometimes other ways.
2. You must have the Russian Doll commit-uncommit order. If you
   cannot fall into this rigid scheme, you must use more functions.
3. Names for labels correspond to what fails, not what has to be undone
   (or else you cannot move stuff around).

-- Pete

  reply	other threads:[~2002-02-23 12:50 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-22 21:12 [RFC] [PATCH] C exceptions in kernel Dan Aloni
2002-02-22 21:28 ` Davide Libenzi
2002-02-22 22:10 ` Richard B. Johnson
2002-02-22 22:34 ` David B. Stevens
2002-02-22 22:48   ` Davide Libenzi
2002-02-23  3:37 ` Edgar Toernig
     [not found] ` <mailman.1014437101.26721.linux-kernel2news@redhat.com>
2002-02-23 10:11   ` Pete Zaitcev
2002-02-23 12:26     ` Keith Owens
2002-02-23 12:50       ` Pete Zaitcev [this message]
2002-02-23 23:07         ` Jes Sorensen
2002-02-23 23:40           ` Keith Owens
2002-02-24  1:02             ` Jes Sorensen
2002-02-24 23:45               ` Richard Gooch
2002-02-23 23:50         ` Bill Huey
2002-02-24  1:31           ` Davide Libenzi
2002-02-24  2:55             ` Bill Huey
2002-02-23 15:13 ` Felix von Leitner
2002-02-23 15:21 ` bert hubert
2002-02-23 16:05   ` Dan Aloni
2002-02-23 16:22     ` Larry McVoy
2002-02-23 17:00       ` Dan Aloni
2002-02-23 17:52         ` Francois Romieu
2002-02-23 17:07       ` bert hubert
2002-02-23 17:47   ` Alexander Viro
2002-02-23 18:21     ` bert hubert
2002-02-23 18:31       ` Larry McVoy
2002-02-23 18:38         ` bert hubert
2002-02-23 19:12           ` Kurt Ferreira
2002-02-23 23:05       ` Jes Sorensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020223075002.A23666@devserv.devel.redhat.com \
    --to=zaitcev@redhat.com \
    --cc=kaos@ocs.com.au \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox