From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 21A8818DB37 for ; Fri, 20 Mar 2026 03:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773976475; cv=none; b=n7/vXdGX0yG8OqQusQfc1lzTNiD/OVymbmsiic6GitQ0iosAu2ZcBywtlhoh0fa3px3Ki/ZLM7ITJNr9TDIGUezLBAffxu6pQkhSOUwrgPvWI5g5r1LQNAA9Lcu05ZuJ125UjkoWu3tWF1yCjBHAzs81e4sZt6Kv6gbxYWfkPSI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773976475; c=relaxed/simple; bh=1ldpoIJJPrstSo7P+uHcHJMsXGhDf6QFzETNfcD8JmU=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=g4ZBvx9rZXlElPZ8db4T59zfp06jNOeTujq3l9oGZScDAkF+zvww5+2kuVOxtmUB3z1SB/hHUIN/Yw7XTLWQZKYacaEAQwDukEX3afa4QV4IxVJz+jpxViZiavUPOg3im7/wrfnE3BTq74FLYCl5o1NnMDhedE/xgkybie6ww60= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=o1wA1ZmS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="o1wA1ZmS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96F43C19424; Fri, 20 Mar 2026 03:14:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1773976474; bh=1ldpoIJJPrstSo7P+uHcHJMsXGhDf6QFzETNfcD8JmU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=o1wA1ZmS2n1U/a7/+G5dzNWCWW02PcdZ1i1f1hnH4Yx/UFtzuij7AxCt9D/7vunfK RYMQ5fgggQVSL/sesJzy7eFjfAzbwzfHbTpbwfm8C6fzywK1xCK3d/8K9JKQjB8lZB M/aa0TN73tcSF97ejcTfl9m+9LcYyg7blP1FQzAI= Date: Thu, 19 Mar 2026 20:14:34 -0700 From: Andrew Morton To: Hao Ge Cc: Suren Baghdasaryan , Kent Overstreet , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/alloc_tag: clear codetag for pages allocated before page_ext initialization Message-Id: <20260319201434.b51833a0fea2801a2b220ee5@linux-foundation.org> In-Reply-To: <20260319083153.2488005-1-hao.ge@linux.dev> References: <20260319083153.2488005-1-hao.ge@linux.dev> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 19 Mar 2026 16:31:53 +0800 Hao Ge wrote: > Due to initialization ordering, page_ext is allocated and initialized > relatively late during boot. Some pages have already been allocated > and freed before page_ext becomes available, leaving their codetag > uninitialized. > > A clear example is in init_section_page_ext(): alloc_page_ext() calls > kmemleak_alloc(). If the slab cache has no free objects, it falls back > to the buddy allocator to allocate memory. However, at this point page_ext > is not yet fully initialized, so these newly allocated pages have no > codetag set. These pages may later be reclaimed by KASAN,which causes > the warning to trigger when they are freed because their codetag ref is > still empty. > > Use a global array to track pages allocated before page_ext is fully > initialized, similar to how kmemleak tracks early allocations. > When page_ext initialization completes, set their codetag > to empty to avoid warnings when they are freed later. AI review asks questions: https://sashiko.dev/#/patchset/20260319083153.2488005-1-hao.ge%40linux.dev