From nobody Wed Dec 17 06:14:33 2025 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (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 C11562236F2 for ; Fri, 5 Dec 2025 23:17:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764976664; cv=none; b=P3EcIJhmFYg8iO9czgw/uv05Nk8Yd8FKOgmUfnh1QxbO+QhIW5sZX6Cqm6mDNqiQaeWXwsF4sCRe6/n6gIdfn3ubGI7hWLt+ahNBn6lUdwwoOPDfm+sOgsLsXxRZdR4nAxgjpAKjWX8/fVRiYr1M2rE40/+X679FdfzWOfUPsSQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764976664; c=relaxed/simple; bh=ifSb8nlq9nVAyzV/KdKH4t+CZwG7Fr66ThermYs8kOM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b8LnJVtaIcMa5pvnuhnoGFuDpDFbAjZePfwp+FqHBoBZ3UgvTHvZmklgMKzFv73D7CFOmjgJWDf+N4tSurHz8Z5LerTsuM8Z2CyD2X/ceqQ57e1EuQ6oVLsNkU/3wF4BksnzcWN+Bxtcl4CdOoOjCjWkFw8aKpVQ3s3HpQzLFBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=UDTOFCyk; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="UDTOFCyk" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ejrce1XdxpWJWHE5Wtt1V02tXeXE+vjGDq8qzCrERNM=; b=UDTOFCykey2R4x2elUbcoVM3Rz MyYhKVZ/cUjO++zOwSPvfeiWj/kUke3gfaRIGzNP74ZI5YSuPqgPFX8IR2i7vOfslE+++i0/Fx5At YIJQvjSD6hSqmVX0lEZkxp4m8WUvW2AfRGRsRhD9urL9prArVeXKT46tqDebyx4ASMFX7A5Iw20rg Kau5ByoyZB++7okKue5brOeEzqXy9gEuv8RctToi9OqpawawA06uUpt+gGM4vns/f01WuRBwmvWdw TwjmqIm4uHHxjoUOb3rCwxCL1beCuLt5cH/DjulA2LeFDz0SmEzCpxIVp5kaRx03fe57afvIyOfbl YHAGRsMA==; Received: from 186-249-144-101.shared.desktop.com.br ([186.249.144.101] helo=t470) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vRf3P-009H1j-0J; Sat, 06 Dec 2025 00:17:35 +0100 From: Mauricio Faria de Oliveira To: Andrew Morton , David Hildenbrand Cc: Lorenzo Stoakes , Michal Hocko , Vlastimil Babka , Oscar Salvador , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-dev@igalia.com Subject: [PATCH RFC 2/9] mm/page_owner: add parameter option 'page_owner=on,swap' Date: Fri, 5 Dec 2025 20:17:14 -0300 Message-ID: <20251205231721.104505-3-mfo@igalia.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205231721.104505-1-mfo@igalia.com> References: <20251205231721.104505-1-mfo@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" CONFIG_SWAP_PAGE_OWNER will introduce a behavior change in page_owner on systems with swap space. Thus, add the 'swap' option to the 'page_owner' parameter to enable it ('page_owner=3Don,swap'). Currently, the allocation stack trace of a page is lost at swap-out (the page is freed) and reset at swap-in (a new page is allocated). With the new feature, if this option is enabled, the (initial) allocation stack trace of a page is maintained over swap-out and swap-in, and the refcounts for the initial and swap-in allocation stack traces are adjusted. (Note: 'swap_page_owner_enabled' is parsed before 'page_owner_enabled', so 'page_owner=3Doff,swap' could set the former but not the latter, but this is a nop as then init_page_owner() returns early and doesn't enable anything.) Signed-off-by: Mauricio Faria de Oliveira --- mm/page_owner.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/mm/page_owner.c b/mm/page_owner.c index a70245684206..a27958872b07 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -57,6 +57,11 @@ struct stack_print_ctx { static bool page_owner_enabled __initdata; DEFINE_STATIC_KEY_FALSE(page_owner_inited); =20 +#ifdef CONFIG_SWAP_PAGE_OWNER +static bool swap_page_owner_enabled __initdata; +DEFINE_STATIC_KEY_FALSE(swap_page_owner_inited); +#endif + static depot_stack_handle_t dummy_handle; static depot_stack_handle_t failure_handle; static depot_stack_handle_t early_handle; @@ -81,7 +86,18 @@ static inline void unset_current_in_page_owner(void) =20 static int __init early_page_owner_param(char *buf) { - int ret =3D kstrtobool(buf, &page_owner_enabled); + int ret; + +#ifdef CONFIG_SWAP_PAGE_OWNER + char *swap =3D strchr(buf, ','); + + if (swap) { + *swap++ =3D '\0'; + if (!strcmp(swap, "swap")) + swap_page_owner_enabled =3D true; + } +#endif + ret =3D kstrtobool(buf, &page_owner_enabled); =20 if (page_owner_enabled) stack_depot_request_early_init(); @@ -138,6 +154,10 @@ static __init void init_page_owner(void) dummy_stack.next =3D &failure_stack; stack_list =3D &dummy_stack; static_branch_enable(&page_owner_inited); +#ifdef CONFIG_SWAP_PAGE_OWNER + if (swap_page_owner_enabled) + static_branch_enable(&swap_page_owner_inited); +#endif } =20 struct page_ext_operations page_owner_ops =3D { --=20 2.51.0