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 X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D195C7618B for ; Thu, 25 Jul 2019 12:56:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DFC7221951 for ; Thu, 25 Jul 2019 12:56:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564059398; bh=F/FsA+e4Dd8Scx3bQFdthOpfRrhA8DdCEIxJU7+kOf0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=cS5DcfyW6Lq2XKSeDPrpXgsPYDMgrCxS2YocRzdorYvVpcOkk635xgE2BJ3RrWJIB LHKS87xFH81qzGCEOxbS28JGhjg9U2mF/JmM4HEjO7DrCPgbnzB8FXfIEjV5F2ftCs M/++l0umZQcr230CWVz9yzXgJ4ewEyWCvWOi67Uc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388651AbfGYM4i (ORCPT ); Thu, 25 Jul 2019 08:56:38 -0400 Received: from mx2.suse.de ([195.135.220.15]:49480 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387901AbfGYM4i (ORCPT ); Thu, 25 Jul 2019 08:56:38 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D02BCAF05; Thu, 25 Jul 2019 12:56:36 +0000 (UTC) Date: Thu, 25 Jul 2019 14:56:36 +0200 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-acpi@vger.kernel.org, "Rafael J. Wysocki" , Andrew Morton , Oscar Salvador Subject: Re: [PATCH v1] ACPI / scan: Acquire device_hotplug_lock in acpi_scan_init() Message-ID: <20190725125636.GA3582@dhcp22.suse.cz> References: <20190724143017.12841-1-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190724143017.12841-1-david@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Wed 24-07-19 16:30:17, David Hildenbrand wrote: > We end up calling __add_memory() without the device hotplug lock held. > (I used a local patch to assert in __add_memory() that the > device_hotplug_lock is held - I might upstream that as well soon) > > [ 26.771684] create_memory_block_devices+0xa4/0x140 > [ 26.772952] add_memory_resource+0xde/0x200 > [ 26.773987] __add_memory+0x6e/0xa0 > [ 26.775161] acpi_memory_device_add+0x149/0x2b0 > [ 26.776263] acpi_bus_attach+0xf1/0x1f0 > [ 26.777247] acpi_bus_attach+0x66/0x1f0 > [ 26.778268] acpi_bus_attach+0x66/0x1f0 > [ 26.779073] acpi_bus_attach+0x66/0x1f0 > [ 26.780143] acpi_bus_scan+0x3e/0x90 > [ 26.780844] acpi_scan_init+0x109/0x257 > [ 26.781638] acpi_init+0x2ab/0x30d > [ 26.782248] do_one_initcall+0x58/0x2cf > [ 26.783181] kernel_init_freeable+0x1bd/0x247 > [ 26.784345] kernel_init+0x5/0xf1 > [ 26.785314] ret_from_fork+0x3a/0x50 > > So perform the locking just like in acpi_device_hotplug(). While playing with the device_hotplug_lock, can we actually document what it is protecting please? I have a bad feeling that we are adding this lock just because some other code path does rather than with a good idea why it is needed. This patch just confirms that. What exactly does the lock protect from here in an early boot stage. > Cc: "Rafael J. Wysocki" > Cc: Len Brown Cc: Andrew Morton > Cc: Oscar Salvador > Cc: Michal Hocko > Signed-off-by: David Hildenbrand > --- > drivers/acpi/scan.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > index 0e28270b0fd8..cbc9d64b48dd 100644 > --- a/drivers/acpi/scan.c > +++ b/drivers/acpi/scan.c > @@ -2204,7 +2204,9 @@ int __init acpi_scan_init(void) > acpi_gpe_apply_masked_gpes(); > acpi_update_all_gpes(); > > + lock_device_hotplug(); > mutex_lock(&acpi_scan_lock); > + > /* > * Enumerate devices in the ACPI namespace. > */ > @@ -2232,6 +2234,7 @@ int __init acpi_scan_init(void) > > out: > mutex_unlock(&acpi_scan_lock); > + unlock_device_hotplug(); > return result; > } > > -- > 2.21.0 -- Michal Hocko SUSE Labs