From: Andrew Morton <akpm@linux-foundation.org>
To: Alex Shi <alex.shi@linux.alibaba.com>
Cc: Hugh Dickins <hughd@google.com>, Yu Zhao <yuzhao@google.com>,
Vlastimil Babka <vbabka@suse.cz>, Michal Hocko <mhocko@suse.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH next] mm/vmscan: __isolate_lru_page_prepare clean up
Date: Fri, 20 Nov 2020 15:13:07 -0800 [thread overview]
Message-ID: <20201120151307.4d9e3ef092ba01a325db7ce2@linux-foundation.org> (raw)
In-Reply-To: <1605859413-53864-1-git-send-email-alex.shi@linux.alibaba.com>
On Fri, 20 Nov 2020 16:03:33 +0800 Alex Shi <alex.shi@linux.alibaba.com> wrote:
> The function just return 2 results, so use a 'switch' to deal with its
> result is unnecessary, and simplify it to a bool func as Vlastimil
> suggested.
>
> Also removed 'goto' in using by reusing list_move().
>
> ...
>
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1540,7 +1540,7 @@ unsigned int reclaim_clean_pages_from_list(struct zone *zone,
> */
> int __isolate_lru_page_prepare(struct page *page, isolate_mode_t mode)
> {
> - int ret = -EBUSY;
> + int ret = false;
>
> /* Only take pages on the LRU. */
> if (!PageLRU(page))
> @@ -1590,7 +1590,7 @@ int __isolate_lru_page_prepare(struct page *page, isolate_mode_t mode)
> if ((mode & ISOLATE_UNMAPPED) && page_mapped(page))
> return ret;
>
> - return 0;
> + return true;
> }
The resulting __isolate_lru_page_prepare() is rather unpleasing.
- Why return an int and not a bool?
- `int ret = false' is a big hint that `ret' should have bool type!
- Why not just remove `ret' and do `return false' in all those `return
ret' places?
- The __isolate_lru_page_prepare() kerneldoc still says "returns 0 on
success, -ve errno on failure".
next prev parent reply other threads:[~2020-11-20 23:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 8:03 [PATCH next] mm/vmscan: __isolate_lru_page_prepare clean up Alex Shi
2020-11-20 23:13 ` Andrew Morton [this message]
2020-11-22 12:00 ` Alex Shi
2020-11-22 12:35 ` Matthew Wilcox
2020-11-22 14:00 ` Alex Shi
2020-11-24 11:21 ` Vlastimil Babka
2020-11-25 23:43 ` Andrew Morton
2020-11-26 2:25 ` Alex Shi
2020-11-26 15:23 ` Vlastimil Babka
2020-11-27 1:56 ` Alex Shi
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=20201120151307.4d9e3ef092ba01a325db7ce2@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=alex.shi@linux.alibaba.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=vbabka@suse.cz \
--cc=yuzhao@google.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;
as well as URLs for NNTP newsgroup(s).