From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 9317B28AAE3 for ; Mon, 30 Jun 2025 13:00:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288432; cv=none; b=ftXK3P+09iaJPuHjCVL2On1uY6vkYv6fzKdMLOuibunbgE04mSuI9HkdtRLwgf/2TZNazrGsyikbiu8YykoEIJ2Xj58hxc+K0WR+e9Mj9bsHbIB4D1DDCdM6z1Jx61xWiSINx/RxjNKaaRAN3AhLWG+rK1jXMrjQ4gfS3vRDFYY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288432; c=relaxed/simple; bh=S3zLBPDhBdMrO+ksqFydENk2LB8FvPckKtc18Wgtb7I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JbpqEfakrPh7byDQuRVpzr15SxDJkEaeqYpgbcQM/7leMe+xo51Ju2p0PSKRY7uDM9ZUr+0lrsRnDPISDPQCMiCHdvS6bpedeMH9NuekxpHWYfwXspmc40vWs1NUZRwPt0FzzxPSXYmInAE5OmKt1jyoDlAGIcc6rtmnpfdcQ0o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=d8uz3zHL; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="d8uz3zHL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p0pHDGHZALCRdBpqrQ9hLtuju8zJ3QwGWTV045A4FRg=; b=d8uz3zHLLpgFvrb6RkYLTtB+YcBaO9A+wqCQpkBTiRRsz0xye3u5istyLRAt2F+oOJIocd 0fwGkVGxlDZZ3qFLWViVLjz+BYxo0EVEftv6yGE0MxyTIfvGeJ7RkyVH6JLLs2glaiQhwt qWgNdkjBx6wrnuROIGw3AkXAEzfmxT0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-472-2t-YPpEcMs66dK8E833ZMA-1; Mon, 30 Jun 2025 09:00:27 -0400 X-MC-Unique: 2t-YPpEcMs66dK8E833ZMA-1 X-Mimecast-MFC-AGG-ID: 2t-YPpEcMs66dK8E833ZMA_1751288426 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4536962204aso8328565e9.3 for ; Mon, 30 Jun 2025 06:00:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288426; x=1751893226; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p0pHDGHZALCRdBpqrQ9hLtuju8zJ3QwGWTV045A4FRg=; b=Ei3IU3T1TTtJ2Esz+UU7RUMsroEhBs2qcuC40Qe+yI7pI8NQfJqV0NX22U1Mnhu2s6 GGCJjzFwufOF8b9z0Dc5GeCyXXg9pBgWDEuPa6TpWvRrOnrcv61uoX3zQ+kkYpl7auIc OGD9XGicQyfPrIghHcjeR0gX9dE8gHOc+ULOPmE61/aho0R5No3851AuQ8lEGgkkoL6P v/P/I4z8oJM4WG3q3ZHzgP5pSQER9Me8At0rMleGudsyUYbckcZTo325RJRvxXSe16kn 5NzM4gKh2+5THvS+swg9fkXT2a4GfeEuBHv7ikzDnc7+0eJfV+ThHCM0ZdwPZFRIe7kS nNFw== X-Forwarded-Encrypted: i=1; AJvYcCWD3p8NDKqKN9qCPTxdAg+H21ZD7ExQCtyjQAlxgxzHT3A4+dWscYdugBE5hOg9dv+hn2twbas5oMk=@vger.kernel.org X-Gm-Message-State: AOJu0YyzJFcePBwg4JgZC+7Z/GGOUi6yL/zP0ECVGRyY/IctKsEuCu8A jT/762VAg1IRjZkGIWo5dIwP8MwmHlpCWWIP0KYpOHktDTWJ4LhGBQZMzXsz2PdDNCZ85KnvNeJ bOAm6ie4m8nJtRbOEwZs6nrPfubLlRMGi++m1H7bD9j7YMXnmx1Jmza2NO5GI+Q== X-Gm-Gg: ASbGncug1N87GVdXFXjPnsUbXR6+T3WD4hm3KP0XpQg2lW4BSOPDNrexsqJr6NkktzD 10krxW+aABsOSKXoIImxAyYxp0h7UHroQ+8/unjeC9vSPxmOFtx8hHTRDSCz1lTbE+C0EiRQwI6 7/3XFBAn0YQYkTW8ra2erfNhpQE8FbjJmJzXZ3VQo5UNYEtTv5L07brq9O6RhtHqpHmebg6MjDj N7+W4MnLNyLSYZGEKbviAHWoqlX67qU5Mo6tofig2mbe49Fdu9l7IDTear4y3zAHQcgrOVdeQNa UdVf6HhoBptpX1yUHfvjF/5Jr9kL9EjElmPJGYCoJhZMa4KYMDwsuUzUzD0yienwQ4F8F0I0uTK Un0rcpT8= X-Received: by 2002:a5d:64e1:0:b0:3a6:d579:ec21 with SMTP id ffacd0b85a97d-3a8f577fd35mr10177753f8f.12.1751288426266; Mon, 30 Jun 2025 06:00:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwLhkxvJD2R8UoqRuajbGlVqpEQolWc/VBvsc1ZeiLSR5gPzKHixn/vDhyoe1JVlLg6TEErg== X-Received: by 2002:a5d:64e1:0:b0:3a6:d579:ec21 with SMTP id ffacd0b85a97d-3a8f577fd35mr10177695f8f.12.1751288425713; Mon, 30 Jun 2025 06:00:25 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a88c7e76e1sm10574554f8f.16.2025.06.30.06.00.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:25 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v1 04/29] mm/page_alloc: let page freeing clear any set page type Date: Mon, 30 Jun 2025 14:59:45 +0200 Message-ID: <20250630130011.330477-5-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Currently, any user of page types must clear that type before freeing a page back to the buddy, otherwise we'll run into mapcount related sanity checks (because the page type currently overlays the page mapcount). Let's allow for not clearing the page type by page type users by letting the buddy handle it instead. We'll focus on having a page type set on the first page of a larger allocation only. With this change, we can reliably identify typed folios even though they might be in the process of getting freed, which will come in handy in migration code (at least in the transition phase). In the future we might want to warn on some page types. Instead of having an "allow list", let's rather wait until we know about once that should go on such a "disallow list". Reviewed-by: Zi Yan Acked-by: Harry Yoo Signed-off-by: David Hildenbrand --- mm/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 858bc17653af9..44e56d31cfeb1 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1380,6 +1380,9 @@ __always_inline bool free_pages_prepare(struct page *page, mod_mthp_stat(order, MTHP_STAT_NR_ANON, -1); page->mapping = NULL; } + if (unlikely(page_has_type(page))) + page->page_type = UINT_MAX; + if (is_check_pages_enabled()) { if (free_page_is_bad(page)) bad++; -- 2.49.0