Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5789405rwd; Mon, 5 Jun 2023 08:34:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6AwSeqJL3em3ya6TpOT+dRFedqkU1Zybj5fmZ/ZG4f5f1ajCzbjWKsSZvAw5jB6hzzvNuw X-Received: by 2002:a17:902:ab59:b0:1aa:d235:6dd4 with SMTP id ij25-20020a170902ab5900b001aad2356dd4mr8314953plb.19.1685979271504; Mon, 05 Jun 2023 08:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685979271; cv=none; d=google.com; s=arc-20160816; b=xfwlRwh3Merwsk2hrugd3g3So9HHs5RibKZAR0GoZdm37y14bLtoA77FsRYwpYPkZ/ 8uoJjj1fftkTAhZQOT58aqbyQ/nu04niv2bF04rB7oJRD4LSufHYKaq1Yey779GNIQ5D F8BUtbyCRvT97qqDR3/A04ETGJsNeua1bHLh4dKapzRB8JVnS5VtqDIaLTqBegIcrKAg mspL4N4j/S87P/SSqeGzQS5jjb8MklgRyz0JJr3xZ/y4D12U3xW/JfBqBiDWMBW4NgPP lPG/cz1c9dXLw+PJphh0eLknsO10FtXyipejOCdr20DSPjLN81SYSnkkJiuTjAjtErl0 zL7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Bw8IEae0nViz9T5/tm415WaEBsWa8uqIyLDMVx+BHcE=; b=dAyzQtBYL1z1nct85WR6EsSzf+OaJ4gyefojcOptGQktGL3T3PmTA+GFVxpiP+o8rK ze62uNF0BxFxdaST84xbpxgFH6ScVygm19S88xLjo7Ew0JB1zWuCe7bgw2gg/dqacRwf tcBHQAEKT4Jx9/g97WVG3Sl+CLAUMEvtLYiWzOYMbpGGrd8t+tu6vfH8iqWPF92ObrI7 WyLTLld5gMdGZuJeyQBJbKDuwIcqiHtjKKiYSP6VU8c/Fw0qMvMialTvn0OWlbFCPEMH rF1USsJlsn2rkiq1ipqIPl0lPrKiaGvzyQ8ArppcmYoXVyMPfdIVKH1imo9ozIyyZVoU FVOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=hK7WwFpK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o16-20020a17090a421000b002562c783d8asi5791453pjg.85.2023.06.05.08.34.18; Mon, 05 Jun 2023 08:34:31 -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=@infradead.org header.s=bombadil.20210309 header.b=hK7WwFpK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234284AbjFEPSF (ORCPT + 99 others); Mon, 5 Jun 2023 11:18:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230503AbjFEPR7 (ORCPT ); Mon, 5 Jun 2023 11:17:59 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D2EEE8; Mon, 5 Jun 2023 08:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Bw8IEae0nViz9T5/tm415WaEBsWa8uqIyLDMVx+BHcE=; b=hK7WwFpKh6iUwrWyy3yi1W86AE FegZ7KAO2JuYf8UhX04OiHpjgUdbWMmX4zr1mLJAk3TLam+w/DABXf1fShloTPiia7YN3ytZVrOqQ jEdc+h88JsV/3odb7gARrcIn9L9x/Oyq6+YEe6zNMgL15dZ8YHpKPYpf3aSNyhIOd+uEFRrTPl2TS hLRIBnmH17Gp16ad2fYUgJ1q678ZIufiRJ+1fPPSuIuA6xS7nXTPxSB24Zl2d9aUWHcm63cIxYKLv e4Q1/IX3yaYwvZjNKCt4xR/OeS74DiiveqQqgHXGfhmVvY8rmdgW8WQH3CdQokE9dUmOGQukjFyFe 8L0zSSmA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q6Bxm-00FvjV-1c; Mon, 05 Jun 2023 15:17:42 +0000 Date: Mon, 5 Jun 2023 08:17:42 -0700 From: Luis Chamberlain To: David Hildenbrand , song@kernel.org Cc: Linus Torvalds , Johan Hovold , Lucas De Marchi , Petr Pavlu , gregkh@linuxfoundation.org, rafael@kernel.org, lucas.de.marchi@gmail.com, christophe.leroy@csgroup.eu, peterz@infradead.org, rppt@kernel.org, dave@stgolabs.net, willy@infradead.org, vbabka@suse.cz, mhocko@suse.com, dave.hansen@linux.intel.com, colin.i.king@gmail.com, jim.cromie@gmail.com, catalin.marinas@arm.com, jbaron@akamai.com, rick.p.edgecombe@intel.com, yujie.liu@intel.com, tglx@linutronix.de, hch@lst.de, patches@lists.linux.dev, linux-modules@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pmladek@suse.com, prarit@redhat.com, lennart@poettering.net Subject: Re: [PATCH 2/2] module: add support to avoid duplicates early on load Message-ID: References: <499e30cc-d015-8353-1364-50d17da58f47@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Luis Chamberlain X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Mon, Jun 05, 2023 at 01:26:00PM +0200, David Hildenbrand wrote: > I only did a single run on each kernel, should be good enough for the purpose here. > > > 1) !debug config (not enabling KASAN) > > a) master > > # cat /sys/kernel/debug/modules/stats > Virtual mem wasted bytes 20358550424 18 GiB > Average mod size 217908 212 KiB > Average mod text size 63570 62 KiB > b) patched > > # cat /sys/kernel/debug/modules/stats > Virtual mem wasted bytes 0 > 2) debug config (enabling KASAN) > > a) master > > # cat /sys/kernel/debug/modules/stats > Virtual mem wasted bytes 6453862040 6 GiB > Average mod size 430517 420 KiB, so ballpark kasan pretty much doubles module size. > Average mod text size 197592 192 KiB, and is reflected on module .text too, in fact .text more than doubles. It would have otherwise been difficult to get some of these stats, so thanks! I make note of .text just because of the recent development work going on for a new module_alloc(). About 14 MiB required to house a big iron kasan enabled module .text, whereas about half is required for !kasan. > b) patched > > # cat /sys/kernel/debug/modules/stats > Virtual mem wasted bytes 6441296 We've gone down from ~6 GiB to ~6 MiB. > So, with these (helpful) stats, Extremely useful, yes thanks. > the improvement is obvious (and explains the ~1s > improvement I saw staring at the startup times of the udev services). > > There are still some failed module loads with the debug config (only in the > becoming state), I did not dive deeply into the actual code changes (-EBUSY), That's fine, Linus' patch does not keep the lock for the entire life of the module, it releases it right away after we're done with the kernel_read(), and because of this, there is a small race in between a thread the kernel_read() finishing and the module then being processed into the modules linked list. During that time, if a new module with the same name comes in, we'll have to allow it since the lock was released. Those extra modules end up lingering to wait for the first one that made it to the modules linked list. I don't think we need to worry about 6 MiB, this patch alone should suffice for a long time until userspace gets its act together and fixes this properly. Fixing userspace should reduce some latencies as well on bootup so someone who cares about bootup speeds on high end systems could likely be encouraged to fix that. > just spelling it out so we can decide if this is to be expected or some corner > case that shouldn't be happening. It is expected, in fact the fact that the heuristic works so well, without keeping the lock forever, and therefore keeping the code changes to a minimum is quite an amazing. Luis