From patchwork Thu May 12 02:53:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wonhyuk Yang X-Patchwork-Id: 12846879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8946AC433EF for ; Thu, 12 May 2022 02:53:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9A768D0001; Wed, 11 May 2022 22:53:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DFCFA6B0075; Wed, 11 May 2022 22:53:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C728D8D0001; Wed, 11 May 2022 22:53:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B05EC6B0074 for ; Wed, 11 May 2022 22:53:15 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 7F9D2616AB for ; Thu, 12 May 2022 02:53:15 +0000 (UTC) X-FDA: 79455569550.14.882F04B Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by imf31.hostedemail.com (Postfix) with ESMTP id B14FE20007 for ; Thu, 12 May 2022 02:52:52 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id t11-20020a17090ad50b00b001d95bf21996so6588435pju.2 for ; Wed, 11 May 2022 19:53:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jrgF71qNNcYD8nMa0N2Q78v1uFUFa9LGIhiMObVxexI=; b=MC7TNUG4QWAakfYQhS5QSM5SxEsCYVGXnkyUwHwXKvplZ7MABo+4i4g7EAumDk/IRK B/VKo4UUmnm0M/qTCiamuZh7YCX948h8rzLdv8+lnO5rORzPD8JKJcYht2q/0fuD48JN zB56ucdFuOstRW34Cfa/XsT0/gKAIYX7rToPeRXjPJtxovndrRjgak2/ROloBqi92rQw eOaweOM8ilNP4E4+F5hkh69jRUVjneiqzlljaBPBsp7bRbeVxwYrqX4qSzBOHfn+x1YH LYfBvIQImecH4tqm76Sge0c3Y7EoSdKlVNerS6yPCL7WzLz7trGFCZasWe/Qq9b/oV28 P+SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jrgF71qNNcYD8nMa0N2Q78v1uFUFa9LGIhiMObVxexI=; b=njjWnigv0EKNVbyaU1zUqJFcyWQc2tagf4KCoFfiwm4dAThJMNrbKMbFPI8J2iexHf 8UoNZqTG4azcGtpYrGpLNhCdQyU0JjRjYxijRhBa3WgsPPzI9LWgTSorQUVwRippJmDP f6YRFaEDrEgDmkjngHJJYn3uwy/I74YiyPn/AkeU6bay20SL/1YWtmgDydMrkQNoDvqu jTngOUDFODXMM/vnY66Tn9le3CgRhDVbPfu0cL7aCCOMbq5Wl0b3B0EytJkLHlMyMk39 LPtzIAa9yAe6wc7FOyNvFIc5UPTxzw0lBZh7mx9g2cFw9iRXObXQdkQo3m/LMoB+qyr2 N2Vg== X-Gm-Message-State: AOAM532mDoJUgQtEJCZ64HeYSdMCFMnDxOiEKVAOhLLYzFrmrRO0pwIa dY9625c2nNJnRyIZhaB8vt0= X-Google-Smtp-Source: ABdhPJxiQGyU27UIahq15uZJlZcn2NmrIUajfvr44Ukcf4v/Ucl9xoUNLKWjatK0SYMOaj15aAgLrA== X-Received: by 2002:a17:90b:606:b0:1d9:5dd5:1489 with SMTP id gb6-20020a17090b060600b001d95dd51489mr8518187pjb.171.1652323993950; Wed, 11 May 2022 19:53:13 -0700 (PDT) Received: from localhost.localdomain ([125.131.156.123]) by smtp.gmail.com with ESMTPSA id a13-20020a1709027e4d00b0015e8d4eb21fsm2603639pln.105.2022.05.11.19.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 19:53:13 -0700 (PDT) From: Wonhyuk Yang To: Mel Gorman , Steven Rostedt , Ingo Molnar , Andrew Morton Cc: Wonhyuk Yang , Baik Song An , Hong Yeon Kim , Taeung Song , linuxgeek@linuxgeek.io, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [Patch v2] [PATCH] mm/page_alloc: Fix tracepoint mm_page_alloc_zone_locked() Date: Thu, 12 May 2022 11:53:07 +0900 Message-Id: <20220512025307.57924-1-vvghjk1234@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MC7TNUG4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf31.hostedemail.com: domain of vvghjk1234@gmail.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=vvghjk1234@gmail.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B14FE20007 X-Rspam-User: X-Stat-Signature: iaf1bnwseswyz7888p4odpykufzhj8ed X-HE-Tag: 1652323972-65191 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Currently, trace point mm_page_alloc_zone_locked() doesn't show correct information. First, when alloc_flag has ALLOC_HARDER/ALLOC_CMA, page can be allocated from MIGRATE_HIGHATOMIC/MIGRATE_CMA. Nevertheless, tracepoint use requested migration type not MIGRATE_HIGHATOMIC and MIGRATE_CMA. Second, after Commit 44042b4498728 ("mm/page_alloc: allow high-order pages to be stored on the per-cpu lists") percpu-list can store high order pages. But trace point determine whether it is a refiil of percpu-list by comparing requested order and 0. To handle these problems, make mm_page_alloc_zone_locked() only be called by __rmqueue_smallest with correct migration type. With a new argument called percpu_refill, it can show roughly whether it is a refill of percpu-list. Cc: Baik Song An Cc: Hong Yeon Kim Cc: Taeung Song Cc: linuxgeek@linuxgeek.io Signed-off-by: Wonhyuk Yang Acked-by: Mel Gorman --- v1 -> v2: Simplify determining percpu-refill suggested by Mel Gorman include/trace/events/kmem.h | 14 +++++++++----- mm/page_alloc.c | 13 +++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h index ddc8c944f417..f89fb3afcd46 100644 --- a/include/trace/events/kmem.h +++ b/include/trace/events/kmem.h @@ -229,20 +229,23 @@ TRACE_EVENT(mm_page_alloc, DECLARE_EVENT_CLASS(mm_page, - TP_PROTO(struct page *page, unsigned int order, int migratetype), + TP_PROTO(struct page *page, unsigned int order, int migratetype, + int percpu_refill), - TP_ARGS(page, order, migratetype), + TP_ARGS(page, order, migratetype, percpu_refill), TP_STRUCT__entry( __field( unsigned long, pfn ) __field( unsigned int, order ) __field( int, migratetype ) + __field( int, percpu_refill ) ), TP_fast_assign( __entry->pfn = page ? page_to_pfn(page) : -1UL; __entry->order = order; __entry->migratetype = migratetype; + __entry->percpu_refill = percpu_refill; ), TP_printk("page=%p pfn=0x%lx order=%u migratetype=%d percpu_refill=%d", @@ -250,14 +253,15 @@ DECLARE_EVENT_CLASS(mm_page, __entry->pfn != -1UL ? __entry->pfn : 0, __entry->order, __entry->migratetype, - __entry->order == 0) + __entry->percpu_refill) ); DEFINE_EVENT(mm_page, mm_page_alloc_zone_locked, - TP_PROTO(struct page *page, unsigned int order, int migratetype), + TP_PROTO(struct page *page, unsigned int order, int migratetype, + int percpu_refill), - TP_ARGS(page, order, migratetype) + TP_ARGS(page, order, migratetype, percpu_refill) ); TRACE_EVENT(mm_page_pcpu_drain, diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0e42038382c1..e906ac274586 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2476,6 +2476,9 @@ struct page *__rmqueue_smallest(struct zone *zone, unsigned int order, del_page_from_free_list(page, zone, current_order); expand(zone, page, order, current_order, migratetype); set_pcppage_migratetype(page, migratetype); + trace_mm_page_alloc_zone_locked(page, order, migratetype, + pcp_allowed_order(order) && + migratetype < MIGRATE_PCPTYPES); return page; } @@ -2999,7 +3002,7 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype, zone_page_state(zone, NR_FREE_PAGES) / 2) { page = __rmqueue_cma_fallback(zone, order); if (page) - goto out; + return page; } } retry: @@ -3012,9 +3015,6 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype, alloc_flags)) goto retry; } -out: - if (page) - trace_mm_page_alloc_zone_locked(page, order, migratetype); return page; } @@ -3733,11 +3733,8 @@ struct page *rmqueue(struct zone *preferred_zone, * reserved for high-order atomic allocation, so order-0 * request should skip it. */ - if (order > 0 && alloc_flags & ALLOC_HARDER) { + if (order > 0 && alloc_flags & ALLOC_HARDER) page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC); - if (page) - trace_mm_page_alloc_zone_locked(page, order, migratetype); - } if (!page) { page = __rmqueue(zone, order, migratetype, alloc_flags); if (!page)