public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Pierre Peiffer <pierre.peiffer@bull.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2.6.23-mm1] Change the ida/idr_pre_get() return value to follow the kernel convention
Date: Tue, 30 Oct 2007 10:33:56 -0700	[thread overview]
Message-ID: <20071030103356.bf11d1a7.akpm@linux-foundation.org> (raw)
In-Reply-To: <20071030171350.cd25b87c.pierre.peiffer@bull.net>

On Tue, 30 Oct 2007 17:13:50 +0100
Pierre Peiffer <pierre.peiffer@bull.net> wrote:

> 
> ida_pre_get() and idr_pre_get() currently return 0 in case of error, and 1
> in case of success, what is not the conventional way to handle error cases.
> 
> This patch makes both of them return 0 in case of success, and an errcode
> otherwise, and then it changes each caller to let them return the error
> reported instead of ENOMEM. This avoids to the callers to make any assumption
> about the cause of the error.
> 

If we're going to do this (and really we should), then we risk quietly
breaking out-of-tree code and we risk breaking in-tree or
soon-to-be-in-tree code which we didn't know about.

So what we should do is to rename these functions when we change their
interfaces.

Happily, this means that we then don't need to remove the old functions -
we can keep them there for a while as we transition everything over to the
new functions.  It also means that we can sneak the new functions into the
2.6.24 stream and then merge these changes via the relevant maintainers
rather than needing a single atomic megapatch.


Although I'd much prefer just to remove the pathetic things - idr_pre_get()
is a truly awful interface.

It would be slightly better if it took an `id' argument and filled in the
nodes at the appropriate position in the tree so that the caller is
guaranteed that the subsequent idr_get_new() will succeed.  Because at
present there is no guarantee that the nodes which you preallocated with
idr_pre_get() are still available when you do your idr_get_new(): some
other CPU/task might have come in and used them all.

Storage classes which need to allcoate memory at insertion time are hard:
radix_tree_preload() gets it right in terms of robustness, but it's an
awful lot of fuss.

IDR gets it all wrong and compounds the problem by implementing internal
locking.  It shouldn't have done that: storage code like this should use
only caller-provided locking.


  reply	other threads:[~2007-10-30 17:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-30 16:13 [PATCH 2.6.23-mm1] Change the ida/idr_pre_get() return value to follow the kernel convention Pierre Peiffer
2007-10-30 17:33 ` Andrew Morton [this message]
2007-10-31 10:06   ` Pierre Peiffer
2007-10-31 10:14     ` Andrew Morton

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=20071030103356.bf11d1a7.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pierre.peiffer@bull.net \
    /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