From patchwork Tue Jan 10 01:27:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 90602 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp366468qgi; Mon, 9 Jan 2017 17:27:31 -0800 (PST) X-Received: by 10.98.83.193 with SMTP id h184mr706769pfb.175.1484011651229; Mon, 09 Jan 2017 17:27:31 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d30si45526plj.218.2017.01.09.17.27.30; Mon, 09 Jan 2017 17:27:31 -0800 (PST) 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; dkim=fail header.i=@gmail.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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967368AbdAJB1V (ORCPT + 25 others); Mon, 9 Jan 2017 20:27:21 -0500 Received: from mail-oi0-f68.google.com ([209.85.218.68]:35228 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755113AbdAJB1R (ORCPT ); Mon, 9 Jan 2017 20:27:17 -0500 Received: by mail-oi0-f68.google.com with SMTP id x84so16027649oix.2; Mon, 09 Jan 2017 17:27:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=MVU4gI9MS6dO0cyPMyk9CX4ivL+iQdllUy1OIsgYRoM=; b=sfRhDf2dpAUKL3sbE1wdDZuuSLjEtHUZcLOO7AX8yK+Gn3lThk5uGQ7+3WQECvgN3Z GJHI2xtYhYyCiEMLTq6ZQqdhdWfTvD8+kfjC/k4lR+7kSs/xqFwtpouIDh40gXIN64gu cpROoa6W4EYf6D9r99zgNBINnU2r43wmxzKr5fDMOQx7PZshwQbH4VomOfRsigulaXG2 JOE4XacvLkNkwJKOnMMZv23kwSpJBU0d1Abq4/lFK8iEjNTJOWsBEO4qFPF4thKPCUaz ZzULRvK4QebPNERWoqWTCguSa1D+tx1YjXa8m8p8suS8EukeUFMA6d8f3LTKQZos4V8v W6XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=MVU4gI9MS6dO0cyPMyk9CX4ivL+iQdllUy1OIsgYRoM=; b=CB3gjj31GFVLtXLPj4kUszB1SuNXB/shKD0L/jhyKy9fOHXg0RLMF8HD+CeZ0TfExH TZweLr99BvKDI+x2uXLyUseV5sN2llvHXtYcMlSBkKrXFozx1XZA791LQPO75LJ6x1k/ del/7EvmqpAvLte6hNVk9b6kSekFR9EHurWKcJCofqwrfeVu+11uGvovkAr+WI7ISM/K E0KEaFQcTUtvnTBL24FyQq5atEU9hVAOWjcPAdoXoVtPfurzLhh9cN85GhebvFL4JlOJ HPSZl2GtkoaXdaUoY+l43JMv0BeapkJMJp+bv+FrsW6GModT/x5/ZqDIfhAVIGyY+RWp y10g== X-Gm-Message-State: AIkVDXJ7tZNMXOpSrGFhb2tguwkxNcjlXz6eDXbvfS9AltauVARPNZ+OwDNdmeWnDSluWLYh0PDbyycg+EmU5g== X-Received: by 10.157.35.20 with SMTP id j20mr269299otb.167.1484011636949; Mon, 09 Jan 2017 17:27:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.12.152 with HTTP; Mon, 9 Jan 2017 17:27:16 -0800 (PST) In-Reply-To: <20170109235211.yetponvbexvalkir@pd.tnic> References: <20170108130355.vxhjmj6dlkqw6hyq@pd.tnic> <1AE640813FDE7649BE1B193DEA596E886CE27B7E@SHSMSX101.ccr.corp.intel.com> <1AE640813FDE7649BE1B193DEA596E886CE27BEE@SHSMSX101.ccr.corp.intel.com> <20170109093329.jd7uwlcpci4icpd3@pd.tnic> <20170109221831.GC3800@linux.vnet.ibm.com> <20170109231501.xrhwsv46mznw3kqt@pd.tnic> <20170109233204.GG3800@linux.vnet.ibm.com> <20170109234039.mfefmv5dv4shxnfn@pd.tnic> <20170109235211.yetponvbexvalkir@pd.tnic> From: "Rafael J. Wysocki" Date: Tue, 10 Jan 2017 02:27:16 +0100 X-Google-Sender-Auth: TgufeJE_hZ2giZZZoSW3j162ul4 Message-ID: Subject: Re: 174cc7187e6f ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel To: Borislav Petkov Cc: "Paul E. McKenney" , "Zheng, Lv" , "Rafael J. Wysocki" , "Wysocki, Rafael J" , "Moore, Robert" , "J?rg R?del" , lkml , Linux ACPI Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 10, 2017 at 12:52 AM, Borislav Petkov wrote: > On Tue, Jan 10, 2017 at 12:40:39AM +0100, Borislav Petkov wrote: >> Lemme run it. > > Well, it boots but I get: > > [ 0.291447] ------------[ cut here ]------------ > [ 0.291702] WARNING: CPU: 0 PID: 1 at kernel/rcu/tree.c:3993 rcu_scheduler_starting+0x5c/0x70 > [ 0.292107] Modules linked in: > [ 0.292277] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.10.0-rc3+ #21 > [ 0.292540] Hardware name: HP HP EliteBook 745 G3/807E, BIOS N73 Ver. 01.08 01/28/2016 > [ 0.292893] Call Trace: > [ 0.293072] ? dump_stack+0x46/0x63 > [ 0.293285] ? __warn+0xec/0x110 > [ 0.293487] ? rcu_scheduler_starting+0x5c/0x70 > [ 0.293735] ? kernel_init_freeable+0x58/0x19a > [ 0.293976] ? rest_init+0x80/0x80 > [ 0.294153] ? kernel_init+0xa/0x100 > [ 0.294334] ? ret_from_fork+0x22/0x30 > [ 0.294525] ---[ end trace 4c0fe009ed4dc740 ]--- > > TBH, I like Rafael's suggestion in the other mail to stick with fixing > this in ACPI, especially this is an ACPI problem, not RCU. Well, > more or less: RCU could be taught to *not* do schedule_work() if > workqueue_init() hasn't happened yet but that's a tangential. > > So, I'm going to bed. When I wake up, I want to see working fixes! > > :-))) Well, if the https://patchwork.kernel.org/patch/9504277/ patch from Lv worked, the attached one should work too (please test), but it can be justified in a slightly more convincing way. Namely, the idea is that acpi_os_read/write_memory() should never be used before invoking acpi_os_initialize() and since those are the only places where the list of memory regions is walked under RCU without extra locking, it is safe to skip the RCU synchronization until that happens. Thanks, Rafael --- drivers/acpi/osl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) Index: linux-pm/drivers/acpi/osl.c =================================================================== --- linux-pm.orig/drivers/acpi/osl.c +++ linux-pm/drivers/acpi/osl.c @@ -378,7 +378,9 @@ static void acpi_os_drop_map_ref(struct static void acpi_os_map_cleanup(struct acpi_ioremap *map) { if (!map->refcount) { - synchronize_rcu_expedited(); + if (acpi_os_initialized) + synchronize_rcu_expedited(); + acpi_unmap(map->phys, map->virt); kfree(map); } @@ -671,6 +673,8 @@ acpi_os_read_memory(acpi_physical_addres bool unmap = false; u64 dummy; + WARN_ON_ONCE(!acpi_os_initialized); + rcu_read_lock(); virt_addr = acpi_map_vaddr_lookup(phys_addr, size); if (!virt_addr) { @@ -716,6 +720,8 @@ acpi_os_write_memory(acpi_physical_addre unsigned int size = width / 8; bool unmap = false; + WARN_ON_ONCE(!acpi_os_initialized); + rcu_read_lock(); virt_addr = acpi_map_vaddr_lookup(phys_addr, size); if (!virt_addr) {