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 501142882A7 for ; Fri, 27 Mar 2026 01:11:46 +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=1774573906; cv=none; b=o5HDUhCXl6wU/2o2046pVdldHmWWXc6zjRp+10n3qxkN8oJGWR+g25YBquqdtED1SWuTk7MsbHqvoZCkhRsr6OmFHghPzzJSh1E43wZo3bYy+lZc5zeBF1Rc8Z7TnSw8F2hnOKM4T5yg4CpqeFFQdQHOaUnYjy2GtSFornq8svk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774573906; c=relaxed/simple; bh=Fe7KwUg/tq18as0rpB2EpsguFqezOlv+XwT4XQCuSCk=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=NJXYjM471ZyvW5tZSlcbynEiZuYU3p3ZiqNtpvbxWNps80ilmeZrpsjcr3i5hKM0RoxIrV5xKDxrv5RG/5QDjulEl5g3FhKEbGlzaXtDfScSTEk3OX+zRXxtAEn2gbwO0wg4NgZervnfMy3g1Yqvk/H1/+U3mP8/M7rPqK9ncAo= 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=sSeaQGEJ; 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="sSeaQGEJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD4C7C116C6; Fri, 27 Mar 2026 01:11:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1774573906; bh=Fe7KwUg/tq18as0rpB2EpsguFqezOlv+XwT4XQCuSCk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=sSeaQGEJwkqd9JitOdQFLzky3an4qh0q0FMVSfd3D8kfehFwD5nIBDGu9/OFbqx/O z7vPAdBc9SLY07B+kRL0FlRJ4DpTkUAewfokbv0WDffXY/pwcfgjm3iL0zQTmvHm7G NCkD1v1tzZEdk7zXbZ3yFbfqNQff//o/960xXSxY= Date: Thu, 26 Mar 2026 18:11:45 -0700 From: Andrew Morton To: Hao Ge Cc: Suren Baghdasaryan , Kent Overstreet , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/alloc_tag: clear codetag for pages allocated before page_ext initialization Message-Id: <20260326181145.35b559956a45b0efdc9c0450@linux-foundation.org> In-Reply-To: <20260326140554.191996-1-hao.ge@linux.dev> References: <20260326140554.191996-1-hao.ge@linux.dev> X-Mailer: Sylpheed 3.7.0 (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, 26 Mar 2026 22:05:54 +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. The array size is fixed at 8192 entries, and will emit > a warning if this limit is exceeded. When page_ext initialization > completes, set their codetag to empty to avoid warnings when they > are freed later. > Thanks. I'll queue this for review and test. But where will I queue it? > > Fixes: 93d5440ece3c ("alloc_tag: uninline code gated by mem_alloc_profiling_key in page allocator") A year ago, so a cc:stable might be needed. > +#ifdef CONFIG_MEM_ALLOC_PROFILING_DEBUG otoh, it appears that the bug only hits with CONFIG_MEM_ALLOC_PROFILING_DEBUG=y? If so, I'll add that (important) info to the changelog. Do people use CONFIG_MEM_ALLOC_PROFILING_DEBUG much? Is a backport really needed? Either way, it seems that this isn't a very urgent issue so I'm inclined to add it to the 7.1-rc1 pile, perhaps with a cc:stable. Please all share your thoughts with me, thanks.