linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Qiang Liu <liuq131@chinatelecom.cn>,
	baolin.wang@linux.alibaba.com,
	Kemeng Shi <shikemeng@huaweicloud.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm/compaction: remove unnecessary detection code.
Date: Thu, 14 Nov 2024 08:44:40 +0100	[thread overview]
Message-ID: <2b6ca5b1-f421-4dda-a2a2-865af97b2db8@suse.cz> (raw)
In-Reply-To: <20241114065720.3665-1-liuq131@chinatelecom.cn>

On 11/14/24 07:57, Qiang Liu wrote:
> It is impossible for the situation where blockpfn > end_pfn to arise,
> The if statement here is not only unnecessary, but may also lead to
> a misunderstanding that blockpfn > end_pfn could potentially happen.
> so these unnecessary checking code should be removed.
> 
> Signed-off-by: Qiang Liu <liuq131@chinatelecom.cn>

I see that's since 3da0272a4c7d ("mm/compaction: correctly return failure
with bogus compound_order in strict mode")

I think that commit introduced a risk of overflow due to a bogus order
(which we read in a racy way), and once blockpfn overflows it will satisfy
<= end_pfn and might e.g. end up scanning a completely different zone?

                        if (blockpfn + (1UL << order) <= end_pfn) {

                                blockpfn += (1UL << order) - 1;
                                page += (1UL << order) - 1;
                                nr_scanned += (1UL << order) - 1;
                        }

We should better add back the MAX_ORDER sanity check?

> ---
>  mm/compaction.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index a2b16b08cbbf..baeda7132252 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -682,12 +682,6 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
>  	if (locked)
>  		spin_unlock_irqrestore(&cc->zone->lock, flags);
>  
> -	/*
> -	 * Be careful to not go outside of the pageblock.
> -	 */
> -	if (unlikely(blockpfn > end_pfn))
> -		blockpfn = end_pfn;
> -
>  	trace_mm_compaction_isolate_freepages(*start_pfn, blockpfn,
>  					nr_scanned, total_isolated);
>  



  reply	other threads:[~2024-11-14  7:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-14  6:57 Qiang Liu
2024-11-14  7:44 ` Vlastimil Babka [this message]
2024-11-14  7:52   ` Vlastimil Babka
2024-11-14 10:06     ` Baolin Wang
2024-11-14  9:21   ` Kemeng Shi
2024-11-14  9:37     ` Vlastimil Babka

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=2b6ca5b1-f421-4dda-a2a2-865af97b2db8@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liuq131@chinatelecom.cn \
    --cc=shikemeng@huaweicloud.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