Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 11 Aug 2018 18:02:24 -0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1foYDX-00015c-3a for speck@linutronix.de; Sat, 11 Aug 2018 20:02:23 +0200 Received: by mail-pf1-x42e.google.com with SMTP id b11-v6so5917793pfo.3 for ; Sat, 11 Aug 2018 11:02:23 -0700 (PDT) Received: from i7.lan (c-73-11-52-149.hsd1.or.comcast.net. [73.11.52.149]) by smtp.gmail.com with ESMTPSA id b195-v6sm24398107pfb.2.2018.08.11.11.02.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Aug 2018 11:02:15 -0700 (PDT) Sender: Linus Torvalds Date: Sat, 11 Aug 2018 11:02:12 -0700 (PDT) From: Linus Torvalds Subject: [MODERATED] Re: unreated arch broken by the fixes In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Sat, 11 Aug 2018, Linus Torvalds wrote: > > So I'll double-check the other architectures, but I think I'll just > reverse the two lines as Catalin suggested: > > - boot_cpu_state_init(); > smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ > + boot_cpuhp_state_init(); Doing a visual scan over every single smp_prepare_boot_cpu() case, it really does look like the right thing to do. It fixes the case where the architecture uses the generic version of 'setup_per_cpu_areas()' (in mm/percpu.c), but then needs to do some arch-specific setup to make it "stick" in smp_prepare_boot_cpu(). arm and arm64 do that with code like void __init smp_prepare_boot_cpu(void) { set_my_cpu_offset(per_cpu_offset(smp_processor_id())); } (arm64 also initializes static keys etc) and most others don't do much of anything (often they do "set_cpu_online/present()" which looks fishy, but whatever) but s390 does something that *may* be related too: S390_lowcore.percpu_offset = __per_cpu_offset[0]; so it migth actually be the case that this is needed for s390 too. And in no case did it look *wrong*. In fact, for the case of x86, it really looks like the right thing too, and we could possibly just remove our current /* * Up to this point, the boot CPU has been using .init.data * area. Reload any changed state for the boot CPU. */ if (!cpu) switch_to_new_gdt(cpu); from setup_per_cpu_areas(), because our native_smp_prepare_boot_cpu() does exactly that int me = smp_processor_id(); switch_to_new_gdt(me); but whatever. It does seem to be duplicated right now, and kind of odd (why do that switch_to_new_gdt() inside the loop?). I wouldn't actually do that x86 change, because keeping the percpu segment setup earlier for x86 is certainly safer (there are other calls after it anyway, maybe they depend on percpu accesses working), but the point is that _conceptually_ it makes sense for x86 too. And more importantly, nobody seems to care about the opposite order. All that boot_cpu_state_init() does is about hotplug (which is why Catalin's test patch also renamed it to "boot_cpuhp_state_init()" - note the extra "hp" in there. I think that renaming might be a good idea (except I'd just spell out "hotplug" rather than add "hp" in the middle), but I'm not going to do that either. End result: keep the sequence as-is, I'll do the re-ordering early in the merge window before I pull anything, and mark it for stable. Linus