From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 066B433D4F0 for ; Fri, 24 Apr 2026 18:29:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777055388; cv=none; b=u+qxIZAs7j8gjZgv23oU3/8WY97nZ0eN7X3yAHPFYW5mDXK4nn27Rt6OtIL+dpU9ZQx+85yYLCSc+vn9SmQz9vgyRDj0CClj5yFGTEg9Efdk/EyPsZ7rKkOVVHUFM7tnmG2e63MXGHhvxqmR/euOkIX9Dfi/BzSc0tklzDJu4T4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777055388; c=relaxed/simple; bh=3kkooBEHJF5hLBMrc88e/f1Fx4klTLxcQLIvIY/U0pw=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=YkAXaTDzDmNKhG3Dx0y9ik7KKe52iZQiUHGw3TEBjobJJ42qn6lyEZKMdllE/wG93S8Piw2iXjsA4xc84dhf8OZMXvHilGndBnk4cV5Ha4gdaCNHmGUmqtj1C82lf4AYNrD0cgk58Ai++jKjuTXhnVXullqzRrKK4CfW3FZQNu4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=TkEikQa7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="TkEikQa7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BEBDC19425; Fri, 24 Apr 2026 18:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1777055387; bh=3kkooBEHJF5hLBMrc88e/f1Fx4klTLxcQLIvIY/U0pw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=TkEikQa7+cB0BwOlrtQLBC2F8wSXhYtRVNQR11G6dPJNZqLw+ED3uvByC+3EPR7fR u/5hKjCBfJo635Lqq+gMhUEX+p42mdk4Yn3cTlrG9iGOI0OClH03vexG51H8GpqQVc 8US1nADY16Mb6wLjtIA8VnRBe8p9RitxsQ3c8+Uw= Date: Fri, 24 Apr 2026 11:29:46 -0700 From: Andrew Morton To: Sunny Patel Cc: apopple@nvidia.com, byungchul@sk.com, david@kernel.org, gourry@gourry.net, joshua.hahnjy@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, matthew.brost@intel.com, rakie.kim@sk.com, ying.huang@linux.alibaba.com, ziy@nvidia.com Subject: Re: [PATCH] mm/migrate_device: Cleanup up PMD Checks and warnings Message-Id: <20260424112946.4b4ba29987e166dfade76c2c@linux-foundation.org> In-Reply-To: <20260424172208.11674-1-nueralspacetech@gmail.com> References: <20260424065922.5f15ca8c88eaf8a02847af17@linux-foundation.org> <20260424172208.11674-1-nueralspacetech@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 24 Apr 2026 22:52:08 +0530 Sunny Patel wrote: > On Sun, 19 Apr 2026 23:17:43 +0530 Sunny Patel wrote: > > > 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. > > AI review might have found a bug in the surrounding code: > https://sashiko.dev/#/patchset/20260419174747.10701-1-nueralspacetech@gmail.com > > After looking into the AI comment found two potential leak. > > 1. The goto should be unlock_abort instead of abort to ensure > the spinlock is released. > > 2. The pgtable allocation at the top of the function > is indeed not freed on the unlock_abort path. Will add a > pte_free(vma->vm_mm, pgtable). > > Since this patch is more of Cleanup on PMD checks and > Warnings Is it ok if I send different patch to address > this potential leak issues or need it in this revision > itself? A separate patch, please. It's best to prepare the bugfix patch against current Linus mainline, then any cleanups come on top of the bugfix. Thanks.