From: Matthew Wilcox <willy@infradead.org>
To: "zhaoyang.huang" <zhaoyang.huang@unisoc.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Minchan Kim <minchan@kernel.org>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Zhaoyang Huang <huangzhaoyang@gmail.com>,
ke.wang@unisoc.com
Subject: Re: [PATCHv3] mm: skip CMA pages when they are not available
Date: Mon, 22 May 2023 05:07:52 +0100 [thread overview]
Message-ID: <ZGrqmOfdnhSz9sq9@casper.infradead.org> (raw)
In-Reply-To: <1684724882-22266-1-git-send-email-zhaoyang.huang@unisoc.com>
On Mon, May 22, 2023 at 11:08:02AM +0800, zhaoyang.huang wrote:
> +static bool skip_cma(struct page *page, struct scan_control *sc)
> +{
> + if (!current_is_kswapd() && gfp_migratetype(sc->gfp_mask) != MIGRATE_MOVABLE
> + && get_pageblock_migratetype(page) == MIGRATE_CMA)
> + return true;
Putting the 'return' at the same level of indentation as the second half
of the conditional is wrong. It confuses the reader. Also, the &&
needs to go at the end of the line not the beginning (read the
codingstyle documentation!) Also there's no good reason to use such
long lines. ie do this instead:
if (!current_is_kswapd() &&
gfp_migratetype(sc->gfp_mask) != MIGRATE_MOVABLE &&
get_pageblock_migratetype(page) == MIGRATE_CMA)
return true;
if you prefer, this style of indent is also acceptable:
if (!current_is_kswapd() &&
gfp_migratetype(sc->gfp_mask) != MIGRATE_MOVABLE &&
get_pageblock_migratetype(page) == MIGRATE_CMA)
return true;
> @@ -2225,10 +2242,12 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan,
> unsigned long nr_skipped[MAX_NR_ZONES] = { 0, };
> unsigned long skipped = 0;
> unsigned long scan, total_scan, nr_pages;
> + struct page *page;
No, don't do this.
> LIST_HEAD(folios_skipped);
>
> total_scan = 0;
> scan = 0;
> +
Don't add this completely unrelated whitespace change either.
> while (scan < nr_to_scan && !list_empty(src)) {
> struct list_head *move_to = src;
> struct folio *folio;
> @@ -2239,12 +2258,14 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan,
> nr_pages = folio_nr_pages(folio);
> total_scan += nr_pages;
>
> - if (folio_zonenum(folio) > sc->reclaim_idx) {
> + page = &folio->page;
> +
> + if (folio_zonenum(folio) > sc->reclaim_idx
> + || skip_cma(page, sc)) {
Again, this is not where the || goes.
And skip_cma() should take a folio, not a page. It's unreasonable
to ask you to convert get_pageblock_migratetype(),
get_pfnblock_flags_mask(), __get_pfnblock_flags_mask(), etc to
use a folio (... although someone looking for a project could do that
...). Instead, you should do the folio->page conversion inside
skip_cma().
> nr_skipped[folio_zonenum(folio)] += nr_pages;
> move_to = &folios_skipped;
> goto move;
> }
> -
No unnecessary whitespace changes.
prev parent reply other threads:[~2023-05-22 4:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-22 3:08 zhaoyang.huang
2023-05-22 4:07 ` Matthew Wilcox [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=ZGrqmOfdnhSz9sq9@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=huangzhaoyang@gmail.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=ke.wang@unisoc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=zhaoyang.huang@unisoc.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