Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3474396rwb; Fri, 30 Sep 2022 04:15:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7yMQymbK5Q0YnfFD/jHfgwhosTGfRtahLlrHenDRgqkaHzmSUN8TJWwk6Bt8Nm1AXHVEj2 X-Received: by 2002:a17:90b:1b51:b0:203:25f0:c25e with SMTP id nv17-20020a17090b1b5100b0020325f0c25emr9270009pjb.65.1664536542498; Fri, 30 Sep 2022 04:15:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664536542; cv=none; d=google.com; s=arc-20160816; b=fTuveP36GBsAjgZ2hXZIAnNrnoixOS71vUWtUp5TuUd7tAQjPESgmPPtdU0vcFpxLK xs9YCXJgUlH377V+7JbG0h11ythPCeuMop5hG0lJQUPjeMOIPbg+caRbYPVPXDIURKek MTzRpVRoDsHZxDsgFp6kyGmh7o7gAI9AWUIGZiUYqF5vLSONBw/jExZA2pNiAXIT/s7l jwd4wOX6Ie8zKO3t5YF1dWhmtUVOeVm1gXx7le726UeagUrIotDlVxXbHXyWwbsrB5gY fXBMYw6R1judBRrxb5kFcI/AHCXrLjDwqimw3mgjsw1b2wfHiqGkD5IGpYZR9IhsPpXl ea1g== 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:dkim-signature; bh=opcYLHBFYUInTSSKrfc+T85BEqPL++kCd/mhT+P9K8Q=; b=c7wDL9/WMcWWsnz7gcn9ShXYt31+FuZDRATnN3FnFuv6Vakvx4gPBG9EHlhEvWjEed t55rwB1jJj+6EFD54Er9aPSG9AYcc7Aqp6XLwA2XfW9YY6nwZm2HrJlNLwUZFYW86y8O uNB+m6C6hKXA69VmINxnhXgIe1QBhcmQHAfkHPE1DCLED2ejK745iiSnEbUxAzLr9P1A l+DPknvP1PVW5AMdj93c+IY2RX+tXWB7BOCtgsvv/cRfL1jY9iOX7//j+XLpqhgnsao8 1I8RMGWx1jqnLPi6yh+omKgDkzBAoQjz2uVxwmKnsJFKiSr2yJrFOHU0Sy3iPY4+t6DL JoYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=Zunqaf42; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020a170902e54e00b00176806795b7si3063153plf.351.2022.09.30.04.15.30; Fri, 30 Sep 2022 04:15:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=Zunqaf42; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231646AbiI3LAD (ORCPT + 99 others); Fri, 30 Sep 2022 07:00:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231474AbiI3K7j (ORCPT ); Fri, 30 Sep 2022 06:59:39 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16EE717B523 for ; Fri, 30 Sep 2022 03:37:57 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id m4so6188536wrr.5 for ; Fri, 30 Sep 2022 03:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=opcYLHBFYUInTSSKrfc+T85BEqPL++kCd/mhT+P9K8Q=; b=Zunqaf42yRazlVaCz+p3FTJw+yxM7vvPb2+BMvxh0Q8/k83DtM7V24lwooufy4hpI2 Jg2mhNK0GC/we7ogEZ52w5v8j3jyCQVFh3AZsGmitjMLqEJeYHE4PBceRO1V5czE6tKO FvLLpRIX2Hh0GgEn6obNCVGgmlw+YRKJuqe5I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=opcYLHBFYUInTSSKrfc+T85BEqPL++kCd/mhT+P9K8Q=; b=NL0wVHVZxIcsxbv9FaQMw/e+qBkGVlfpABnD7ppSBez9a9B4yzMm89zDDOFk2NtkrB RERsIMckkMZr0If9g+2l64ULM2M5VGFSlUgfxKj+MjtehQoGfgGghMQ1WyOzVmiHS9BM x8Ciq99CzRYZYk0sbzx5hbZWYjulJyz741QwOWjXKP35nksp3Er1IB3yKtrPn8R1jdcJ HVKMQYe3YGYvKAdHy3Q/KmBUClXjvGzx6u7xOWxrRx8k1EnbQaTOtqp0VQvyFDyBKleV MACxhULU+VuGiLPmZt/2uLavn9YhOcrEREmsCd+xHOctuD2zVf8bX90PWUsPwIcLo7kU AaWQ== X-Gm-Message-State: ACrzQf2RLPm0Ga3TCV/LhyaIGTuzCT8f6EejUOY5qtsVriv5h1lXBOMw 9CsrtOLbNKMSlienmFKsimDZT8uP5grum+r9 X-Received: by 2002:a05:6512:c13:b0:49f:9a2f:8b86 with SMTP id z19-20020a0565120c1300b0049f9a2f8b86mr3002980lfu.413.1664533635506; Fri, 30 Sep 2022 03:27:15 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g12-20020a05651222cc00b00498f23c249dsm254543lfu.74.2022.09.30.03.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 03:27:14 -0700 (PDT) From: Rasmus Villemoes To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Rasmus Villemoes , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: slub: make slab_sysfs_init() a late_initcall Date: Fri, 30 Sep 2022 12:27:12 +0200 Message-Id: <20220930102712.789755-1-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, slab_sysfs_init() is an __initcall aka device_initcall. It is rather time-consuming; on my board it takes around 11ms. That's about 1% of the time budget I have from U-Boot letting go and until linux must assume responsibility of keeping the external watchdog happy. There's no particular reason this would need to run at device_initcall time, so instead make it a late_initcall to allow vital functionality to get started a bit sooner. This actually ends up winning more than just those 11ms, because the slab caches that get created during other device_initcalls (and before my watchdog device gets probed) now don't end up doing the somewhat expensive sysfs_slab_add() themselves. Some example lines (with initcall_debug set) before/after: initcall ext4_init_fs+0x0/0x1ac returned 0 after 1386 usecs initcall journal_init+0x0/0x138 returned 0 after 517 usecs initcall init_fat_fs+0x0/0x68 returned 0 after 294 usecs initcall ext4_init_fs+0x0/0x1ac returned 0 after 240 usecs initcall journal_init+0x0/0x138 returned 0 after 32 usecs initcall init_fat_fs+0x0/0x68 returned 0 after 18 usecs Altogether, this means I now get to petting the watchdog around 17ms sooner. [Of course, the time the other initcalls save is instead spent in slab_sysfs_init(), which goes from 11ms to 16ms, so there's no overall change in boot time.] Signed-off-by: Rasmus Villemoes --- The numbers certainly suggest that someone might want to look into making sysfs/kobject/kset perform better. But that would be way more complicated than this patch, and could not possibly achieve the same win as getting the sysfs_slab_add() overhead completely out of the way. mm/slub.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 4b98dff9be8e..dade5c84a7bb 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -6070,8 +6070,7 @@ static int __init slab_sysfs_init(void) mutex_unlock(&slab_mutex); return 0; } - -__initcall(slab_sysfs_init); +late_initcall(slab_sysfs_init); #endif /* CONFIG_SYSFS */ #if defined(CONFIG_SLUB_DEBUG) && defined(CONFIG_DEBUG_FS) -- 2.37.2