Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1212835imu; Tue, 20 Nov 2018 13:37:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/VqzzJNgjBBturw5GtaEUf8BXP8Cs/ej0fjBjqNV2doJdFHuBbfyS+Upo3D/tQ4Y1Lq7T8J X-Received: by 2002:a63:4a4d:: with SMTP id j13mr3514361pgl.127.1542749868115; Tue, 20 Nov 2018 13:37:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542749868; cv=none; d=google.com; s=arc-20160816; b=08S/Ny1KoSVKlRhns6222thpYk9KyE1XXngl4yMP71QLvuP+aQ/V2KuDpzH8McYLhs FxCMb3d4AQmWgA4MeOccMtGtHSVEmi8CO7nP3UCiAIj9dI8wKYt+DLHwFiw/E+S8uJje DO6MSlY1j671ZNRaiJOwIGA3pCAdg1Y50w+3TTRfMoMY66URZpDhvMwb15yoyKWQ6cj8 Vcv+I3clxY0AS46FXegQD19yRrrVAYFePsV2bs2CYThQNjScPoyebUzfeE4pwlRttN+v w+l/x0C360r7Jutzm53jx3e60gkOWBcvlo7G23z2sCEZ6Je404S5koOFClX5Ok9XQ5iC I7yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=e/FWsE222cszEpgYRALtjU1uJ8qYBn0JvGHUuERpGKg=; b=06ukC2w2bW7/F7nk5tFEJWNU5AwN4lmljJHUx9I2TvQ/NrPQPyckX+tkWqE9A2mjIu MlWIB12u1fcoBl5GMUYzGn5Y6vyViydaCqYaWbPouMX6oELUtnOCI8GZUknA59/O9QEX /5nMynP4Up+PW09Tjyc//bPIUzjjkK0WdMHqBk5RD+mKraoYU95QdNERu4H/gM5i6J8x bA+rPVVpUtVkDg1BRzw8YydLT6jPelsSKBYxU2xBIzH8BW3s7J5UGdKAgIeXRhleMN9H A3HAcAy1Vu3SQJjNo5DVr6fKjgpNrTr+PPXklBGier7rVIjdnlq2NyMVUlD9F4A9eyro YRGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q61-v6si44806751plb.418.2018.11.20.13.37.33; Tue, 20 Nov 2018 13:37:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727659AbeKUGpz (ORCPT + 99 others); Wed, 21 Nov 2018 01:45:55 -0500 Received: from mout.gmx.net ([212.227.15.19]:60301 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbeKUGpz (ORCPT ); Wed, 21 Nov 2018 01:45:55 -0500 Received: from ovpn-124-218.rdu2.redhat.com ([98.118.28.103]) by mail.gmx.com (mrgmx003 [212.227.17.184]) with ESMTPSA (Nemesis) id 0Lh7PL-1fceJW38i7-00oaEV; Tue, 20 Nov 2018 21:14:38 +0100 From: Qian Cai To: akpm@linux-foundation.org, tglx@linutronix.de Cc: longman@redhat.com, yang.shi@linux.alibaba.com, arnd@arndb.de, linux-kernel@vger.kernel.org, Qian Cai Subject: [PATCH v2] debugobjects: scale the static pool size Date: Tue, 20 Nov 2018 15:14:32 -0500 Message-Id: <20181120201432.2163-1-cai@gmx.us> X-Mailer: git-send-email 2.17.2 (Apple Git-113) X-Provags-ID: V03:K1:WkL3VU7Oioe2DgshJPRc93y/cqD0hGNQc5Dj8iB4mL/utOdCGZ5 d0WmHwRpXc+7C34KsTv1AbgOj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l+ekLVUwUxP85fWF5pBu5c gXo4L+kvb7945I5mPJSeqPPdFygrP3ziraKZZ+Lgc= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current value of the early boot static pool size is not big enough for systems with large number of CPUs with timer or/and workqueue objects selected. As the results, systems have 60+ CPUs with both timer and workqueue objects enabled could trigger "ODEBUG: Out of memory. ODEBUG disabled". Hence, fixed it by computing it according to CONFIG_NR_CPUS and CONFIG_DEBUG_OBJECTS_* options. Signed-off-by: Qian Cai --- Changes since v1: * Removed the CONFIG_NR_CPUS check since it is always defined. * Introduced a minimal default pool size to start with. Otherwise, the pool size would be too low for systems only with a small number of CPUs. * Adjusted the scale factors according to data. lib/debugobjects.c | 81 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 70935ed91125..a79f02c29617 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -23,9 +23,81 @@ #define ODEBUG_HASH_BITS 14 #define ODEBUG_HASH_SIZE (1 << ODEBUG_HASH_BITS) -#define ODEBUG_POOL_SIZE 1024 +#define ODEBUG_DEFAULT_POOL 512 #define ODEBUG_POOL_MIN_LEVEL 256 +/* + * Some debug objects are allocated during the early boot. Enabling some + * options like timers or workqueue objects may increase the size required + * significantly with large number of CPUs. For example (as today, 20 Nov. + * 2018), + * + * No. CPUs x 2 (worker pool) objects: + * + * start_kernel + * workqueue_init_early + * init_worker_pool + * init_timer_key + * debug_object_init + * + * No. CPUs objects (CONFIG_HIGH_RES_TIMERS): + * + * sched_init + * hrtick_rq_init + * hrtimer_init + * + * CONFIG_DEBUG_OBJECTS_WORK: + * No. CPUs x 6 (workqueue) objects: + * + * workqueue_init_early + * alloc_workqueue + * __alloc_workqueue_key + * alloc_and_link_pwqs + * init_pwq + * + * Also, plus No. CPUs objects: + * + * perf_event_init + * __init_srcu_struct + * init_srcu_struct_fields + * init_srcu_struct_nodes + * __init_work + * + * Increase the number a bit more in case the implmentatins are changed in + * the future, as it is better to avoid OOM than spending a bit more kernel + * memory that will/can be freed. + */ +#if defined(CONFIG_DEBUG_OBJECTS_TIMERS) && \ +!defined(CONFIG_DEBUG_OBJECTS_WORK) +/* + * With all debug objects config options selected except workqueue, kernel + * reports, + * 64-CPU: ODEBUG: 466 of 466 active objects replaced + * 256-CPU: ODEBUG: 1810 of 1810 active objects replaced + */ +#define ODEBUG_POOL_SIZE (ODEBUG_DEFAULT_POOL + CONFIG_NR_CPUS * 10) + +#elif defined(CONFIG_DEBUG_OBJECTS_WORK) && \ +!defined(CONFIG_DEBUG_OBJECTS_TIMERS) +/* + * all the options except the timers: + * 64-CPU: ODEBUG: 652 of 652 active objects replaced + * 256-CPU: ODEBUG: 2572 of 2572 active objects replaced + */ +#define ODEBUG_POOL_SIZE (ODEBUG_DEFAULT_POOL + CONFIG_NR_CPUS * 10) + +#elif defined(CONFIG_DEBUG_OBJECTS_WORK) && \ +defined(CONFIG_DEBUG_OBJECTS_TIMERS) +/* + * all the options: + * 64-CPU: ODEBUG: 1114 of 1114 active objects replaced + * 256-CPU: ODEBUG: 4378 of 4378 active objects replaced + */ +#define ODEBUG_POOL_SIZE (ODEBUG_DEFAULT_POOL + CONFIG_NR_CPUS * 20) +#else +#define ODEBUG_POOL_SIZE ODEBUG_DEFAULT_POOL +#endif + #define ODEBUG_CHUNK_SHIFT PAGE_SHIFT #define ODEBUG_CHUNK_SIZE (1 << ODEBUG_CHUNK_SHIFT) #define ODEBUG_CHUNK_MASK (~(ODEBUG_CHUNK_SIZE - 1)) @@ -58,8 +130,13 @@ static int debug_objects_fixups __read_mostly; static int debug_objects_warnings __read_mostly; static int debug_objects_enabled __read_mostly = CONFIG_DEBUG_OBJECTS_ENABLE_DEFAULT; +/* + * This is only used after replaced static objects, so no need to scale it + * to use the early boot static pool size and it has already been scaled + * according to actual No. CPUs in the box within debug_objects_mem_init(). + */ static int debug_objects_pool_size __read_mostly - = ODEBUG_POOL_SIZE; + = ODEBUG_DEFAULT_POOL; static int debug_objects_pool_min_level __read_mostly = ODEBUG_POOL_MIN_LEVEL; static struct debug_obj_descr *descr_test __read_mostly; -- 2.17.2 (Apple Git-113)