Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1438250imu; Tue, 20 Nov 2018 18:14:30 -0800 (PST) X-Google-Smtp-Source: AJdET5fRltvkNNi3ic+LX4J6wGoTS4yYKeLGDOwwul2Ziq1SUHK0l7r5E4mnvAjvz9mPjn0N5vtI X-Received: by 2002:a62:4105:: with SMTP id o5-v6mr4699050pfa.85.1542766470372; Tue, 20 Nov 2018 18:14:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542766470; cv=none; d=google.com; s=arc-20160816; b=BzX73aMBCOG07/hu/qkJ2jwU1PPYZcneihI3q27/6BDR1Mo++xsamk8A2xC0wzlxiO d7hWqoANn96/MXAiNNm3o+khwsPIRp/2tbKEymfaiveWJpmELX5RxdDdS73enUjnprfs c96Y5iw/y0/sn0WVzScGKpSYBkodIaKZy73PXF7I7kLJp6Iyfv5pHmb43gzoF2Ar851v wu5ejDuF6W57apeq1k+OY8jRh1Pplxqz+7j+LDKy+2k7pG4XdNV4UUKzXAh4lcvWov2l 12XqjRuNZoS36ONA/se2Bee9hnhelx6dChMUvrvMD3ndcbnrgRbeBZvMWqCT/uqar2Lx QehQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=+iZZ5yH2MjaTBw5hA57G5iNyMvVblgPEF8tAfJbAUd0=; b=0QCEu0VhziAfjAzQLMT2SNSzv9GLZgIbSlWXIuB8QUycN74RvdnZ+QKojOuE/ILR23 M+8/bICFodiAAfNCDRCReyO7alt3GZQGh1mB6dAlkjw0/MW5slgRtvac7CqUuTdZD28K O1eUjuVsXg80ubrnWTJY4leOO9CdfWA5r8CeafXT16B/tpouwLpXL3129g3LWyl6UL8s ElWO/9ijmnXSOUNqtgPb4ONy8GWZe3obzfRfh8AqW+AoEEEW/2L8NiicZ+4gneBSUS6y WgCDE10HWgLdGV7LQquyp+M0DhVzzLmvhWDFbXW3Pkau5cqKUHHManOpFgqZ7kKriMnH nWtA== 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 x23si13494444pln.100.2018.11.20.18.14.15; Tue, 20 Nov 2018 18:14:30 -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 S1726402AbeKUMor (ORCPT + 99 others); Wed, 21 Nov 2018 07:44:47 -0500 Received: from mout.gmx.net ([212.227.15.19]:49863 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725913AbeKUMor (ORCPT ); Wed, 21 Nov 2018 07:44:47 -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 0LmbZb-1fqmGC2rRr-00aEe2; Wed, 21 Nov 2018 03:12:16 +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 v4] debugobjects: scale the static pool size Date: Tue, 20 Nov 2018 21:11:57 -0500 Message-Id: <20181121021157.3061-1-cai@gmx.us> X-Mailer: git-send-email 2.17.2 (Apple Git-113) In-Reply-To: <20181120232810.2503-1-cai@gmx.us> References: <20181120232810.2503-1-cai@gmx.us> X-Provags-ID: V03:K1:LHELuvoYZ2TrgLTOI13I0EQ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wfM0VkXPP1bPHdjP+ LaKfZfRMfPCELOk1ySHmtnMvsBhWI8g437kSLixnEC3+zVDHUexxj1qFFshb1C3AW4S/nS/SG VSss6WlRiyYnefG2bu3AlYCK84kVyDnYE71czC4qE= 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 v3: * style fixes Changes since v2: * Made the calculation easier to read suggested by longman@redhat.com. 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..140571aa483c 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. + * + * With all debug objects config options selected except the workqueue and the + * timers, kernel reports, + * 64-CPU: ODEBUG: 4 of 4 active objects replaced + * 256-CPU: ODEBUG: 4 of 4 active objects replaced + * + * all the options except the workqueue: + * 64-CPU: ODEBUG: 466 of 466 active objects replaced + * 256-CPU: ODEBUG: 1810 of 1810 active objects replaced + * + * all the options except the timers: + * 64-CPU: ODEBUG: 652 of 652 active objects replaced + * 256-CPU: ODEBUG: 2572 of 2572 active objects replaced + * + * all the options: + * 64-CPU: ODEBUG: 1114 of 1114 active objects replaced + * 256-CPU: ODEBUG: 4378 of 4378 active objects replaced + */ +#ifdef CONFIG_DEBUG_OBJECTS_WORK +#define ODEBUG_WORK_PCPU_CNT 10 +#else +#define ODEBUG_WORK_PCPU_CNT 0 +#endif /* CONFIG_DEBUG_OBJECTS_WORK */ + +#ifdef CONFIG_DEBUG_OBJECTS_TIMERS +#define ODEBUG_TIMERS_PCPU_CNT 10 +#else +#define ODEBUG_TIMERS_PCPU_CNT 0 +#endif /* CONFIG_DEBUG_OBJECTS_TIMERS */ + +#define ODEBUG_POOL_SIZE (ODEBUG_DEFAULT_POOL + CONFIG_NR_CPUS * \ + (ODEBUG_TIMERS_PCPU_CNT + ODEBUG_WORK_PCPU_CNT)) + #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)