mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@debian.org>
To: linux-kernel@vger.kernel.org
Subject: [RFC] How should delete_resource() handle children?
Date: Tue, 10 Feb 2004 19:33:49 +0000	[thread overview]
Message-ID: <20040210193349.GI13351@parcelfarce.linux.theplanet.co.uk> (raw)


If you call release_resource() on a resource that has children, all
of those children are silently removed from the list too.  Does anybody
currently depend on that behaviour?

There are three valid behaviours I can think of for this:

 * Current behaviour, on the assumption that all the children of this
   resource are also owned by this device, and so removing them is the
   right thing to do.

 * BUG_ON() on the basis you should never do this.

 * Reparent the children to the parent resource of the one being released.

The first option has the problem that if the children of the resource
belong to some other part of the system, they still have pointers into
their parent which is now gone.  Memory corruption will follow.

The second option has the problem that if you *do* need to delete this
resource but keep its children linked in, you can't do it in a race-free
manner.

The third option has the problem that if you were relying on the current
behaviour of release_resource(), the parent/siblings of the deleted
resource still have references to objects you thought were deleted.


I like the third option best.  Now that we have insert_resource(), the
corresponding release_resource() should leave the children in the state
they were in before.

An alternative possibility would be to introduce a remove_resource()
that implements the reparenting option and leave the current behaviour
of release_resource() alone.


Comments?

-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain

             reply	other threads:[~2004-02-10 19:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-10 19:33 Matthew Wilcox [this message]
2004-02-19  1:48 ` Randy.Dunlap
2004-02-19  2:12   ` Nick Piggin
2004-02-19  2:07     ` Randy.Dunlap
2004-02-19  2:20   ` Matthew Wilcox

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=20040210193349.GI13351@parcelfarce.linux.theplanet.co.uk \
    --to=willy@debian.org \
    --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

all inboxes | Powered by JetHome®