public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Pavel Machek <pavel@kernel.org>, Len Brown <lenb@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	driver-core@lists.linux.dev
Subject: Re: [PATCH] PM / wakeup: Allocate class wakeup_class statically
Date: Fri, 3 Apr 2026 13:02:41 +0200	[thread overview]
Message-ID: <f0ac89b0-2b6d-429c-9716-51a00832d7b2@gmail.com> (raw)
In-Reply-To: <CAJZ5v0jTTdJDPDk3ACVpjP=S5nrA-vddfKBnFRyWSbHCuWWKQQ@mail.gmail.com>

On 03.04.2026 12:45, Rafael J. Wysocki wrote:
> On Thu, Apr 2, 2026 at 3:05 PM Heiner Kallweit <hkallweit1@gmail.com> wrote:
>>
>> On 01.04.2026 19:32, Rafael J. Wysocki wrote:
>>> On Wed, Apr 1, 2026 at 5:45 PM Heiner Kallweit <hkallweit1@gmail.com> wrote:
>>>>
>>>> On 01.04.2026 16:19, Rafael J. Wysocki wrote:
>>>>> On Sun, Mar 29, 2026 at 6:14 PM Heiner Kallweit <hkallweit1@gmail.com> wrote:
>>>>>>
>>>>>> Allocating wakeup_class statically avoids a little runtime overhead.
>>>>>> Define groups and device release function as part of the class, so that
>>>>>> we don't have to repeat this for each class device.
>>>>>> Whilst at it, constify wakeup_source_attrs[].
>>>>>>
>>>>>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>>>>>
>>>>> Can you please have a look at this and let me know what you think:
>>>>>
>>>>> https://sashiko.dev/#/patchset/0fe1b679-ab28-4505-b0db-14e7ac3ba749%40gmail.com
>>>>>
>>>> Interesting finding! I think the diagnosis is right.
>>>>
>>>> But: I would say the current behavior isn't a nice solution as well:
>>>
>>> It is not fantastic, but it doesn't have this issue.
>>>
>>>> wakeup_source_device_create() does: dev->class = wakeup_class;
>>>> I think no reader will expect that wakeup_class may be NULL here due to
>>>> initcall ordering. In addition this behavior results in such early
>>>> wakeup sources not being shown in sysfs.
>>>
>>> They are registered too early to show up in sysfs, but they can work regardless.
>>>
>>> I think that it's just pointless to call device_register() for a given
>>> wakeup source if wakeup_class has not been registered yet.
>>>
>>>> But I'm not sure whether registering class "wakeup" (and registering
>>>> classes in general) would be possible early enough (core_initcall,
>>>> or even pure_initcall).
>>>
>>> driver_init() is called before do_initcalls() is do_basic_setup(), so
>>> class registration should work for all initcall levels AFAICS.
>>>
>> When testing the current code on my system, autosleep is the first wakeup
>> source, registered in a core_initcall, and it's not shown in sysfs.
>> Same result when class wakeup is registered in a core_initcall
>> (instead of postcore_initcall). Registering class wakeup in a pure_initcall
>> works and fixes the issue. So, would this be an acceptable solution for the
>> discussed issue?
> 
> I don't see why not.

OK, then I'll send a patch for it. I was asking because comment in init.h says:

A "pure" initcall has no dependencies on anything else, and purely
*initializes variables* that couldn't be statically initialized.


      reply	other threads:[~2026-04-03 11:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-29 16:14 [PATCH] PM / wakeup: Allocate class wakeup_class statically Heiner Kallweit
2026-04-01 14:19 ` Rafael J. Wysocki
2026-04-01 15:45   ` Heiner Kallweit
2026-04-01 17:32     ` Rafael J. Wysocki
2026-04-02 13:05       ` Heiner Kallweit
2026-04-03 10:45         ` Rafael J. Wysocki
2026-04-03 11:02           ` Heiner Kallweit [this message]

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=f0ac89b0-2b6d-429c-9716-51a00832d7b2@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=lenb@kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=rafael@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