Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2915091yba; Mon, 8 Apr 2019 07:22:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqz//AFCJOxw5pkMWsdFos/Cd26chyhCBDHLEaGV6/+ZKqqtsYSG2XQa0zJTahXSDRnxsyEG X-Received: by 2002:a62:6504:: with SMTP id z4mr30310863pfb.202.1554733346685; Mon, 08 Apr 2019 07:22:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554733346; cv=none; d=google.com; s=arc-20160816; b=LxTFbMc9OjadaYQMF9sXmrPyeWjvdKb8hXc7PFeYr6jgFTw3lG5je94YwkttjLspL8 itz1VduVqYlpKOb6Vb6WkbNyw6RznCbIlatQix1sArMbR4hxzjOQe7e75utpIWof+67V ibCIGDRk7B7XCPbKkeQHMIgCNhXYOgjAnerpL5P3KRVsr+3wHTRlYFWVg73f5MEMjFNy DkpzskFlwMneojjgBM7WfdxBNgS4alRF2Hew+MP1eZD7GLd9LJtx8u05huR+RK89wxmd ifB73fz/MmH1x5NI99cisCgn4HCsjgoDH7Qu7v+gOAOYOMhuI6VTCSbSmEWvEOTvfnwo 05IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Z+cw8lPOTd2k+caN0YQ7f79gUgHYwCL3ULHkVm8Sb1I=; b=Uz9Y8LFqLr4tMnE6WZa1MEZq3hvqQhYw9dIikXN3gxL8GMsU52eNoab9vAu6f1VCqT mEEZ0GZo/3A8i5gPfgp9y5dgvCoCo3R0aq8qihqhjbutb0V4Zv2Rmf5rgk8sp6UefhpP 7ITDCBRtteRTUM8iZb5l5RvkXDNzuD2alHJtlJFNhX67h3XnpDCk/uIfNNnmD3kUr83N tnRLwJpffCu2BV5DJwmUqZGt/ZZoBu87VyBzCSuMNR8SiEs515WzCstLcP/eT7L3RGvU B4E2L/LFdKQ6jlz2QNN5+qe+YJcCvNC9pzx8+HPBXVMhOv1gcbXHm7EoEFyoK+R52gla 1sAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1si18452319plp.120.2019.04.08.07.22.10; Mon, 08 Apr 2019 07:22:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726636AbfDHOTy (ORCPT + 99 others); Mon, 8 Apr 2019 10:19:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30939 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726349AbfDHOTy (ORCPT ); Mon, 8 Apr 2019 10:19:54 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E03DC308FC5E; Mon, 8 Apr 2019 14:19:53 +0000 (UTC) Received: from prarit.bos.redhat.com (prarit-guest.khw1.lab.eng.bos.redhat.com [10.16.200.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EF9B60472; Mon, 8 Apr 2019 14:19:53 +0000 (UTC) Subject: Re: [PATCH] modules: Only return -EEXIST for modules that have finished loading To: linux-kernel@vger.kernel.org Cc: cavery@redhat.com, Jessica Yu References: <20190402133916.13513-1-prarit@redhat.com> From: Prarit Bhargava Message-ID: Date: Mon, 8 Apr 2019 10:19:52 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190402133916.13513-1-prarit@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 08 Apr 2019 14:19:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jessica? ping? P. On 4/2/19 9:39 AM, Prarit Bhargava wrote: > Microsoft HyperV disables the X86_FEATURE_SMCA bit on AMD systems, and > linux guests boot with repeated errors: > > amd64_edac_mod: Unknown symbol amd_unregister_ecc_decoder (err -2) > amd64_edac_mod: Unknown symbol amd_register_ecc_decoder (err -2) > amd64_edac_mod: Unknown symbol amd_report_gart_errors (err -2) > amd64_edac_mod: Unknown symbol amd_unregister_ecc_decoder (err -2) > amd64_edac_mod: Unknown symbol amd_register_ecc_decoder (err -2) > amd64_edac_mod: Unknown symbol amd_report_gart_errors (err -2) > > The warnings occur because the module code erroneously returns -EEXIST > for modules that have failed to load and are in the process of being > removed from the module list. > > module amd64_edac_mod has a dependency on module edac_mce_amd. Using > modules.dep, systemd will load edac_mce_amd for every request of > amd64_edac_mod. When the edac_mce_amd module loads, the module has > state MODULE_STATE_UNFORMED and once the module load fails and the state > becomes MODULE_STATE_GOING. Another request for edac_mce_amd module > executes and add_unformed_module() will erroneously return -EEXIST even > though the previous instance of edac_mce_amd has MODULE_STATE_GOING. > Upon receiving -EEXIST, systemd attempts to load amd64_edac_mod, which > fails because of unknown symbols from edac_mce_amd. > > add_unformed_module() must wait to return for any case other than > MODULE_STATE_LIVE to prevent a race between multiple loads of > dependent modules. > > Signed-off-by: Prarit Bhargava > Reported-by: Cathy Avery > Cc: Jessica Yu > --- > kernel/module.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/kernel/module.c b/kernel/module.c > index 0b9aa8ab89f0..e8c1de2ab4e1 100644 > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -3566,8 +3566,7 @@ 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_COMING > - || old->state == MODULE_STATE_UNFORMED) { > + if (old->state != MODULE_STATE_LIVE) { > /* Wait in case it fails to load. */ > mutex_unlock(&module_mutex); > err = wait_event_interruptible(module_wq, >