From: Wei Yang <richard.weiyang@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Wei Yang <richard.weiyang@gmail.com>,
"Schmid, Carsten" <Carsten_Schmid@mentor.com>,
"bp@suse.de" <bp@suse.de>,
"dan.j.williams@intel.com" <dan.j.williams@intel.com>,
"mingo@kernel.org" <mingo@kernel.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"bhelgaas@google.com" <bhelgaas@google.com>,
"osalvador@suse.de" <osalvador@suse.de>,
"rdunlap@infradead.org" <rdunlap@infradead.org>,
"richardw.yang@linux.intel.com" <richardw.yang@linux.intel.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Subject: Re: Resend [PATCH] kernel/resource.c: invalidate parent when freed resource has childs
Date: Sat, 10 Aug 2019 00:44:58 +0000 [thread overview]
Message-ID: <20190810004458.mio4vp3nk6jl2hyh@master> (raw)
In-Reply-To: <CAHk-=wi_9sdMxurjZ1MbNnxt-pA=dqoyf8Fdn9aYc8xvjjnTBg@mail.gmail.com>
On Fri, Aug 09, 2019 at 03:45:59PM -0700, Linus Torvalds wrote:
>On Fri, Aug 9, 2019 at 3:38 PM Wei Yang <richard.weiyang@gmail.com> wrote:
>>
>> In theory, child may have siblings. Would it be possible to have several
>> devices under xhci-hcd?
>
>I'm less interested in the xhci-hcd case - which I certainly *hope* is
>fixed already? - than in "if this happens somewhere else".
>
Agree, this is what I want to say.
>So if we do want to remove the parent (which may be a good idea with a
>warning), and want to make sure that the children are really removed
>from the resource hierarchy, we should do somethiing like
>
> static bool detach_children(struct resource *res)
> {
> res = res->child;
> if (!res)
> return false;
> do {
> res->parent = NULL;
> res = res->sibling;
> } while (res);
> return true;
> }
>
>and then we could write the __release_region() warning as
>
> /* You should not release a resource that has children */
> WARN_ON_ONCE(detach_children(res));
>
I am thinking about why this could happen.
To guard the core kernel code, it looks reasonable.
>or something?
>
>NOTE! The above is entirely untested, and written purely in my mail
>reader. It might be seriously buggy, including not compiling, or doing
>odd things. See it more as a "maybe something like this" code snippet
>example than any kind of final form.
>
> Linus
--
Wei Yang
Help you, Help me
next prev parent reply other threads:[~2019-08-10 0:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-08 15:40 [PATCH] kernel/resource.c: invalidate parent when freed resource has childs Schmid, Carsten
2019-08-09 13:50 ` Resend " Schmid, Carsten
2019-08-09 16:59 ` Dan Williams
2019-08-09 18:37 ` Joe Perches
2019-08-09 18:54 ` [PATCH] kernel/resource.c: Convert printks to pr_<level> Joe Perches
2019-08-09 20:09 ` Resend [PATCH] kernel/resource.c: invalidate parent when freed resource has childs Linus Torvalds
2019-08-09 22:38 ` Wei Yang
2019-08-09 22:45 ` Linus Torvalds
2019-08-10 0:44 ` Wei Yang [this message]
2019-08-12 8:39 ` AW: " Schmid, Carsten
2019-08-13 8:09 ` Schmid, Carsten
2019-08-14 14:48 ` [PATCH v2] " Schmid, Carsten
2019-08-14 16:29 ` Wei Yang
2019-08-15 8:18 ` AW: " Schmid, Carsten
2019-08-15 13:03 ` Wei Yang
2019-08-15 13:17 ` AW: " Schmid, Carsten
2019-08-16 10:18 ` [PATCH] kernel/resource.c: warn if released region has children Schmid, Carsten
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=20190810004458.mio4vp3nk6jl2hyh@master \
--to=richard.weiyang@gmail.com \
--cc=Carsten_Schmid@mentor.com \
--cc=bhelgaas@google.com \
--cc=bp@suse.de \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=osalvador@suse.de \
--cc=rdunlap@infradead.org \
--cc=richardw.yang@linux.intel.com \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).