From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (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 415672309AA for ; Tue, 26 May 2026 12:54:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779800047; cv=none; b=eg/EhZNuRYTHrd/CB012IJ9aPaFmVk3iSZTguxoYD9ragtPrCFmk6s/cVzA5bE5EirDWbC0RIZUm3NA9EPVFjNu3HJ/8LUdD4TCcdJ5+9KwuuKB6IyZ++v+yjonCOfxca0+UeyditHeLxVnWF+/Zeq27r4Y2SVQ0gJ3vuhj83KQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779800047; c=relaxed/simple; bh=8NFmtjNVk6yqSf59PQPhoTYEdjcxCUFRSGiq2LjpJPU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=c3Jv9qPdVO6hMVyvHr7gM+PKzO98RruCGE0D0cvAJkE/4vYIQW3tEdpAUbbwFCon4/qo/NxpdJRS0WgvkSepmdkQIpPwQRdOD9NPyKhfuxWGFF0uJGdJ87BcwVQnNZumpVbC3iybLBSRFbucoZ/AaSwX/Qohe7YnfXwdhU3gHMo= 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=EKucJNjP; arc=none smtp.client-ip=91.218.175.188 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="EKucJNjP" 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=1779800044; 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=8NFmtjNVk6yqSf59PQPhoTYEdjcxCUFRSGiq2LjpJPU=; b=EKucJNjPDOyhy/Ct1wzGkugYgHG38e4JHfUiB89+kwZuDSasTGZUEoc1YDrz5Tlx3cQgBS nbFBvy3MoCeQXc3AEh1D5EiRZA7JxcqK8wuhQb/KM8RElSncECRexNGouS6+eizOvOXxUG BRDHXzkKV0rGmVw5LE4kz+EpbfTed0o= 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, djbw@kernel.org, apopple@nvidia.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 PUD counter before folio_put() Date: Tue, 26 May 2026 20:53:51 +0800 Message-Id: <20260526125351.58831-1-lance.yang@linux.dev> In-Reply-To: <20260526101355.1984244-1-yintirui@huawei.com> References: <20260526101355.1984244-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:55PM +0800, Yin Tirui wrote: >__split_huge_pud_locked() updates the file/shmem RSS counter after >dropping the PUD 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: dbe54153296d ("mm/huge_memory: add vmf_insert_folio_pud()") >Cc: >Signed-off-by: Yin Tirui >--- Thanks! Feel free to add: Reviewed-by: Lance Yang