From patchwork Wed Jul 31 12:32:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11067691 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1999313B1 for ; Wed, 31 Jul 2019 12:32:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0671028496 for ; Wed, 31 Jul 2019 12:32:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF0BF28706; Wed, 31 Jul 2019 12:32:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CA6A2891B for ; Wed, 31 Jul 2019 12:32:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727798AbfGaMcI (ORCPT ); Wed, 31 Jul 2019 08:32:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59676 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726259AbfGaMcH (ORCPT ); Wed, 31 Jul 2019 08:32:07 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9348185542; Wed, 31 Jul 2019 12:32:07 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-240.ams2.redhat.com [10.36.117.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 792775C1B5; Wed, 31 Jul 2019 12:32:02 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-acpi@vger.kernel.org, David Hildenbrand , "Rafael J . Wysocki" , Michal Hocko , Oscar Salvador , Andrew Morton Subject: [PATCH v1] drivers/acpi/scan.c: Fixup "acquire device_hotplug_lock in acpi_scan_init()" Date: Wed, 31 Jul 2019 14:32:01 +0200 Message-Id: <20190731123201.13893-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 31 Jul 2019 12:32:07 +0000 (UTC) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Let's document why we take the lock here. If we're going to overhaul memory hotplug locking, we'll have to touch many places - this comment will help to clairfy why it was added here. Cc: Rafael J. Wysocki Cc: Michal Hocko Cc: Oscar Salvador Cc: Andrew Morton Signed-off-by: David Hildenbrand --- drivers/acpi/scan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index cbc9d64b48dd..9193f1d46148 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2204,6 +2204,11 @@ int __init acpi_scan_init(void) acpi_gpe_apply_masked_gpes(); acpi_update_all_gpes(); + /* + * We end up calling __add_memory(), which expects the + * device_hotplug_lock to be held. Races with userspace and other + * hotplug activities are not really possible - lock for consistency. + */ lock_device_hotplug(); mutex_lock(&acpi_scan_lock);