From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B7BCC7EE29 for ; Thu, 25 May 2023 22:03:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1902F900003; Thu, 25 May 2023 18:03:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 14027900002; Thu, 25 May 2023 18:03:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0076D900003; Thu, 25 May 2023 18:03:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E5AAA900002 for ; Thu, 25 May 2023 18:03:12 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B61771A07A7 for ; Thu, 25 May 2023 22:03:12 +0000 (UTC) X-FDA: 80830153824.10.73901D7 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf30.hostedemail.com (Postfix) with ESMTP id 25C0980026 for ; Thu, 25 May 2023 22:03:08 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=OCLj4wLl; spf=none (imf30.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685052190; a=rsa-sha256; cv=none; b=zdM9ICnjGLk1SvTG6MTxb/kK93zi6Q/fasuxNUsvxrIIfwh3CIc4USHTVNsySXcojfrsMY j6R6o8UIohvXlHQiXIPJc2x1QAa/Y+RetXWpDCm5so9I845EW5vWiKVKiD4/TkveA8vJVp Y8T/9GWr4z2mWHa69kb4HT2D+KksmSE= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=OCLj4wLl; spf=none (imf30.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685052190; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Dj12sdoI3n4fpjZdW0Mzq4hB0XZbrqL+DPd7Ji5TGNg=; b=1A3hbQp5JG1hAXPFLH3Sgi7RS5CXJlt3mwWvRLP1Kq0a8VpxNul/es2iS/M5kntYDxDX09 MtA/6MO+BI3UcjJUk1gN/+qN0Oiq+DJ2bUGklTmAK087FFOOl2yZV/MjX9wH5A9PcdX8BC 2yZ1Rvj+/LlWWN+WR4S20ZfEQ7Noo4w= 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-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description; bh=Dj12sdoI3n4fpjZdW0Mzq4hB0XZbrqL+DPd7Ji5TGNg=; b=OCLj4wLliabHMtFkwS9TdrlBTx +sUQHLscg7D3U1XckQR1AU8vIZlREBIbja6Flm4wCq352iuput5TrOvIRI7Am1m5KRbQTAH3nwl8H WV4YsWtwhQCEm0g2Dxz7qwfimujPNEESegH7q3eG7jiG72nxyegVOAZ56wYoV9fCZ6hY4lpVZ75O4 l+gIpkKAusosIkiByfIzuBG6VUnilFxNyHUgpmn3TYH+4puMfaHaFuAKS/xK9R2nAE9ywUcqJn58e SDQtg4WdbbSdKs8coQaiRFvXzhTMiA4xctL2MRr5islutX65JKi673zyZeqTVc0ugTorkYue+n/KC vE2uTTKQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q2J2Y-000GXY-2w; Thu, 25 May 2023 22:02:34 +0000 Date: Thu, 25 May 2023 15:02:34 -0700 From: Luis Chamberlain To: Linus Torvalds Cc: Lucas De Marchi , Petr Pavlu , gregkh@linuxfoundation.org, rafael@kernel.org, song@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, david@redhat.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: <20230524213620.3509138-1-mcgrof@kernel.org> <20230524213620.3509138-3-mcgrof@kernel.org> <8fc5b26b-d2f6-0c8f-34a1-af085dbef155@suse.com> <6gwjomw6sxxmlglxfoilelswv4hgygqelomevb4k4wrlrk3gtm@wrakbmwztgeu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 25C0980026 X-Stat-Signature: 4tnx38mniz8inh33x6dtcer9hex78xpu X-Rspam-User: X-HE-Tag: 1685052188-863918 X-HE-Meta: U2FsdGV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jgLR7rRXl7vF4TE2CHYOqZGrrPLPCdcB2pIErN+JemWcWca5gvZM8hVphdTAGnlV6SkCZr+clCQwa8NcZ95MdgryXm0QiCdN5ZEOxI+JPsek0boHBgmftSlBw+1Ww93Zh8Krw5eQ5Z9ERdoZ7qBVUOr70Ca+/R/KgRL+hsawu+EC15imsVuPVyT46JZoI4mWgRcgYubF2y1hdjwj9x1QjKnJoH90jb7WWMlDOTvWPXBV6dly8+dWhwa+f9AAdNoPNXoQhVII/bAW80YU+KY1rqSslmmMAP1HhZCSosDXqXw40UDKJGbP+qKGvSQWn8TRsdkoKX+lKZ0dx1JYR/xuV9xFu3BSYDqnY92Z0eKlHs8/g= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, May 25, 2023 at 02:12:49PM -0700, Linus Torvalds wrote: > On Thu, May 25, 2023 at 11:45 AM Lucas De Marchi > wrote: > > > > Are you willig to merge (a possibly improved version of) your patch > > or the userspace change is still something that would be desired? > > I think a user space change should still be something that people > should look at, particularly as the kernel side patch I'm willing to > accept doesn't catch the "completely serial" cases, only the "trying > to load at the same time that the same module is literally busy being > loaded". > > But I've cleaned up my patch a bit, and while the cleaned-up version > is rather larger as a patch (mainly because of just also re-organizing > the finit_module() code to do all the 'struct file' prep), I'm > actually pretty happy with this attached patch conceptually. > > In this form, it actually "makes sense" to me, rather than being just > clearly a workaround. Also, unlike the previous patch, this doesn't > actually make any changes to the basic kernel_read_file() set of > functions, it's all done by the module loading code itself. > > Luis, would you mind testing this version on your load? It still won't > actually handle the purely serial case, so there *will* be those > spurious double module reads from different CPU's just doing the > things serially, but the exclusive file access region has been > extended to not just cover the actual file content reading, but to > cover the whole "turn it into a a real module" part too. > > Also, this does *not* update some of the comments in the module > loading. I changed finit_module to use "kernel_read_file()" instead of > "kernel_read_file_from_fd()", since it actually now has to look up the > file descriptor anyway. But the comments still talk about that > "from_fd" thing. > > Anyway, this is back to "ENTIRELY UNTESTED" territory, in that I've > compiled this, but haven't booted it. The changes look obvious, but > hey, mistakes happen. > > And the commit message is just a place-holder. Obviously. I won't sign > off on this or write more of a commit message until it has had some > real testing. With 255 vcpus: Before: vagrant@kmod ~ $ sudo systemd-analyze Startup finished in 41.653s (kernel) + 44.305s (userspace) = 1min 25.958s graphical.target reached after 44.178s in userspace. root@kmod ~ # grep "Virtual mem wasted bytes" /sys/kernel/debug/modules/stats Virtual mem wasted bytes 1949006968 So ~1.8 GiB. After: root@kmod ~ # systemd-analyze Startup finished in 35.872s (kernel) + 41.715s (userspace) = 1min 17.588s graphical.target reached after 41.594s in userspace. root@kmod ~ # cat /sys/kernel/debug/modules/stats Mods ever loaded 66 Mods failed on kread 0 Mods failed on decompress 0 Mods failed on becoming 1 Mods failed on load 0 Total module size 11268096 Total mod text size 4149248 Failed kread bytes 0 Failed decompress bytes 0 Failed becoming bytes 474688 Failed kmod bytes 0 Virtual mem wasted bytes 474688 Average mod size 170729 Average mod text size 62868 Avg fail becoming bytes 474688 Duplicate failed modules: Module-name How-many-times Reason cryptd 1 Becoming root@kmod ~ # du -b /lib/modules/6.3.0-next-20230505+/kernel/crypto/cryptd.ko 475409 /lib/modules/6.3.0-next-20230505+/kernel/crypto/cryptd.ko So yeah definitely a pretty good improvement. Sometimes the system boots without any duplicates at all, for some reason Vs the previous attempt. Tested-by: Luis Chamberlain Luis