linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>
Subject: Re: [PATCH 2/2] kobject: send KOBJ_REMOVE uevent when the object is removed from sysfs
Date: Thu, 28 May 2020 06:56:19 -0700	[thread overview]
Message-ID: <64eb962a-eaef-9747-9408-eb9061cb42f6@roeck-us.net> (raw)
In-Reply-To: <CAJZ5v0jPoi+5d+jv0iAuKkObSr=EDxmMhNqMTvLQNUEc_i9zcg@mail.gmail.com>

On 5/28/20 3:57 AM, Rafael J. Wysocki wrote:
> On Thu, May 28, 2020 at 12:25 AM Guenter Roeck <linux@roeck-us.net> wrote:
>>
>> On Wed, May 27, 2020 at 11:01:16AM +0200, Rafael J. Wysocki wrote:
>>>
>>> So Guenter, can you please test the patch below to see if it still introduces
>>> the problems seen by you on ARM?
>>>
>>
>> arm64 and arm64be boot tests pass with the patch below.
> 
> Great, thanks!
> 
>> Some arm boot tests fail, but I think that is due to some other problem with -next.
>> Hard to say for sure at this point because -next is pretty badly broken
>> overall. I'll need to run some bisects to see what is going on.
> 
> I see.
> 

The failing arm boot tests are due to various dts changes (commit "arm64:
dts: vexpress: Move fixed devices out of bus node" and associated),
unrelated to this patch.

Guenter

> Thanks for giving this one a go.
> 
>>> ---
>>> From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>>> Subject: [PATCH] kobject: Make sure the parent does not get released before its children
>>>
>>> In the function kobject_cleanup(), kobject_del(kobj) is
>>> called before the kobj->release(). That makes it possible to
>>> release the parent of the kobject before the kobject itself.
>>>
>>> To fix that, adding function __kboject_del() that does
>>> everything that kobject_del() does except release the parent
>>> reference. kobject_cleanup() then calls __kobject_del()
>>> instead of kobject_del(), and separately decrements the
>>> reference count of the parent kobject after kobj->release()
>>> has been called.
>>>
>>> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
>>> Reported-by: kernel test robot <rong.a.chen@intel.com>
>>> Fixes: 7589238a8cf3 ("Revert "software node: Simplify software_node_release() function"")
>>> Suggested-by: "Rafael J. Wysocki" <rafael@kernel.org>
>>> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>>> [ rjw: Drop parent reference only when called __kobject_del() ]
>>> Signed-off-by: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>>> ---
>>>  lib/kobject.c |   34 +++++++++++++++++++++++-----------
>>>  1 file changed, 23 insertions(+), 11 deletions(-)
>>>
>>> Index: linux-pm/lib/kobject.c
>>> ===================================================================
>>> --- linux-pm.orig/lib/kobject.c
>>> +++ linux-pm/lib/kobject.c
>>> @@ -599,14 +599,7 @@ out:
>>>  }
>>>  EXPORT_SYMBOL_GPL(kobject_move);
>>>
>>> -/**
>>> - * kobject_del() - Unlink kobject from hierarchy.
>>> - * @kobj: object.
>>> - *
>>> - * This is the function that should be called to delete an object
>>> - * successfully added via kobject_add().
>>> - */
>>> -void kobject_del(struct kobject *kobj)
>>> +static void __kobject_del(struct kobject *kobj)
>>>  {
>>>       struct kernfs_node *sd;
>>>       const struct kobj_type *ktype;
>>> @@ -625,9 +618,23 @@ void kobject_del(struct kobject *kobj)
>>>
>>>       kobj->state_in_sysfs = 0;
>>>       kobj_kset_leave(kobj);
>>> -     kobject_put(kobj->parent);
>>>       kobj->parent = NULL;
>>>  }
>>> +
>>> +/**
>>> + * kobject_del() - Unlink kobject from hierarchy.
>>> + * @kobj: object.
>>> + *
>>> + * This is the function that should be called to delete an object
>>> + * successfully added via kobject_add().
>>> + */
>>> +void kobject_del(struct kobject *kobj)
>>> +{
>>> +     struct kobject *parent = kobj->parent;
>>> +
>>> +     __kobject_del(kobj);
>>> +     kobject_put(parent);
>>> +}
>>>  EXPORT_SYMBOL(kobject_del);
>>>
>>>  /**
>>> @@ -663,7 +670,9 @@ EXPORT_SYMBOL(kobject_get_unless_zero);
>>>   */
>>>  static void kobject_cleanup(struct kobject *kobj)
>>>  {
>>> +     struct kobject *parent = kobj->parent;
>>>       struct kobj_type *t = get_ktype(kobj);
>>> +     bool state_in_sysfs = kobj->state_in_sysfs;
>>>       const char *name = kobj->name;
>>>
>>>       pr_debug("kobject: '%s' (%p): %s, parent %p\n",
>>> @@ -681,10 +690,10 @@ static void kobject_cleanup(struct kobje
>>>       }
>>>
>>>       /* remove from sysfs if the caller did not do it */
>>> -     if (kobj->state_in_sysfs) {
>>> +     if (state_in_sysfs) {
>>>               pr_debug("kobject: '%s' (%p): auto cleanup kobject_del\n",
>>>                        kobject_name(kobj), kobj);
>>> -             kobject_del(kobj);
>>> +             __kobject_del(kobj);
>>>       }
>>>
>>>       if (t && t->release) {
>>> @@ -698,6 +707,9 @@ static void kobject_cleanup(struct kobje
>>>               pr_debug("kobject: '%s': free name\n", name);
>>>               kfree_const(name);
>>>       }
>>> +
>>> +     if (state_in_sysfs)
>>> +             kobject_put(parent);
>>>  }
>>>
>>>  #ifdef CONFIG_DEBUG_KOBJECT_RELEASE
>>>
>>>
>>>


  reply	other threads:[~2020-05-28 13:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-24 15:30 [PATCH 1/2] software node: implement software_node_unregister() Greg Kroah-Hartman
2020-05-24 15:30 ` [PATCH 2/2] kobject: send KOBJ_REMOVE uevent when the object is removed from sysfs Greg Kroah-Hartman
2020-05-25 11:07   ` Rafael J. Wysocki
2020-05-25 22:49   ` Dmitry Torokhov
2020-05-26  5:58     ` Greg Kroah-Hartman
2020-05-26  8:26       ` Rafael J. Wysocki
2020-05-27  7:50         ` Heikki Krogerus
2020-05-27  8:34           ` Rafael J. Wysocki
2020-05-27  9:01             ` Rafael J. Wysocki
2020-05-27 14:34               ` Rafael J. Wysocki
2020-05-27 22:25               ` Guenter Roeck
2020-05-28 10:57                 ` Rafael J. Wysocki
2020-05-28 13:56                   ` Guenter Roeck [this message]
2020-05-28 14:03                     ` Rafael J. Wysocki
2020-05-24 16:43 ` [PATCH 1/2] software node: implement software_node_unregister() Guenter Roeck
2020-05-25  2:44   ` Randy Dunlap
2020-05-25  7:59 ` Petr Mladek
2020-05-25 11:24 ` Heikki Krogerus
2020-05-26  0:12 ` Randy Dunlap
2020-05-28 20:25 ` Brendan Higgins

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=64eb962a-eaef-9747-9408-eb9061cb42f6@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.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;
as well as URLs for NNTP newsgroup(s).