From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (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 734BA1F91F6 for ; Tue, 26 May 2026 12:56:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779800198; cv=none; b=Uj2aGjbVcJw7rFDZ6TTt+o9FhxhzyZycHtw56pFuUcJlDx4vo0MSAxfU8ONaeESH0EPH+dutsiilm7CJoD1nGe4w6ulg971GZeLKdpx60s0nC2sFgNGrj1N9rn3FONDdQ4t5ab1j6iV+OIeUqwnlVMlBajVoMMIkBuJ4uZEILdk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779800198; c=relaxed/simple; bh=JU7eq6I2jPDxDfe2T5IMnm9RAHvvxOtoBUIkCy5w30Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=P0J5ce3zvdwWvU2mPk6doBVyQKNgmCpDVxYUXNGoZJnH+mPyt6w2+BFck1nLtXCJdKwA6/VNny2aTX686EcXHj6CL1FqUfXuNGClWxrY43nU4p+9rbOgm2yQU1K+988bTmwRlyrRIFh+cfL7YovM1KDe4bsZlKRQacYsMZPVm+Q= 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=xnnaurTS; arc=none smtp.client-ip=95.215.58.180 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="xnnaurTS" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779800185; 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=JU7eq6I2jPDxDfe2T5IMnm9RAHvvxOtoBUIkCy5w30Q=; b=xnnaurTSzTJdSa9ximYjZKUGfBzMu7x5E4F8xHgkpgw3dHa/cX/0fuMStpiTt/KQF8aHlp TkFu/1Jsv+559dKjTrbn8MvXHO3OXjtXwJlkGiCVgZFNZGkCMGihP5MYjhCYZquLdsjAFx EOoMl6/aP7XO3g1OCgH+NqURHp+4Oio= From: Lance Yang To: yintirui@huawei.com Cc: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, ziy@nvidia.com, baolin.wang@linux.alibaba.com, liam@infradead.org, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, lance.yang@linux.dev, vbabka@kernel.org, yang.shi@linux.alibaba.com, wangkefeng.wang@huawei.com, chenjun102@huawei.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] mm/huge_memory: update file PMD counter before folio_put() Date: Tue, 26 May 2026 20:56:08 +0800 Message-Id: <20260526125608.60396-1-lance.yang@linux.dev> In-Reply-To: <20260526101337.1984081-1-yintirui@huawei.com> References: <20260526101337.1984081-1-yintirui@huawei.com> 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=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On Tue, May 26, 2026 at 06:13:37PM +0800, Yin Tirui wrote: >__split_huge_pmd_locked() updates the file/shmem RSS counter after >dropping the PMD mapping's folio reference. If folio_put() drops the >last reference, mm_counter_file() can later read freed folio state via >folio_test_swapbacked(). > >Move the counter update before folio_put(). > >Fixes: fadae2953072 ("thp: use mm_file_counter to determine update which rss counter") >Cc: >Signed-off-by: Yin Tirui >--- Thanks! Feel free to add: Reviewed-by: Lance Yang