Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3057721pxf; Sun, 21 Mar 2021 17:22:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyedg8sGXiiAf9m6+tbFD3kfrMCoYVsIcgNzfk3JjwuNSnm3YPl00iCYHz/e6vDqJONNVfw X-Received: by 2002:a05:6402:51d0:: with SMTP id r16mr22696760edd.48.1616372541620; Sun, 21 Mar 2021 17:22:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616372541; cv=none; d=google.com; s=arc-20160816; b=ULPjGaEYJXIk3D1YJqiHbrkcNl9J49LDx0ldYCPZy3BFe3u0qO3Oz5z8LQc1spvYXP BuNxn5DzxR+lccNPXfMzlq/rn9OIO/6923YU0W8Txni4YY2rfMahfWPaVmPMTlFSNU+R 3OPATvlke4lSok87z6rLrrbPGjfjwSOQUh4uHwOtpP+LuOZ8P+wnLyPd6qOHBqqezZun POL1Wp2lNXhhuU1EDMIqxhAY6y4Oxyhju7BRjssb/7Fo3h7FzBICDuhtWJkTjExHcitR 8dTFs+zBout+xakTrVIJve2UZMp7YSMxIxfQ9+sXiuqbMft4jhZvfuxVWQ5OTW318Oun viIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=VRe+tfLRhXnhZrWTVy4eOcYB2KHiPxHjwvRLWiAdrpg=; b=TAT++7HWMrkMqDBrPliDh3RYwR0z3emLvV8XLgt+KMy3Zx3dQgO22gAYdTfGgZPDXp WwlO7HjAxI6Rszgd6db0X2Huqyjjw0b64tyX8upVplOurZFfRtxizx+32+mmhMzKDU55 l2MZcZlB4fKH28bfSKN367jSmzjbhHqevg1LAY/yT5BLv0Y+vKhW1puTDv6Lbsf7z3JA FMMATJgdWJ7HPQSAUyzfQ2GAXExQ/1a+0StD2LJZvoguiTcP8hgl8dU4fTW/vnNSOQRM BiqsczZ051bnFLYKxKX2YxG2oHSHfzDwIeL/SINW0xJUs7dd0I3goji/zD+PYjHreVFI XFNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentoo.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si10080705edn.67.2021.03.21.17.21.53; Sun, 21 Mar 2021 17:22:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentoo.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231340AbhCUVZd (ORCPT + 99 others); Sun, 21 Mar 2021 17:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230167AbhCUVZS (ORCPT ); Sun, 21 Mar 2021 17:25:18 -0400 Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10265C061574 for ; Sun, 21 Mar 2021 14:25:18 -0700 (PDT) Received: by sf.home (Postfix, from userid 1000) id 43C355A22061; Sun, 21 Mar 2021 21:25:07 +0000 (GMT) From: Sergei Trofimovich To: Andrew Morton , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Sergei Trofimovich Subject: [PATCH] mm: add page_owner_stack=off to make stack collection optional Date: Sun, 21 Mar 2021 21:25:01 +0000 Message-Id: <20210321212501.2504947-1-slyfox@gentoo.org> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On some architectures (like ia64) stack walking is slow and currently requires memory allocation. This causes stack collection for page_owner=on to fall into recursion. This patch implements a page_owner_stack=off to allow page stats collection. Signed-off-by: Sergei Trofimovich --- .../admin-guide/kernel-parameters.txt | 6 +++++ mm/Kconfig.debug | 3 ++- mm/page_owner.c | 23 +++++++++++++------ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 04545725f187..3e710c4ab4df 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3518,6 +3518,12 @@ we can turn it on. on: enable the feature + page_owner_stack= [KNL] Boot-time parameter option disabling stack + collection of page allocation. Has effect only if + "page_owner=on" is set. Useful for cases when stack + collection is too slow or not feasible. + off: disable the feature + page_poison= [KNL] Boot-time parameter changing the state of poisoning on the buddy allocator, available with CONFIG_PAGE_POISONING=y. diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug index 1e73717802f8..c1ecaf066c93 100644 --- a/mm/Kconfig.debug +++ b/mm/Kconfig.debug @@ -57,7 +57,8 @@ config PAGE_OWNER help to find bare alloc_page(s) leaks. Even if you include this feature on your build, it is disabled in default. You should pass "page_owner=on" to boot parameter in order to enable it. Eats - a fair amount of memory if enabled. See tools/vm/page_owner_sort.c + a fair amount of memory if enabled. Call chain tracking can be + disabled with "page_owner_stack=off". See tools/vm/page_owner_sort.c for user-space helper. If unsure, say N. diff --git a/mm/page_owner.c b/mm/page_owner.c index d15c7c4994f5..2cc1113fa28d 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -31,6 +31,7 @@ struct page_owner { }; static bool page_owner_enabled = false; +static bool page_owner_stack_enabled = true; DEFINE_STATIC_KEY_FALSE(page_owner_inited); static depot_stack_handle_t dummy_handle; @@ -41,21 +42,26 @@ static void init_early_allocated_pages(void); static int __init early_page_owner_param(char *buf) { - if (!buf) - return -EINVAL; - - if (strcmp(buf, "on") == 0) - page_owner_enabled = true; - - return 0; + return kstrtobool(buf, &page_owner_enabled); } early_param("page_owner", early_page_owner_param); +static int __init early_page_owner_stack_param(char *buf) +{ + return kstrtobool(buf, &page_owner_stack_enabled); +} +early_param("page_owner_stack", early_page_owner_stack_param); + static bool need_page_owner(void) { return page_owner_enabled; } +static bool need_page_owner_stack(void) +{ + return page_owner_stack_enabled; +} + static __always_inline depot_stack_handle_t create_dummy_stack(void) { unsigned long entries[4]; @@ -122,6 +128,9 @@ static noinline depot_stack_handle_t save_stack(gfp_t flags) depot_stack_handle_t handle; unsigned int nr_entries; + if (!need_page_owner_stack()) + return failure_handle; + nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 2); /* -- 2.31.0