From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00B0927587D for ; Sun, 26 Apr 2026 22:06:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777241201; cv=none; b=rF74hcXGueY7uOW4Hij0+wL1ktAUSfKtdQ1uvNaTbQ+RAjFTomw2sjtdiVNW7FAs7GjJo9YQIRCjBlUIy3fuht7Qon0ZBtqAEQYV/Jqa9uVy17YbxAfzmmYRAe8cpXcXFdtHnnB1mmJC3IptPIbcGNgZYbCDOXgHA6LmoVZTgOk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777241201; c=relaxed/simple; bh=52tKa67iGb1IORoxe4ZYHwagg5DfBxmhace2N1GfDeo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NUS0pJ/xUB16Z0tkje7c6rtvBLK4l9XJFMLCMB9ug0uLQwO04CIi26gKkyVPx2HoXKgKzkuViozbuVy5JxhwiKLaEC+4XATCKn3uXA7pJe+RZVxc+OHthLkCckHW4bMLdywbbrXVkSQE3MW/pjfCuZHKRL23s1gIE7XBKnZQnxY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FHDlFAq1; arc=none smtp.client-ip=74.125.82.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FHDlFAq1" Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-2c156c4a9efso12971215eec.1 for ; Sun, 26 Apr 2026 15:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777241199; x=1777845999; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=xF/9PrWdSCugZscSXWokV8Z5ndKFNcsdESXX37E9bAw=; b=FHDlFAq1qL5zBdkYI1Ca7gJ5PykHB+2uS8hhoStoq2PIkCFKWqX1FDlYeHpouDNwcj i5zS/RbQPzlnuR8m/+hSTCyNwGtetBcem5b8bjVQ9JXPXGCgCgbtMHEPrvA6Vbx0aZFi F6xSbh+9HihASC/umoIrFG7IxBPk/QN0SCpDnPnW54/I0VGrRXg071/f6K+4nne0M/yK fey3sQ3GSgSiFHukRvQDfpGAU1vMHbnGFW5ivI6Y7IdXWLbG6H1qb9SbwDecm324H7Ro szMJWsSEs8PYMcE+ZpbCCvKR1C1v61yOq9lRiKNYEDVz5wE1SQC8Q9+x7XaxIF1s2Y1P LPmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777241199; x=1777845999; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xF/9PrWdSCugZscSXWokV8Z5ndKFNcsdESXX37E9bAw=; b=SjanjBIMlZixxQD/zkoVhPrzKb6msgi9IZngGKjfjJ42MI3MaI+P+33VoQXgdg+Fv5 RkKIRPjXtXcW3hvPP3SSoKS0UShTv0Rad9Nz7shBeoW5vF35WLiFfQSKmZI+Z0XLG3LJ LeUZhSA2m3GcM4tZXS8LAAf0xszFlklTYqFqCiIL96uUQfdAVc8wUYFBUMGjdUcsIh/J NAIN4UpNbc/LZw8w4JL9z+OdJjfJuVjc5cTNx8Xe2I3sYG+IW7FUOybvvOaox11dxHBg ZC5e4e/dG4Voc7I6kekw2mcb45Q8FLEHlI5MDJromR/YhqxloXdkR6l0lG9ZFthxxB4l VhUA== X-Forwarded-Encrypted: i=1; AFNElJ85wvtl44ATcotoyzbFwzyNhd3bn5qsT9FqOEX2xFUluVKvi5Fq7KrI+enI3iUq1n1C20hIsQqgNRYFs90=@vger.kernel.org X-Gm-Message-State: AOJu0YwUyWvA2+MGj7UF+1a6+eJdHRk1lGqX41IUxh3jXTgfA9zt1Mx4 VexI2x6qx3pdHXa5I0osNLUlRsWJfTSVT6GO6LZBilmZpiZ/L9RF7nN8 X-Gm-Gg: AeBDietWR/rfK/HzbtIPZMXEYlFq5oOME5sxW9N62hWAImBIAW3tnFlAun3HE+jYTe4 ZQS3IAC6EJpGd2mx8qLVlNVpZruBqVgRhLkFHtWfk+LFjGcDLcTtaxsmnS8WhQfvZKw39169Dyp eBe0rNZP8JE4Y3FtwMFxa3Avu69qO/XBREqN+2VCL+6zJUDW+mUGXIagoRRa/HIdx9unowQ5jVt te8o1BOLHaqR4xs2rnzLrfBHnHUv0k46huS42su+z5tuIPxJVAoRYRXol7cbneh6QCKhF8LbAra OhMaNsvzI91RI6sdGsgyXCe/hKRd+MiCtfOZCe+/r+D5LzIbSfOmsM9ltB+fqTbEYVR4+RMraHq /bRiCauuYvVI3A09xmGI2achFIfneU71UvOzgnQFVzbKH9oHjM2nwNTeBJMbpGkJkQSYPW3V8Q9 fY1Hsx10IY+zbMHNK8e7B1gsC+cFG/c10s8ePb57pOttfgpws= X-Received: by 2002:a05:7300:8c9f:b0:2e1:e3e6:2909 with SMTP id 5a478bee46e88-2e465487fa5mr21912607eec.9.1777241198958; Sun, 26 Apr 2026 15:06:38 -0700 (PDT) Received: from fedora ([2601:644:937c:6c90::47b5]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2e53ac84c38sm42170346eec.13.2026.04.26.15.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 15:06:38 -0700 (PDT) Date: Sun, 26 Apr 2026 15:06:35 -0700 From: Vishal Moola To: Bunyod Suvonov Cc: akpm@linux-foundation.org, vbabka@kernel.org, linux-mm@kvack.org, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, surenb@google.com, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com Subject: Re: [PATCH] mm/page_alloc: add tracepoint for PCP refills Message-ID: References: <20260425091335.346504-1-b.suvonov@sjtu.edu.cn> 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-Disposition: inline In-Reply-To: <20260425091335.346504-1-b.suvonov@sjtu.edu.cn> On Sat, Apr 25, 2026 at 05:13:35PM +0800, Bunyod Suvonov wrote: > The page allocator already has mm_page_pcpu_drain to trace pages > drained from the per-cpu page lists back to the buddy allocator. There > is no matching tracepoint for the opposite direction, where > rmqueue_bulk() refills a PCP list from the buddy allocator. This sounds like a reasonable idea. Does this tracepoint show us something that a workload might care about? Not opposed, just curious. For future versions, would you mind including documentation about it in Documentation/trace/events-kmem.rst? > mm_page_alloc_zone_locked is not a good substitute for this. It is > emitted from __rmqueue_smallest(), which is used both by rmqueue_bulk() > and by the direct buddy allocation path. Its percpu_refill field is > derived from the allocation order and migratetype, so it does not > reliably identify whether the allocation came from a PCP refill. > > Add mm_page_pcpu_refill and emit it from rmqueue_bulk() for each page > added to the PCP list. The new tracepoint uses the same page, order and > migratetype fields as mm_page_pcpu_drain, making refill and drain > activity directly comparable. > > Signed-off-by: Bunyod Suvonov > --- > include/trace/events/kmem.h | 23 +++++++++++++++++++++++ > mm/page_alloc.c | 1 + > 2 files changed, 24 insertions(+) > > diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h > index cd7920c81f85..16985604fc51 100644 > --- a/include/trace/events/kmem.h > +++ b/include/trace/events/kmem.h > @@ -243,6 +243,29 @@ DEFINE_EVENT(mm_page, mm_page_alloc_zone_locked, > TP_ARGS(page, order, migratetype, percpu_refill) > ); > > +TRACE_EVENT(mm_page_pcpu_refill, > + > + TP_PROTO(struct page *page, unsigned int order, int migratetype), > + > + TP_ARGS(page, order, migratetype), > + > + TP_STRUCT__entry( > + __field( unsigned long, pfn ) > + __field( unsigned int, order ) > + __field( int, migratetype ) > + ), > + > + TP_fast_assign( > + __entry->pfn = page ? page_to_pfn(page) : -1UL; > + __entry->order = order; > + __entry->migratetype = migratetype; > + ), > + > + TP_printk("page=%p pfn=0x%lx order=%d migratetype=%d", > + pfn_to_page(__entry->pfn), __entry->pfn, > + __entry->order, __entry->migratetype) > +); > + > TRACE_EVENT(mm_page_pcpu_drain, > > TP_PROTO(struct page *page, unsigned int order, int migratetype), > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 65e205111553..a60b73ed39a4 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -2544,6 +2544,7 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order, > * pages are ordered properly. > */ > list_add_tail(&page->pcp_list, list); > + trace_mm_page_pcpu_refill(page, order, migratetype); If you're trying to trace all pages as they come onto the pcp lists, should you also account for the free_frozen_page_commit() path? > } > spin_unlock_irqrestore(&zone->lock, flags); > > -- > 2.53.0 >