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 2E3DFC77B7A for ; Mon, 29 May 2023 17:48:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B51A6B0072; Mon, 29 May 2023 13:48:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 563EE6B0074; Mon, 29 May 2023 13:48:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42C6F900002; Mon, 29 May 2023 13:48:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 33BA66B0072 for ; Mon, 29 May 2023 13:48:10 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E55C21602DF for ; Mon, 29 May 2023 17:48:09 +0000 (UTC) X-FDA: 80844026298.29.6288152 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf12.hostedemail.com (Postfix) with ESMTP id D079440017 for ; Mon, 29 May 2023 17:48:07 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=WCwjN1TX; spf=pass (imf12.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.44 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685382488; h=from:from: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=HMdOshEWsCUccpZDIFZZY9qEaKeS/wKY+PKyVf4UtLw=; b=p20PEEo/bC+6xNZzdmA89SiwGWZzJv/Sgk34ZLTxLdM7lOyAggD3xImr02M3C+t0LLjDXt +s01Z0M2wH3107DMgzH9ACZeCedbQczaR9rItEA9ym0IEBgzlcZPEv7FOU+TQn1mN1yTyU kQKuGhp0R0pa5ivcZCmimon1Su9tJHY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685382488; a=rsa-sha256; cv=none; b=HEzUmTAAV/hyqK19b+Jwl5BmEMn+GLFIBpnjV0LZ8gp1UHTgjJj4mAxUwl5cfZG+BiOIum FS+d6scBhqmXTQ8xt+DtKoM/SmPLvcm0PozSvnNP+yvZ6DoVyDFAKIGk4SyrWP12n1Yfn3 YAUi1QfkeOw/VpoFN7c/BSkBApHYiw8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=WCwjN1TX; spf=pass (imf12.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.44 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-51475e981f0so6018660a12.1 for ; Mon, 29 May 2023 10:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1685382486; x=1687974486; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HMdOshEWsCUccpZDIFZZY9qEaKeS/wKY+PKyVf4UtLw=; b=WCwjN1TXsDQhih517yPCSkluit2k5EFbSNLUPvfdbbcxfpAGTxN9+aTCCHRA5pZtWn XxC4kysIL3lxycmuL7QRFbu9a021dqE6aTqjAa8Netk0dqyhwQwBm9HBIkx7THoL8HPF GcQNvXth2Mo8KH3bB6xWJSfCIIja4VsbNj4Xs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685382486; x=1687974486; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HMdOshEWsCUccpZDIFZZY9qEaKeS/wKY+PKyVf4UtLw=; b=JxMmSgW0mT7GbH0gbEJpvjyJKUPtwPNlJS1nZy9/y5lHfrXxf/uJ3aSMSnP/O6AUg/ V2Ck8iyR6KxazJzjHtkv7QQqE1Am5JqDb3/5eOlP/9PyymwlXVMFtz1TRVcF7KJOrUpC Gs9xGizxbndVNs98ZQI4CG0Pei+U3q1fOo4JHU7Duf2BTrOFjIebdzUFrKEOpvZQvzGD YkXjCedg2lCkUrpUCAnc2hzq0K3DiMS5QYPsJCEn3tEefwnOXqhgeR5D9Cmn8nEQq39u u40PWC95cX+khQhQHjWtZkbdmWXhdqG1WWAkWcVPJoUB2ZMO5RJCmEqjK+PlxKI7Vr83 ZI5w== X-Gm-Message-State: AC+VfDw+dReR7TD6sMbumQyn9Ofy09Qc0iYGIKbZ1qDkJgVkGva5YI9T PG+yQMMuxTHIjQ02qmdpg323+0Tux51xBB27fT9NAbIy X-Google-Smtp-Source: ACHHUZ47LpdBZgAdnu1eUSbhr4xsKhiDSFnqbjjwfE/E+3ktUd8T03Nt07j7q4De5Cu1HOYCV7NCZw== X-Received: by 2002:a17:907:e8a:b0:966:335a:5b07 with SMTP id ho10-20020a1709070e8a00b00966335a5b07mr14978428ejc.62.1685382486059; Mon, 29 May 2023 10:48:06 -0700 (PDT) Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com. [209.85.208.54]) by smtp.gmail.com with ESMTPSA id j4-20020a170906278400b00966056bd4f4sm6122579ejc.28.2023.05.29.10.48.05 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 May 2023 10:48:05 -0700 (PDT) Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5149b63151aso2745410a12.3 for ; Mon, 29 May 2023 10:48:05 -0700 (PDT) X-Received: by 2002:a17:907:36cd:b0:96f:7d09:7deb with SMTP id bj13-20020a17090736cd00b0096f7d097debmr13772127ejc.69.1685382465126; Mon, 29 May 2023 10:47:45 -0700 (PDT) MIME-Version: 1.0 References: <20230524213620.3509138-1-mcgrof@kernel.org> <20230524213620.3509138-3-mcgrof@kernel.org> <8fc5b26b-d2f6-0c8f-34a1-af085dbef155@suse.com> <6gwjomw6sxxmlglxfoilelswv4hgygqelomevb4k4wrlrk3gtm@wrakbmwztgeu> In-Reply-To: From: Linus Torvalds Date: Mon, 29 May 2023 13:47:28 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] module: add support to avoid duplicates early on load To: Johan Hovold Cc: Luis Chamberlain , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: eiix4tfb6jffn56wj1ffnoh4z9ijnn9n X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: D079440017 X-Rspam-User: X-HE-Tag: 1685382487-935262 X-HE-Meta: U2FsdGVkX1+4oFVVldAYf/uppTo/5uzLSxsq8eT0hTwMM3HZEUwuAsMog4Ie41jBrzVARitGU0vEcNjm7xSOhzuxbI8X6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jdx7DmEGkgTRr4XVyv+Um8BGYs42x+o09fc33D72yhFROU0vsG4IqX0AstCKXmaVYuDYxn0Jwi8YMK8A+8p0RNjXo6mkabGGN0IDiLWd923DtpMm+qxfS48Qk/TloJrduRMBpBYPeFAHxU76Cl8grsMEnSMraLcurL9/zuJmIfYQWIzyE90SQtNt2F8DQuUll8t9OfIAOmUEJ15kLfuam2ucIxZ1r/33OSn05aDwGv5NUP/EQQOXvumyc0TLly/pfJLRiqSKX9G1eCpaB7MOZ/KQnZSxOQCCfGaYrDHyhYdMM9zPpaey7dPgLo6eoE+Hu1ehGaLRWdzraMn2JxZTss/u1WtUEyL1zKaTbXh+XF+KStA5V2bFZjVW4xB/AuiY9IWc4w89niDEeSPmYdIixr0YoEHB3S1rYlkC4ZNba5RUPHNNAbCjGHGjgQ2pMjXDa5KEV+aoFtRHOQNfHasJOg 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 Mon, May 29, 2023 at 8:44=E2=80=AFAM Johan Hovold wro= te: > > Yes, those two changes are enough to make the problem go away. Ok, good. Expected, but just verifying that it wasn't some silly incidental thinko. > > I do wonder what it is that is different in your setup, and maybe you > > could also enable the > > > > pr_debug("finit_module: fd=3D%d, uargs=3D%p, flags=3D%i\n", fd,= uargs, flags); > > Below is the corresponding output with a working kernel: 174 requests > for the 131 modules that end up being loaded (without the revert there > is only around 110 modules loaded). Ok, your setup doesn't sound *too* different from mine. I have 176 kernel modules on my laptop right now, and that exclusive open obviously worked fine for me. But it could easily be some random small difference just from different hardware, so... And yeah, that dmesg output is useless, I didn't think of the fact that it only prints out the file descriptor, not the actual path to the file. In fact, without that change in place, the module code never actually looks at the file and leaves it all to kernel_read_file_from_fd(). With my change, it woul dhave been trivial to use "%pD" and point it at the file pointer instead, and get the dentry name that way, but never mind. I think you're entirely right that it's probably due to a shared dependency module, and I just didn't happen to trigger that case. Sadly, the whole idea was to figure out the exclusion so early that we don't have the module data structures lookup up yet, so there's no really obvious thing to serialize the load on. I'll have to think about this more. Serializing on a per-inode lock would seem to be the simplest thing, but they are all for IO, and we can't just take them over the read. Linus