From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (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 D99A937269A for ; Thu, 30 Apr 2026 04:58:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777525097; cv=none; b=G3BmUT93vuwaNYiJAyvgJKg4N1MxVp0ECwQi3jnMuCXlbc+J2U1PzcbdNNIh/eJICRU8s+RpGul+IfWIL/0nYBCNyEOWEBGYT4xX+RfFuoAQxr3Sp3f7NbevuacgvWsmQDwzSL9yy264lDT+HgfKh+wFeB3vwgl5G0I89xgSQZg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777525097; c=relaxed/simple; bh=qF6eZk+yeclM4g86GuAJoRMyf62spLKVPpLXfwDzc6U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=oQeg2XUfpTq2d/dYaOdL91OoZ+F2kRRSOElz7C2VkVqArHHTqz5QVEYzB3I5vxeibTB7CZwie7IO5hOKplnUJRehgCeF7CJqk2RV4jkvPuDIs0GqwBiPM9FYMYqg/X6I64ycDe0QSkrypklI4b5e97SnT/G7BbuH39uoA4NmwPE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=nOmkU7+x; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="nOmkU7+x" Message-ID: <9f9bb7d9-ca9b-4a8b-bb6f-093bc27a63f9@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1777525092; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nOeEENJP1qRQ6oeQfqR7IGsNJOArnz9T4pL66Gjzcg8=; b=nOmkU7+xdE5TInxjcUQxokbTqasETg2shl7eEasMnHfaFBh/zFHzXk+Q8n7hbdB2iUV/hJ 5WimqGrGeOCPa4rI9bbUHAKjntgr52+2LDhZSrIwAYxEul4UCMZDgBenUKVQAUEJ27xOE1 2VkLgme0XLOYgJKIxqH9kIlEwdvYK84= Date: Thu, 30 Apr 2026 12:58:03 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] mm/huge_memory: skip huge_zero_pmd in zap_huge_pmd_folio() Content-Language: en-US To: maobibo@loongson.cn Cc: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, ziy@nvidia.com, baolin.wang@linux.alibaba.com, Liam.Howlett@oracle.com, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20260430041121.2839350-1-maobibo@loongson.cn> <20260430042834.80895-1-lance.yang@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Lance Yang In-Reply-To: <20260430042834.80895-1-lance.yang@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2026/4/30 12:28, Lance Yang wrote: > > On Thu, Apr 30, 2026 at 12:11:20PM +0800, Bibo Mao wrote: >> when executing command "make check" with qemu software, there is >> error report like this: >> BUG: Bad rss-counter state mm:00000000972846bc type:MM_FILEPAGES val:-4096 Comm:bios-tables-tes Pid:27802 >> BUG: Bad rss-counter state mm:00000000752180c5 type:MM_FILEPAGES val:-2048 Comm:worker Pid:27815 >> BUG: Bad rss-counter state mm:000000009c2f6a61 type:MM_FILEPAGES val:-2048 Comm:qom-test Pid:27825 > > Good catch! > >> The problem is that when application exits, rss counter is calculated >> with huge_zero_pmd huge page, instead it should be skipped. > > Looks like the same problem[1] we discussed recently. > > [1] https://lore.kernel.org/linux-mm/74a75b59-2e13-3985-ee99-d5521f39df2a@google.com/ > >> Signed-off-by: Bibo Mao >> --- >> mm/huge_memory.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/mm/huge_memory.c b/mm/huge_memory.c >> index 970e077019b7..3cbea344d4a2 100644 >> --- a/mm/huge_memory.c >> +++ b/mm/huge_memory.c >> @@ -2423,6 +2423,9 @@ static void zap_huge_pmd_folio(struct mm_struct *mm, struct vm_area_struct *vma, >> { >> const bool is_device_private = folio_is_device_private(folio); >> >> + if (is_huge_zero_pmd(pmdval)) >> + return; >> + > > The huge zero PMD should not be returned by vm_normal_page_pmd() or > vm_normal_folio_pmd() as a normal folio. If it reaches > zap_huge_pmd_folio(), we already made the wrong normal-vs-special > decision ... > > So I don't think we should special-case it in zap_huge_pmd_folio(). That > only avoids this RSS decrement :) > > Could you please check whether the fix[2] also fixes your QEMU test? In addition, like x86-32, 64-bit LoongArch selects ARCH_HAS_PTE_SPECIAL, but not ARCH_SUPPORTS_HUGE_PFNMAP. So CONFIG_ARCH_SUPPORTS_PMD_PFNMAP is not enabled, and pmd_special() falls back to the generic stub that always returns false. So I guess the fix should do the trick :) > [2] https://lore.kernel.org/linux-mm/ea1453a6-14c9-4334-ac7e-2758586393b2@kernel.org/ > > Thanks, Lance