From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout07.his.huawei.com (canpmsgout07.his.huawei.com [113.46.200.222]) (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 5D2CC2D5926 for ; Wed, 25 Feb 2026 06:27:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.222 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772000879; cv=none; b=D/OcuNYWHrnAAfsbYNUVRRP1UeVDrnHWhBpkl7NkHCWH98Jtl0xZr5PPlszzCxPOu5rRn+czk/EcAEwVMqEyrPpWPwQ+5sZjZZWcDR2xQDDovywKX+fsUz/g3+/iLvo2iLBC70cIBp36IAu+H7sdFGBWkdoqJGT1lVExIO3s4g8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772000879; c=relaxed/simple; bh=/8jodCmxkVxM1xLKUuK+58X0vayyV/esiv6stHqzXWs=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=anusaBf8mEJIlaEZSM3ju9290dAnGxYEoLUIUehdbAOQnFZV3qvAdGlFpu5GIfql1EWNmrHH58QoQuLntGP1sdjVtl/Vr2SgkkUq89LqyCx2HDohjrCSjuoMCt/HhMIVUerNnvYjGVMwEka2HB1kLjbjrUZ59zVOszWXqsIXeMk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=QynxAqD2; arc=none smtp.client-ip=113.46.200.222 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="QynxAqD2" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=fzmvl+WxG3Jff7cSYYgfD5qWpcTKs1nAA3CGqddqF1w=; b=QynxAqD2R4KnUQEf/Wp7qbiYSFhUH3njKbhuDePMT5qW/ksJVyoJ6uiSFegqmbyUWKl4gQ1hR 9n09eVvvmcO7g7MmfxwB46mv5HMgtMRkwaGzctBP0PYAy+MYjGGwbu5uA0tNBCdvyjGO4KaFdKT KrcCZTnea8deA2A4rJAM7I8= Received: from mail.maildlp.com (unknown [172.19.163.127]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4fLPfK1zKTzLlTD; Wed, 25 Feb 2026 14:23:05 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id E41EB402AB; Wed, 25 Feb 2026 14:27:51 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 25 Feb 2026 14:27:50 +0800 Message-ID: <9bc0d4e9-71ae-48e7-83cc-d42166d3eaee@huawei.com> Date: Wed, 25 Feb 2026 14:27:48 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] mm/cma: move put_page_testzero() out of VM_WARN_ON in cma_release() To: Zi Yan , Andrew Morton CC: David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , , , SeongJae Park , Ron Economos References: <20260225031231.2352011-1-ziy@nvidia.com> Content-Language: en-US From: Kefeng Wang In-Reply-To: <20260225031231.2352011-1-ziy@nvidia.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To dggpemf100008.china.huawei.com (7.185.36.138) On 2026/2/25 11:12, Zi Yan wrote: > When CONFIG_DEBUG_VM is not set, VM_WARN_ON is a NOP. Putting any statement > with side effect inside it is incorrect. Collect all !put_page_testzero() > results and check the sum using WARN instead after the loop. It restores > the same check in free_contig_range() before commit > e0c1326779cc ("mm: page_alloc: add alloc_contig_frozen_{range,pages}()"), > the commit prior to the Fixes one. > > Fixes: 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()") > Reported-by: Ron Economos > Closes: https://lore.kernel.org/all/1b17c38f-30d3-4bb4-a7e1-e74b19ada885@w6rz.net/ > Suggested-by: Kefeng Wang > Signed-off-by: Zi Yan > --- > From V2: > - Collect !put_page_testzero() to get the right result. > > From V1: > - Collect all put_page_testzero() results and do a single WARN after the > loop. > Reviewed-by: Kefeng Wang > mm/cma.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/mm/cma.c b/mm/cma.c > index 94b5da468a7d..15cc0ae76c8e 100644 > --- a/mm/cma.c > +++ b/mm/cma.c > @@ -1013,6 +1013,7 @@ bool cma_release(struct cma *cma, const struct page *pages, > unsigned long count) > { > struct cma_memrange *cmr; > + unsigned long ret = 0; > unsigned long i, pfn; > > cmr = find_cma_memrange(cma, pages, count); > @@ -1021,7 +1022,9 @@ bool cma_release(struct cma *cma, const struct page *pages, > > pfn = page_to_pfn(pages); > for (i = 0; i < count; i++, pfn++) > - VM_WARN_ON(!put_page_testzero(pfn_to_page(pfn))); > + ret += !put_page_testzero(pfn_to_page(pfn)); > + > + WARN(ret, "%lu pages are still in use!\n", ret); > > __cma_release_frozen(cma, cmr, pages, count); >