From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BBC53F9FB for ; Mon, 20 Apr 2026 08:01:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.111 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776672079; cv=none; b=maKrRis9zRkvM4/d/gD5geqZZmn9qcGlj3hxmVCIwNFo6IwxhXR+XL+r1VtMYHQOZ5CHLbeSMApNLeDwKh+tUvksm16v78DYwwfGPQLnSV8x4ZtvXwpcL5bDqrirU4ep0VR5nlMbnQkDXp73A0s9CqtlIvhq688N/JrMDKVIazo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776672079; c=relaxed/simple; bh=XBchoTvddmRP4iRyX5qXcVfAhuMApegSEF+Hy/T4jJM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=kHDk1ZipLZALg6oyYqvVgsU8ViVS3yK3smOcXVevzJdUsnPiqJ6/HQKwEJWeENLgvx/L29BXrPziFsQK3Dw6tmr5u1pOaNBFYAA8d7EkVOJrjeVI94/+mRq7mrEAON/1HAapRJwCk1WM5K3oeSFyWyXA1+bULyL6oF+Ja4zctV8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=u17F74nc; arc=none smtp.client-ip=115.124.30.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="u17F74nc" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1776672069; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=buRq9RvF/EF6GKBQx2WyRvyRBOYOt+melvj1U+/4eY0=; b=u17F74ncbXrC2kof5lcm7YZMstRbWgpdd/iKJAkBf9sz0dpiAeRi1TxtQ2ikY+GyC4draUJZrttCsJE8BeHG6XRRP8o81K5QHvY9iOWRI2FcZUb+Wp1wgRU9aHp6oMXaUAMVQgQhy+kw2+1L24V2blzh2X7nrsjDYl/qgsFEneY= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045098064;MF=ying.huang@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0X1J0Agi_1776672067; Received: from DESKTOP-5N7EMDA(mailfrom:ying.huang@linux.alibaba.com fp:SMTPD_---0X1J0Agi_1776672067 cluster:ay36) by smtp.aliyun-inc.com; Mon, 20 Apr 2026 16:01:08 +0800 From: "Huang, Ying" To: Sunny Patel Cc: Andrew Morton , David Hildenbrand , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Alistair Popple , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/migrate_device: Cleanup up PMD Checks and warnings In-Reply-To: <20260419174747.10701-1-nueralspacetech@gmail.com> (Sunny Patel's message of "Sun, 19 Apr 2026 23:17:43 +0530") References: <20260419174747.10701-1-nueralspacetech@gmail.com> Date: Mon, 20 Apr 2026 16:01:05 +0800 Message-ID: <87tst6hxha.fsf@DESKTOP-5N7EMDA> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sunny Patel writes: > Remove the odd VM_WARN_ON_FOLIO(!folio, folio) usage and replace it > with a simpler VM_WARN_ON_ONCE(!folio) check. > > Drop the redundant VM_WARN_ON_ONCE(!pmd_none(*pmdp) && > !is_huge_zero_pmd(*pmdp)). > > Refactor the PMD checks, making the control flow > clearer and avoiding duplicate condition checks. > > Signed-off-by: Sunny Patel > --- > > Changes in v2: > - Removed additional check for pmd_present() as is_huge_zero_pmd() > already checks for pmd_present(). > > Missed it in first version of this patch. > > mm/migrate_device.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/mm/migrate_device.c b/mm/migrate_device.c > index 8079676c8f1f..2c7e89a6d1b1 100644 > --- a/mm/migrate_device.c > +++ b/mm/migrate_device.c > @@ -807,8 +807,7 @@ static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate, > bool flush = false; > unsigned long i; > > - VM_WARN_ON_FOLIO(!folio, folio); > - VM_WARN_ON_ONCE(!pmd_none(*pmdp) && !is_huge_zero_pmd(*pmdp)); > + VM_WARN_ON_ONCE(!folio); > > if (!thp_vma_suitable_order(vma, addr, HPAGE_PMD_ORDER)) > return -EINVAL; > @@ -865,11 +864,9 @@ static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate, > if (userfaultfd_missing(vma)) > goto unlock_abort; > > - if (!pmd_none(*pmdp)) { > - if (!is_huge_zero_pmd(*pmdp)) > - goto unlock_abort; > + if (is_huge_zero_pmd(*pmdp)) > flush = true; > - } else if (!pmd_none(*pmdp)) > + else if (!pmd_none(*pmdp)) > goto unlock_abort; > > add_mm_counter(vma->vm_mm, MM_ANONPAGES, HPAGE_PMD_NR); LGTM, feel free to add my Reviewed-by: Huang Ying in the future versions. --- Best Regards, Huang, Ying