linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hao Lee <haolee.swjtu@gmail.com>
To: hui yang <yanghui.def@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm:remove useless code
Date: Wed, 23 Dec 2020 15:32:58 +0800	[thread overview]
Message-ID: <CA+PpKPkAdiYR8e=CToCzc4gAGaH4Py5dZ1LboaUROAo_QyTZzA@mail.gmail.com> (raw)
In-Reply-To: <1608707589-6067-1-git-send-email-yanghui.def@gmail.com>

On Wed, Dec 23, 2020 at 3:13 PM hui yang <yanghui.def@gmail.com> wrote:
>
> From: YangHui <yanghui.def@gmail.com>
>
> remove useless code
>
> Signed-off-by: YangHui <yanghui.def@gmail.com>
> ---
>  mm/vmscan.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 257cba7..af1d176 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1234,8 +1234,8 @@ static unsigned int shrink_page_list(struct list_head *page_list,
>                  * Try to allocate it some swap space here.
>                  * Lazyfree page could be freed directly
>                  */
> -               if (PageAnon(page) && PageSwapBacked(page)) {
> -                       if (!PageSwapCache(page)) {
> +               if (PageAnon(page) && PageSwapBacked(page) &&
> +                       !PageSwapCache(page)) {

I think this is incorrect.

Consider this scenario:

PageAnon(page) && PageSwapBacked(page) is true
!PageSwapCache(page) is false

In original logic, this snippet will run into the first if branch which
does nothing actually. However, in your logic, this snippet will run
into else if branch.

Regards,
Hao Lee

>                                 if (!(sc->gfp_mask & __GFP_IO))
>                                         goto keep_locked;
>                                 if (PageTransHuge(page)) {
> @@ -1270,7 +1270,6 @@ static unsigned int shrink_page_list(struct list_head *page_list,
>
>                                 /* Adding to swap updated mapping */
>                                 mapping = page_mapping(page);
> -                       }
>                 } else if (unlikely(PageTransHuge(page))) {
>                         /* Split file THP */
>                         if (split_huge_page_to_list(page, page_list))
> --
> 2.7.4
>
>


  reply	other threads:[~2020-12-23  7:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23  7:13 hui yang
2020-12-23  7:32 ` Hao Lee [this message]
2020-12-23  7:43 ` Souptick Joarder

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='CA+PpKPkAdiYR8e=CToCzc4gAGaH4Py5dZ1LboaUROAo_QyTZzA@mail.gmail.com' \
    --to=haolee.swjtu@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=yanghui.def@gmail.com \
    /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