Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1347979imu; Tue, 20 Nov 2018 16:16:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/WxR1soARBwxKzX5bl/7jHDeGkEdSyMg8tE3YalpYJdtKGC6Ma0vUJYUJnPM4jWqeeInIHY X-Received: by 2002:a63:374e:: with SMTP id g14mr3975200pgn.59.1542759401363; Tue, 20 Nov 2018 16:16:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542759401; cv=none; d=google.com; s=arc-20160816; b=Nu+LqPhXTM9W9BKPDgxl4TB7gIFCdfQWaH450NcIMjL3etys9srcba1g1I0HB4zW33 17/H84/f/6UA4xC4ZMCayXRBc9qHRR/vNMzdR/GkcLcR7zNUL+NWLQ8c0ilFsNxRqD5G ij6YLLFHMjZTZedyX1aD12jtIYaDxMxRm0977CI1aEbdyJisdpJcnA4uBWVO+L5ZlBql SHsa+J86jAowcLQ/akc3iPJpcMAgSquu/o+uQm9mhu2SqPAH6Bv5qBlbOEespuKSrcZL bnPG5EwycZMSpUKbg4M4D0QN2Qc9KBnl92e+qI/OOS9Gtqt7S+OPw8H2kostKaMu/teH f9Aw== 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=V2R4ddSv27SQgleWdxhexBhMGs33RuVgUm0KQ5jr/vM=; b=Y7eynh06FvAmnWpxCo8Uh6h6t2Qz6cTQXETT2KMm4mFFschgGAdaCPSxU7eXn1zIX6 UxUhPIh2rgM0CIQ/4jl/MfWHiXrR0oUaTACUroXgth2uBDLU93tFe1ZjEy3xtUdmNVWa ELO+j/ZBYjLT2G2Vl24swbdtKrDBTB1WCfBvVdDt/zF0MVG9dB2FFAv8yAYTfM5VjHtl CQrbR+hS3JwWkstpbhtd8tTYf4b+FPMOlupW2SPAiKRM5v9BewM2EOziuXMXiWLjCXOz 3cXFO63eFaRZiu6pjdib8hZfyrdR4dIOCEVHBPQ+2I8gghCEPXW1GcMbOxLYikLBxnIi 3yCA== 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 u34si42243056pgk.24.2018.11.20.16.16.26; Tue, 20 Nov 2018 16:16:41 -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 S1726144AbeKUKAn (ORCPT + 99 others); Wed, 21 Nov 2018 05:00:43 -0500 Received: from mout.gmx.net ([212.227.17.20]:42345 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbeKUKAm (ORCPT ); Wed, 21 Nov 2018 05:00:42 -0500 Received: from ovpn-124-218.rdu2.redhat.com ([98.118.28.103]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MN604-1gN1SX2CnQ-006ftS; Wed, 21 Nov 2018 00:28:45 +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 v3] debugobjects: scale the static pool size Date: Tue, 20 Nov 2018 18:28:10 -0500 Message-Id: <20181120232810.2503-1-cai@gmx.us> X-Mailer: git-send-email 2.17.2 (Apple Git-113) In-Reply-To: <20181120201432.2163-1-cai@gmx.us> References: <20181120201432.2163-1-cai@gmx.us> X-Provags-ID: V03:K1:roCpr+APyjDR7Dd8JdM1fpJsJKvpzEImZ5ueOdyLHM46BGzH478 4Hc4mzwoT36hg18YL9pgHwDhPS5Es594km2PHRAr1pT7PMV5WYyGKDjPi7846cVfFLPQNzO EhabfaJpWy+30nxlUFkdRgeKSz20wWvX8FQw9vB9bQtYWquMgfY0eMHAqh7yMz5efa73PDV M5OOkqxa9Y8b502mKTR+w== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:fnatsEXU0gs=:qv9L50flhCDzjI27t9RYJJ 4QM2EDPxxCddv8g3RLWv+FRq272zg1KWkoth5k6bA25DbOVlekFXuxCyeiLguaJ2YLqJglU/u kqzs/rSCb0c/SQC/0UxiYYnYcvDrd1DZxAdTbPLV0vB7JXy5UwrWMjEd9rGyiVg6sFs86RvWQ xkzbNscSMXI3dKmbMZprqnanMzrp7fpCUr/er+04suZ5v2qbvjco/WZDqyV1iyS2ep7GKN+90 FSPtKeI6YhH+uMHZl52WjRJYScTQda/4F4DLc+pjq5nvQuuBSdKBgpJCz+2Nz1WTS4ilP/26U WcC36YLeHyfj7JSvg8+ZX+ic852s+To/8i86Tt4Myh67ursAuf13j5qnJzUQysslbmE3CVXon ogzHWoFRZiiBY1rGeh7b4rGbjVlyFX1TwA/T2BK0ZxarIA718KV2F9NOj0W+G7F6OhTRPyRH6 hYtq6HzeM6MbMqbFo7gOVJevjT8P3ds8Masi5mUDPNNE5L80y94ktq0NnBgXMUGOTac76gsJH DxKnMcx8HRdZ0RUO7vYxpt8rhOx3w5KLbNLxElBJPegxMt1A8uscPIrpRMTVkdG2pjL7QDOnd H5fM/5RETwx14kGKHtX427vOD1nHvLFH771UQrha+bn3Q+kbb9jegSgC12oTX5z1imy1lVqD8 ndZlyYgY5iH8pmauTFAeutZZ5zr9k7p23YyiqH5hRwfIhRHwkiXDKQfv0oKCXWm/kOC+TPLsH vzbtatD455yskckKv+mLJKO4N5bA0LFmO0SgiHt491nz3dFm5oX6/2fhNJJhfkouTQyM8wj6h JTbmMExBVvs8HFZRW8kMinoNqWQCN0uhcjjtgSps9T0PE6V3kEMOqH9zkzDzmiqcAIEixNRvs 4PYDFzxcVvVg6iqXoJAN0LANNxF4iglSQ1qdqx6Xg= 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 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 | 82 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 70935ed91125..02456a1e57cb 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -23,9 +23,82 @@ #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 +131,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)