Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4800148ooa; Tue, 14 Aug 2018 10:43:28 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyMafR5MinFZ4W5J09JT6pBbup87kNQPcNC+PoZcWCZK8/p12P7+4OoYDTg8AHREwxTApm7 X-Received: by 2002:a63:6345:: with SMTP id x66-v6mr22254313pgb.43.1534268608763; Tue, 14 Aug 2018 10:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268608; cv=none; d=google.com; s=arc-20160816; b=FeriNoqV9ZolHKS4rSCUMNeDH3LuJi0DM3kLxLZNd8UaOa1odcn6FzuvZXvnb+EZqh j2upum5KBSXsfgqTCVJbKy0eddg81VRJV23CdwtDDo3UVQpexJIsk08viK0AzIAvo82L CKdykeX9ypxO3y9GJcdB8MYSTJ1M2wHL5TkKdRbwwwJy4noMxfoxYvx6FtNZU/hKhUWj ukFJG2KGPldGbZFBBiPl04ZsUCEFp2dSLcnwmX/dOHXk64L27cfnaE6TY26RGVhujOzR m6KUJGyuv/WLeVDFEqm61twk5M1uyvAU4ouhC+phJLzV9Zek6IwZqMREIfrcktgbyQlH 5Qtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=HEAVvkBqxL1Sjg2zbNAufOVmHr4OOyC0/cxW8Ri2u8U=; b=en3jSBQS+jUB+/r84fy7Ha1UveBA373wLO502eZiSoL2gF8bPXtPt1EaUe98cQJJfb 8HUtx34SJtlYgj4lDkL2v77UMVhYzEV71Pp/v0y3QhgCzI8Iv/5iaW6mg+amPAg52FwU W5J771EkRDwsvlKzeHW+JCZ7NnR6OTk6hkIPrnV9SYBU3US+MvmdPjezN2007qdAxwuz 7Gs6qZ85ht/fenqtvxrIrv2X4ORuUXZIjIqQfjqR+Llpa8p+K8pELWHTA5JL4gE3SEG/ nWMwOLJgBRCLCR91wySlbT2O4GGR3YYaPQXVW0z1d6fARLaiy8NOLWqzB9tUPooB3NBb 5jSw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k7-v6si19989693pgk.104.2018.08.14.10.43.14; Tue, 14 Aug 2018 10:43:28 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390370AbeHNUa1 (ORCPT + 99 others); Tue, 14 Aug 2018 16:30:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59606 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388923AbeHNUa0 (ORCPT ); Tue, 14 Aug 2018 16:30:26 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3D903C8D; Tue, 14 Aug 2018 17:42:15 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vlastimil Babka , Mian Yousaf Kaukab , Catalin Marinas , Thomas Gleixner , Will Deacon , stable@kernel.org, Linus Torvalds Subject: [PATCH 4.9 010/107] init: rename and re-order boot_cpu_state_init() Date: Tue, 14 Aug 2018 19:16:33 +0200 Message-Id: <20180814171521.425971727@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171520.883143803@linuxfoundation.org> References: <20180814171520.883143803@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Linus Torvalds commit b5b1404d0815894de0690de8a1ab58269e56eae6 upstream. This is purely a preparatory patch for upcoming changes during the 4.19 merge window. We have a function called "boot_cpu_state_init()" that isn't really about the bootup cpu state: that is done much earlier by the similarly named "boot_cpu_init()" (note lack of "state" in name). This function initializes some hotplug CPU state, and needs to run after the percpu data has been properly initialized. It even has a comment to that effect. Except it _doesn't_ actually run after the percpu data has been properly initialized. On x86 it happens to do that, but on at least arm and arm64, the percpu base pointers are initialized by the arch-specific 'smp_prepare_boot_cpu()' hook, which ran _after_ boot_cpu_state_init(). This had some unexpected results, and in particular we have a patch pending for the merge window that did the obvious cleanup of using 'this_cpu_write()' in the cpu hotplug init code: - per_cpu_ptr(&cpuhp_state, smp_processor_id())->state = CPUHP_ONLINE; + this_cpu_write(cpuhp_state.state, CPUHP_ONLINE); which is obviously the right thing to do. Except because of the ordering issue, it actually failed miserably and unexpectedly on arm64. So this just fixes the ordering, and changes the name of the function to be 'boot_cpu_hotplug_init()' to make it obvious that it's about cpu hotplug state, because the core CPU state was supposed to have already been done earlier. Marked for stable, since the (not yet merged) patch that will show this problem is marked for stable. Reported-by: Vlastimil Babka Reported-by: Mian Yousaf Kaukab Suggested-by: Catalin Marinas Acked-by: Thomas Gleixner Cc: Will Deacon Cc: stable@kernel.org Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- include/linux/cpu.h | 2 +- init/main.c | 2 +- kernel/cpu.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -29,7 +29,7 @@ struct cpu { }; extern void boot_cpu_init(void); -extern void boot_cpu_state_init(void); +extern void boot_cpu_hotplug_init(void); extern int register_cpu(struct cpu *cpu, int num); extern struct device *get_cpu_device(unsigned cpu); --- a/init/main.c +++ b/init/main.c @@ -509,8 +509,8 @@ asmlinkage __visible void __init start_k setup_command_line(command_line); setup_nr_cpu_ids(); setup_per_cpu_areas(); - boot_cpu_state_init(); smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ + boot_cpu_hotplug_init(); build_all_zonelists(NULL, NULL); page_alloc_init(); --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1944,7 +1944,7 @@ void __init boot_cpu_init(void) /* * Must be called _AFTER_ setting up the per_cpu areas */ -void __init boot_cpu_state_init(void) +void __init boot_cpu_hotplug_init(void) { per_cpu_ptr(&cpuhp_state, smp_processor_id())->state = CPUHP_ONLINE; }