[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9d7f88da-d8eb-4c2b-9380-30b6a0a46076@kylinos.cn>
Date: Thu, 3 Jul 2025 13:14:30 +0800
From: Zihuan Zhang <zhangzihuan@...inos.cn>
To: "Rafael J. Wysocki" <rafael@...nel.org>
Cc: pavel@...nel.org, len.brown@...el.com, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] PM: hibernate: Avoid redundant resume_device
assignment in resume_store()
Hi Rafael,
在 2025/7/3 02:51, Rafael J. Wysocki 写道:
> On Fri, May 30, 2025 at 12:00 PM Zihuan Zhang <zhangzihuan@...inos.cn> wrote:
>> In resume_store(), if the device number written to /sys/power/resume
>> is the same as the current swsusp_resume_device, we can skip reassignment.
>> This avoids unnecessary locking and improves efficiency slightly.
>>
>> Signed-off-by: Zihuan Zhang <zhangzihuan@...inos.cn>
>> ---
>> kernel/power/hibernate.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
>> index 519fb09de5e0..504a1c2465ce 100644
>> --- a/kernel/power/hibernate.c
>> +++ b/kernel/power/hibernate.c
>> @@ -1291,6 +1291,9 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
>> if (error)
>> return error;
>>
>> + if (dev == swsusp_resume_device)
>> + return n;
>> +
> The main purpose of this function is to run software_resume(), not to
> set swsusp_resume_device. You're breaking it with this change.
Thank you for the feedback.
You’re absolutely right — I misunderstood the primary role of
resume_store() as being only to update swsusp_resume_device, and I
overlooked that its main purpose is to trigger software_resume().
I’ll drop this patch accordingly. Thanks again for pointing this out.
>> sleep_flags = lock_system_sleep();
>> swsusp_resume_device = dev;
>> unlock_system_sleep(sleep_flags);
>> --
>> 2.25.1
>>
Best regards,
Zihuan Zhang
Powered by blists - more mailing lists