Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5703329rwb; Mon, 14 Nov 2022 08:20:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ReVinZ87EQdhDfN7/FjfAPygmP7D5Z75+xhkAwDR+QYW9nPcom0/nSvuL63dvLfBGfP0d X-Received: by 2002:a17:906:78e:b0:7a1:e52e:bddb with SMTP id l14-20020a170906078e00b007a1e52ebddbmr10307202ejc.685.1668442839872; Mon, 14 Nov 2022 08:20:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668442839; cv=none; d=google.com; s=arc-20160816; b=IrFIhfO94cRCQsnmfFscce7h6tdTrDtRqrPdpPuk5qSKZvvAgWc8GNGxiH5bmG2kOD o3nKnw8gfgYw97BQO+839V/JpdUgfSoVhxLFuHfw3Zs1VWdWoeiM6DD7dRxEZ+APmDGH dbMnb8nbSi2+GyUWwbKmDTBFprX+zxRNiQCDB6uz7NdoH/P6Y5s0xDc4HvbbjHggVqum Wpb6LEXNwf1tDwB/3zqTqmuSjI9zLYdJqLee175y+B/7GFwGACk+iK8RNhH+0BIlsgHP YJkD7A8N+ANzw+Mj/QnSL1UBUnalOpB6ayWxDeRPAufiJJ+R4uaVBXpZxFWin5HuFgAM ieMQ== 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=uZjZHgVZVYg09RCV/ZTHwTfPg4g7gHQcNAZSrhfP1yM=; b=DVKvBom7+lUzBapg/C4PDD/PcU+UYETJGNdIqEdLLEdtxgU96QmfQgnulWsrZb9sYH pGU1/KbuuYtxdCYOME3v3eGvyKK8QfrvztETPyAV9z+KnTxSEAmV5uh6+jPP8T/UCk45 kc32KAyQgOUmA81hGMVLkx2e9CVHaFkw0sa0mQHT/BJ2rAH+lSDxs7bHpJvESCYpPKc7 NwJGem5wawoXq45353gBy0vJp1t9OggsxZ565VhaaDCYbMAgGW7dO5lDc9ErnHnVICsg QVGMP+uV2KU4R36X+VZ7bPQv7Tg63w/8mRvwYYEt8qWmCbQmlDd9qSdWTaF0PwvW4pAl QOEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=RLG9JtfN; 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 go32-20020a1709070da000b007ae2299a195si10629611ejc.815.2022.11.14.08.20.18; Mon, 14 Nov 2022 08:20:39 -0800 (PST) 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=RLG9JtfN; 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 S236891AbiKNPid (ORCPT + 87 others); Mon, 14 Nov 2022 10:38:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236124AbiKNPib (ORCPT ); Mon, 14 Nov 2022 10:38:31 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6813BBB8; Mon, 14 Nov 2022 07:38:30 -0800 (PST) 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=uZjZHgVZVYg09RCV/ZTHwTfPg4g7gHQcNAZSrhfP1yM=; b=RLG9JtfNVlXDGmV0guc6KvbTz3 fh8FFURX7gYuI3TIW9ZnqLfXE9CudFz+ZRU/xNGIZL+n+/t92bbez8w7h9/6YdpssgK7ZBtr4ZzmK iffoMPI7rdAa/jDBSZZ6DwpFBxZ2NzArKVyM4YDcesekoirLhHJ+SbZ2JpyIsL+tEyOF/6JJ/hElm MlGz3bxpExPImeok3oDW8t+6+b2ESDfo46zEKmtU/aJO/fnXcVwDDc/wVMGkl+cUty1qyCNpM5c9v TtzmYK4gbfYpiZ3TNFsowHkEippuBtOabOr0naWjCiO/GCCISKIZaShN0UqAg+TrQRKr0eI7m10Uv OzMCtGRw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oubXV-002IRv-CR; Mon, 14 Nov 2022 15:38:25 +0000 Date: Mon, 14 Nov 2022 07:38:25 -0800 From: Luis Chamberlain To: David Hildenbrand Cc: Prarit Bhargava , pmladek@suse.com, 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> 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.0 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 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, Nov 14, 2022 at 09:57:56AM +0100, David Hildenbrand wrote: > On 12.11.22 02:47, Luis Chamberlain wrote: > > On Wed, Oct 19, 2022 at 02:00:55PM +0200, Petr Pavlu wrote: > > > On 10/18/22 20: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. > > > > > > Simpler could be to do the following: > > > > > > diff --git a/kernel/module/main.c b/kernel/module/main.c > > > index d02d39c7174e..0302ac387e93 100644 > > > --- a/kernel/module/main.c > > > +++ b/kernel/module/main.c > > > @@ -2386,7 +2386,8 @@ static bool finished_loading(const char *name) > > > sched_annotate_sleep(); > > > mutex_lock(&module_mutex); > > > mod = find_module_all(name, strlen(name), true); > > > - ret = !mod || mod->state == MODULE_STATE_LIVE; > > > + ret = !mod || mod->state == MODULE_STATE_LIVE > > > + || mod->state == MODULE_STATE_GOING; > > > mutex_unlock(&module_mutex); > > > return ret; > > > @@ -2566,7 +2567,8 @@ static int add_unformed_module(struct module *mod) > > > mutex_lock(&module_mutex); > > > old = find_module_all(mod->name, strlen(mod->name), true); > > > if (old != NULL) { > > > - if (old->state != MODULE_STATE_LIVE) { > > > + if (old->state == MODULE_STATE_COMING > > > + || old->state == MODULE_STATE_UNFORMED) { > > > /* Wait in case it fails to load. */ > > > mutex_unlock(&module_mutex); > > > err = wait_event_interruptible(module_wq, > > > @@ -2575,7 +2577,7 @@ static int add_unformed_module(struct module *mod) > > > goto out_unlocked; > > > goto again; > > > } > > > - err = -EEXIST; > > > + err = old->state != MODULE_STATE_LIVE ? -EBUSY : -EEXIST; > > > goto out; > > > } > > > mod_update_bounds(mod); > > > > > > Prarit, can you verify this still does not break the issue you reported? > > David, does this also fix your issue? > > I didn't try, but from a quick glimpse I assume no. Allocating module space > happens before handling eventual duplicates right now, before a module even > is "alive" and in the MODULE_STATE_UNFORMED state. The first two hunks are a revert of commit 6e6de3dee51a and I'm under the impression that cauased your issues as *more* modules states are allowed through. The last hunk tries to fix what 6e6de3dee51a wanted to do. > But maybe I am missing something important. Please do test if you can. Luis