Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp478921rwi; Thu, 20 Oct 2022 00:56:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/qHW/9/EfpRPV7A5HACez4D/JgbltKfdGhGfJX5o3SAnfAyqpeY59RRqRLGEwcGvZdSZQ X-Received: by 2002:a17:902:d483:b0:182:cb98:26e8 with SMTP id c3-20020a170902d48300b00182cb9826e8mr12735392plg.73.1666252573581; Thu, 20 Oct 2022 00:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666252573; cv=none; d=google.com; s=arc-20160816; b=wyiETpOy++Y27SEBonpua2PEeS58YC/uMQgdBbtIuk2dgwHVc9H4OKZQUvIGSlGBd5 Sk1i8MfLngFHfF67UbknkFFDJ0TXcNGlBQxx75crcZFfn+F0QY8aQXbZPT+C11Pza54t iewU1x+osQlgOzyFRrZ5EFa0DvDuwDRXEX5una51jzf44fP1R+iNqP1lvl4AYyrqcy2F L28stnYcmdJSR5D8YtZTHEy0QDnVdKIOcfraX1wuwRq5sBJc2qpJ5oBlxIeRoiCOtZvY deXRtsd+mW1MTcDkBk/om7Hg8ZRG/V0PwKxx1eaD7BUhX9PvlO0ypZFhgSIOssdR3G5o UQ5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fVnKUVN+rk3hsRrJaEq7YSvnw07L+3uAYvZmtQr/27U=; b=OqTPMyqR7WuVub8lg3J3f9123OS3N9Kgmp+V6ZRMX0yOOfJfmQDvOLbdYe9K92K4bP DibThf8wyrLePn3K8ck2fmnmXUHgHUb/vlglG9G8Z/71quyG5VRoD6S6inOCKBXJUeNT 5xiZ3SHOUvD1KsjxySceQztaHQMwky4q7nFuK2U4ZjRDjlKL7VcT2FS0r0CUD5FvD0Y5 TK4PAyPt7Dr8PnPj7wM/dIK15vhcc2LFHVadT1wbu58Vp2ojXS8u9MxvhodST2V6GlQX yGXrgJAFBfCdw3kzMPTIdcchSQmVo8gNS9ft6f1+Duh8CfBdu/cOkJ7ibWp2vRg4Aixo mtZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=ruOP6WHz; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n10-20020a1709026a8a00b00172ec19cb96si19354043plk.436.2022.10.20.00.55.59; Thu, 20 Oct 2022 00:56:13 -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=@suse.com header.s=susede1 header.b=ruOP6WHz; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230249AbiJTHUH (ORCPT + 99 others); Thu, 20 Oct 2022 03:20:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbiJTHT6 (ORCPT ); Thu, 20 Oct 2022 03:19:58 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8AEC32D83; Thu, 20 Oct 2022 00:19:47 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 9A6FB228C8; Thu, 20 Oct 2022 07:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1666250384; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fVnKUVN+rk3hsRrJaEq7YSvnw07L+3uAYvZmtQr/27U=; b=ruOP6WHzMtqSd3sHQzx9qDusF18iwgbG8+jovJfWG3TQhxK2QkMZfppQKtGpwmJitTuVuP wY55GO8fyTPqT8D08VUpyJ3Gd4Fx5wcJ65Fzhg+Mdq83+pUsfnHDtm9twwIdVYB7SQXMqY eVxEU+tScDSElYyT7GgQoAwnLbCjvoY= Received: from suse.cz (unknown [10.100.208.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 78E832C141; Thu, 20 Oct 2022 07:19:44 +0000 (UTC) Date: Thu, 20 Oct 2022 09:19:44 +0200 From: Petr Mladek To: Prarit Bhargava Cc: Luis Chamberlain , Petr Pavlu , linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] module: Merge same-name module load requests Message-ID: References: <20220919123233.8538-1-petr.pavlu@suse.com> <20220919123233.8538-3-petr.pavlu@suse.com> <2342ef17-f8f9-501f-0f7b-5a69e85c2cf4@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2342ef17-f8f9-501f-0f7b-5a69e85c2cf4@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 Tue 2022-10-18 15:53:03, Prarit Bhargava wrote: > On 10/18/22 14:33, Luis Chamberlain wrote: > > On Sat, Oct 15, 2022 at 11:27:10AM +0200, Petr Pavlu wrote: > > > The patch does address a regression observed after commit 6e6de3dee51a > > > ("kernel/module.c: Only return -EEXIST for modules that have finished > > > loading"). I guess it can have a Fixes tag added to the patch. > > > > > > I think it is hard to split this patch into parts because the implemented > > > "optimization" is the fix. > > > > git describe --contains 6e6de3dee51a > > v5.3-rc1~38^2~6 > > > > I'm a bit torn about this situation. Reverting 6e6de3dee51a would be the > > right thing to do, but without it, it still leaves the issue reported > > by Prarit Bhargava. We need a way to resolve the issue on stable and > > then your optimizations can be applied on top. > > > > Prarit Bhargava, please review Petry's work and see if you can come up > > with a sensible way to address this for stable. > > I found the original thread surrounding these changes and I do not think > this solution should have been committed to the kernel. It is not a good > solution to the problem being solved and adds complexity where none is > needed IMO. > > Quoting from the original thread, > > > > > Motivation for this patch is to fix an issue observed on larger machines with > > many CPUs where it can take a significant amount of time during boot to run > > systemd-udev-trigger.service. An x86-64 system can have already intel_pstate > > active but as its CPUs can match also acpi_cpufreq and pcc_cpufreq, udev will > > attempt to load these modules too. The operation will eventually fail in the > > init function of a respective module where it gets recognized that another > > cpufreq driver is already loaded and -EEXIST is returned. However, one uevent > > is triggered for each CPU and so multiple loads of these modules will be > > present. The current code then processes all such loads individually and > > serializes them with the barrier in add_unformed_module(). > > > > The way to solve this is not in the module loading code, but in the udev > code by adding a new event or in the userspace which handles the loading > events. > > Option 1) > > Write/modify a udev rule to to use a flock userspace file lock to prevent > repeated loading. The problem with this is that it is still racy and still > consumes CPU time repeated load the ELF header and, depending on the system > (ie a large number of cpus) would still cause a boot delay. This would be > better than what we have and is worth looking at as a simple solution. I'd > like to see boot times with this change, and I'll try to come up with a > measurement on a large CPU system. This sounds like a ping-pong between projects where to put the complexity. Honestly, I think that it would be more reliable if we serialized/squashed parallel loads on the kernel side. > Option 2) > > Create a new udev action, "add_once" to indicate to userspace that the > module only needs to be loaded one time, and to ignore further load > requests. This is a bit tricky as both kernel space and userspace would > have be modified. The udev rule would end up looking very similar to what > we now. > > The benefit of option 2 is that driver writers themselves can choose which > drivers should issue "add_once" instead of add. Drivers that are known to > run on all devices at once would call "add_once" to only issue a single > load. My concern is how to distinguish first attempts and later (fixed) attempts. I mean that the module load might fail at boot. But the user might fix the root of the problem and try to load the module once again without reboot. The other load need not be direct. It might be part of another more complex operation. Reload of another module. Restart of a service. It might be problematic to do this an user-friendly way. And it might be much more complicated in the end. Best Regards, Petr