public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: TGSP <tgsp002@gmail.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: xiongxin@kylinos.cn, len.brown@intel.com, pavel@ucw.cz,
	huanglei@kylinos.cn, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH -next 1/2] PM: hibernate: fix spelling mistake for annotation
Date: Fri, 4 Nov 2022 15:31:49 +0800	[thread overview]
Message-ID: <fe95b054-e720-ebbf-ba03-4ea6662974ad@gmail.com> (raw)
In-Reply-To: <CAJZ5v0iPFPbbconOoQ7x_4X5yJ31pP7aduLqG4dq6KgAsprKbA@mail.gmail.com>

在 2022/11/4 00:25, Rafael J. Wysocki 写道:
> On Tue, Nov 1, 2022 at 3:28 AM TGSP <tgsp002@gmail.com> wrote:
>>
>> From: xiongxin <xiongxin@kylinos.cn>
>>
>> The actual calculation formula in the code below is:
>>
>> max_size = (count - (size + PAGES_FOR_IO)) / 2
>>              - 2 * DIV_ROUND_UP(reserved_size, PAGE_SIZE);
>>
>> But function comments are written differently, the comment is wrong?
> 
> It is, and it is more serious than just a spelling mistake.
> 
>> By the way, what exactly do the "/ 2" and "2 *" mean?
> 
> Every page in the image is a copy of an existing allocated page, so
> room needs to be made for the two, except for the "IO pages" and
> metadata pages that are not copied.  Hence, the division by 2.
> 
> Now, the "reserved_size" pages will be allocated right before creating
> the image and there will be a copy of each of them in the image, so
> there needs to be room for twice as many.

According to your interpretation, the formula should be:
max_size = (count - 2 * DIV_ROUND_UP(reserved_size, PAGE_SIZE)
                - (size + PAGES_FOR_IO)) / 2

Am I right?

> 
> I'll adjust the changelog and queue up the path for 6.2.
> 
>> Cc: stable@vger.kernel.org
> 
> I'll add a Fixes tag instead.
> 
>> Signed-off-by: xiongxin <xiongxin@kylinos.cn>
>> ---
>>   kernel/power/snapshot.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
>> index 2a406753af90..c20ca5fb9adc 100644
>> --- a/kernel/power/snapshot.c
>> +++ b/kernel/power/snapshot.c
>> @@ -1723,8 +1723,8 @@ static unsigned long minimum_image_size(unsigned long saveable)
>>    * /sys/power/reserved_size, respectively).  To make this happen, we compute the
>>    * total number of available page frames and allocate at least
>>    *
>> - * ([page frames total] + PAGES_FOR_IO + [metadata pages]) / 2
>> - *  + 2 * DIV_ROUND_UP(reserved_size, PAGE_SIZE)
>> + * ([page frames total] - PAGES_FOR_IO - [metadata pages]) / 2
>> + *  - 2 * DIV_ROUND_UP(reserved_size, PAGE_SIZE)
>>    *
>>    * of them, which corresponds to the maximum size of a hibernation image.
>>    *
>> --
>> 2.25.1
>>


  reply	other threads:[~2022-11-04  7:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20221101022840.1351163-1-tgsp002@gmail.com>
2022-11-01  2:28 ` [PATCH -next 1/2] PM: hibernate: fix spelling mistake for annotation TGSP
2022-11-01 12:45   ` Bagas Sanjaya
2022-11-03 16:25   ` Rafael J. Wysocki
2022-11-04  7:31     ` TGSP [this message]
2022-11-05 18:09       ` Rafael J. Wysocki
2022-11-01  2:28 ` [PATCH -next 2/2] PM: hibernate: add check of preallocate mem for image size pages TGSP
2022-11-01 21:23   ` kernel test robot
2022-11-03 16:47   ` Rafael J. Wysocki
2022-11-03 16:57     ` Rafael J. Wysocki
2022-11-03 17:11   ` Rafael J. Wysocki
     [not found] <20221101022342.1345980-1-tgsp002@gmail.com>
2022-11-01  2:23 ` [PATCH -next 1/2] PM: hibernate: fix spelling mistake for annotation TGSP
     [not found] <20221031124837.720118-1-xiongxin@kylinos.cn>
2022-10-31 12:48 ` xiongxin
     [not found] <20221031124823.719912-1-xiongxin@kylinos.cn>
2022-10-31 12:48 ` xiongxin

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=fe95b054-e720-ebbf-ba03-4ea6662974ad@gmail.com \
    --to=tgsp002@gmail.com \
    --cc=huanglei@kylinos.cn \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=xiongxin@kylinos.cn \
    /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