Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2617768rwb; Mon, 3 Oct 2022 03:35:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5KaogdUo6qgm07LD/lA6KW0pA3nzTwQ5Wjq1o3EJXCUWwBgIkj4vuaLq/JPHr+P/RULBIY X-Received: by 2002:a63:84c2:0:b0:450:b994:48a4 with SMTP id k185-20020a6384c2000000b00450b99448a4mr2328256pgd.408.1664793333754; Mon, 03 Oct 2022 03:35:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664793333; cv=none; d=google.com; s=arc-20160816; b=PIS//xa2i+NPVqQDlNrSyvEoWkJlVqfHbQYw00zz89htOJJ5ga2P6rIN4M9fJOPIMv NIHKnoqSnkvItaM6uKxCvwsU42M3wG2as4NWvtTmAPzTwUyOdhiusUEjp9/MWc2rXqeb VtWq/fk9B76vmdxiJsur1BaRyImFSxWuVhQG8qyS8l/AZ9gjexZxjCmuLI/5zKhNI0AY YMVIdEWK4iDCYpiMks3wjyHrfBvzelDaY3ioqioaMz0dS+mJwHks5JzZ10ErhQLQEeJO 30P+HinN9DjWVGS09jwkOBrswOlsPvBMytsEFUvRUVN1chJMVcIGsFu5qlxRTBpm95H9 7j2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=sqHXQiWfZXTSdiOfVyb8flw+WgtrLHXyasFJmUbbWdg=; b=g7oBUfa2sX/u9zB8CiobMbVVQIvIZs0KJIVm2+foU+dfsAlCfEGRe34pQIA6QSwj53 j56/NXAJJ35wylbFCIWN9MiOyNpVfuk52ClbWzFXkXCdFmh62sPUUNZ8WYDhzaYljFcn 5ZdH/20lhNPWoZzpJXwp7TKZx/2P5y0+3rbpQ5rAoItkrwhDS4wc9gN9H7ny9gYA/9ky KwFifTcfgEQUgGcffZmxD0Xt1FwBMfr/hf89J0YUu7LLL0h/arftvJq8rd3THEsxvPEt PNf7RAvqk8GWEWwG55ZdNs0EyDaacrA2QUHHEKDGcAU9tfiWj7Ah479GaBNTWeCC3PVu aoWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=IHrkprNG; 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 o22-20020a635a16000000b0041e08eaa884si9001879pgb.566.2022.10.03.03.35.21; Mon, 03 Oct 2022 03:35:33 -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=IHrkprNG; 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 S229589AbiJCKZm (ORCPT + 99 others); Mon, 3 Oct 2022 06:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229528AbiJCKZj (ORCPT ); Mon, 3 Oct 2022 06:25:39 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D463A1837B for ; Mon, 3 Oct 2022 03:25:29 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id d18so2850530lfb.0 for ; Mon, 03 Oct 2022 03:25:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=sqHXQiWfZXTSdiOfVyb8flw+WgtrLHXyasFJmUbbWdg=; b=IHrkprNGhsdefIFEF+RAkq1RClACOlBsxRtNO5uKxv+2vSZWTFv/XanwprZ4IolXqC oOsqj3PvxuCHutk/YeOk8XGZCBqwVVkWmHfc4uxoKCiziw4HVMsqYNpTQltgMZ8LnzGD 7EyMdSgCeJiswh75FzML6LEBSwyIDZU8cUXxw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=sqHXQiWfZXTSdiOfVyb8flw+WgtrLHXyasFJmUbbWdg=; b=1sPIT/4jKY6+SIy7gGbSD2HxSvM1zfNY0Jf8ZKFBcXKc5XhUGJ+zPLz25rOEpBlOay djV6x67uiDNuDLb0SKW1HaJfVni4mTxQdIEoqOiYG7kM40Ac2LNW3CXsUo+fAGSws2aJ lbYkAXAjf6GVIhLMPr/7ZY34taBQ+GON9jBtQ65VyKrflM9TgiLYFKaOdIcY3xGnmL52 eStzQLyG0ijRZvGR+JEE8HvTD1Y5z0yWKnJtROXB352oCrnRUloNQggUEayKt7EEbjp1 ozunN12Ntg2mPG0LAqjxXAwQrVWZa6JNFWTc8W9MP44oyMW1cGahMfIMPDD/W3b1tHtX aWiw== X-Gm-Message-State: ACrzQf2/w0IXeMie3BH4DRTC/nnLSTdOGdmN1EG9wRek+ue9vKgLNQCa H1koPzQJ0t6edAQsQ/gcVuSgTA== X-Received: by 2002:a19:4315:0:b0:497:7488:7a76 with SMTP id q21-20020a194315000000b0049774887a76mr6641072lfa.286.1664792728163; Mon, 03 Oct 2022 03:25:28 -0700 (PDT) Received: from [172.21.2.224] ([87.54.42.112]) by smtp.gmail.com with ESMTPSA id bf31-20020a2eaa1f000000b0026de3bfbbd6sm116305ljb.43.2022.10.03.03.25.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Oct 2022 03:25:27 -0700 (PDT) Message-ID: Date: Mon, 3 Oct 2022 12:25:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] mm: slub: make slab_sysfs_init() a late_initcall Content-Language: en-US To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220930102712.789755-1-linux@rasmusvillemoes.dk> From: Rasmus Villemoes In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 On 03/10/2022 10.17, Hyeonggon Yoo wrote: > On Fri, Sep 30, 2022 at 12:27:12PM +0200, Rasmus Villemoes wrote: >> 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.] > > This looks okay and just curious, > can you explain what kind of benefit does enabling watchdog early provides? The watchdog is _always_ enabled, from power-on onwards. There's nothing one can do to disable it (short of using a soldering iron to modify the board...), and usually nothing one can do to program its timeout [if it is at all configurable, it's done during board design using appropriate resistor/capacitor values]. All the custom boards I've met, across the very different industries I've worked with, have always had such an external watchdog. Their timing requirements may vary; currently I'm working on a board which has a 1s margin, but I've also encountered something as low as (IIRC) 400ms. While 10-20ms may not sound impressive, this is not the first nor the last patch I'm trying to get upstream (see e7cb072eb988 for another example, done in connection with another project) to gain as much margin as possible - we want to be able to continue to upgrade our kernels for the next 5, 10, 20 years, and undoubtedly the mainline kernel will grow features and overhead in that timespan which won't be offset by better compilers. Rasmus