Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3467892rwd; Mon, 29 May 2023 10:57:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Nx9UHpAG0PjZQs04RU8EUgC6KcUM0c8OJM4TPSS9RpFtsihHvHwKsj6nKqQxR6lG4sMBd X-Received: by 2002:a17:902:e5cc:b0:1ae:2c87:f771 with SMTP id u12-20020a170902e5cc00b001ae2c87f771mr14716319plf.20.1685383071015; Mon, 29 May 2023 10:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685383071; cv=none; d=google.com; s=arc-20160816; b=iGOmUFSHPXQwAhr+ZcXmvT1PYM+j2RL2l9ozAwlwqtMZ0i73gf9Yyja0C0kXAK1yD/ IekWahcHqsjVOkDicUVMpbQ46cqmMPhMHzEIpV3vsHa49gIiYMcLl1Ic0X3TWRi/0rWL NdXTzO/sCEurKIIAtL512JFdAzjsNSy9luPhaFcTCW5EkG04m4PWJ0S9Vza+sNEQq+wL RxM1P9AgLheyhSlUtsfKrN+86yEkB07V5RKwhkpMjy8xu00YhDsufOiFyL22nrTq+FTS bfpKColYx69M3A7ArNqFvXtSeupj0RQBAaM1aGs8CivHAZ+Tgw1qurbwOANEaUyFFWt3 Jn/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=HMdOshEWsCUccpZDIFZZY9qEaKeS/wKY+PKyVf4UtLw=; b=wS8N6B7LqPlPWGaPJyb+KoZLQd0QThGjlsC27BSZQOZEZs4x+tnb9ZTuFgh0hUKCGx J7JMF2D9qX53g4fGhjmG+j6ogwoTEHZrDLVnm8D6t6ERKKLDx+BimX4pbcaWyHgr9sGy UmiWcrvzOrzgFV0knmzkGaFrDx99VVNUTVbWWfP7mPFmM7jp4O2t0lsmPIMINy7l9Lxm oDzzZj2RPwDKfVSfY384GwN9YYsDF0bUjKAS4q5injTIzoBHoKwN/ljBFi4bQyTeVX1A vWtVE04tUIdK+E0MDK9fapP7gIoH3DYGO5nlwbIVQsog8eRhX7z+gSuT77DV78cTa27y UK/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=ebxoUHMA; 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 y9-20020a170902700900b001a043389a7asi7936495plk.310.2023.05.29.10.57.38; Mon, 29 May 2023 10:57:50 -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=@linux-foundation.org header.s=google header.b=ebxoUHMA; 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 S229620AbjE2RsM (ORCPT + 99 others); Mon, 29 May 2023 13:48:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbjE2RsK (ORCPT ); Mon, 29 May 2023 13:48:10 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E866DE for ; Mon, 29 May 2023 10:48:08 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-973f78329e3so284365166b.3 for ; Mon, 29 May 2023 10:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1685382487; x=1687974487; 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=ebxoUHMAoHjBwRTQQFj5NAVEDHva9Q+73M4/Q/jpzXMPHcw9bjP39wSyvA7bdgirQc hDUdZY8YVnGr12KA2uzMWc133w/odbrTDg9Nbdl8mv3qwoqkKKvfDmu9tG58tYTnLjTP yg1PQODaY05oxTogUAi/p3cS8p+y2FjkdNlYA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685382487; x=1687974487; 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=E+xo7G1X+1XgKBzpFNkAt2aL82KeCCnVA9XGnyT9NDmxwwZnr9iBoU6pG12X6M7lM9 82pOQNDDvj3vNq1ONtHv3d5PkEwb8XLZvFO0qM9PrcKH4CapXpVM6GvOeRQS6xvunYj7 LN4a+9w/kl184KhrBUtKMzY3f6rJVVfWKF/ikhHQpKKRR1c5RFmif4149IVFFzFTOZMd yflMfAUk8NAPW0yYNF89RuN+Z92SlJUsqiBzmdSCPHILW2nflfDBG9bmk2CDN97EvaTd noR09yhUkKcc0w1kPG1/TM7ItkR+cNF+Be/DsFnpnf67/PKJodIIn/ZkhB++3EQJoAwX DrWw== X-Gm-Message-State: AC+VfDyXLzn1o1pHD5SNwJWC8kfrLBP3bMxWGZI/TZA2JZq2kt8PoLo5 dVE+OKMkDTVJ1KR63yH0LqNipsl8TaSZ1gf90KShhHfx X-Received: by 2002:a17:907:720b:b0:974:32e:7de9 with SMTP id dr11-20020a170907720b00b00974032e7de9mr3503022ejc.56.1685382486929; 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 s7-20020a170906c30700b0094f410225c7sm6130377ejz.169.2023.05.29.10.48.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 May 2023 10:48:06 -0700 (PDT) Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5149b63151aso2745425a12.3 for ; Mon, 29 May 2023 10:48:06 -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-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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, 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