[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9f1aea6e-29ad-33e0-8ec8-c112956491b6@intel.com>
Date: Wed, 16 Mar 2022 16:47:25 -0700
From: Dave Hansen <dave.hansen@...el.com>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
luto@...nel.org, peterz@...radead.org
Cc: sathyanarayanan.kuppuswamy@...ux.intel.com, aarcange@...hat.com,
ak@...ux.intel.com, dan.j.williams@...el.com, david@...hat.com,
hpa@...or.com, jgross@...e.com, jmattson@...gle.com,
joro@...tes.org, jpoimboe@...hat.com, knsathya@...nel.org,
pbonzini@...hat.com, sdeep@...are.com, seanjc@...gle.com,
tony.luck@...el.com, vkuznets@...hat.com, wanpengli@...cent.com,
thomas.lendacky@....com, brijesh.singh@....com, x86@...nel.org,
linux-kernel@...r.kernel.org,
Sean Christopherson <sean.j.christopherson@...el.com>,
"Rafael J . Wysocki" <rafael.j.wysocki@...el.com>
Subject: Re: [PATCHv6 21/30] x86/acpi, x86/boot: Add multiprocessor wake-up
support
On 3/15/22 19:08, Kirill A. Shutemov wrote:
> + * The value of apic_id and wakeup_vector has to be set before updating
> + * the wakeup command. To let compiler preserve order of writes, use
> + * smp_store_release.
> + */
Yeah, but that's not what's written:
> + smp_store_release(&acpi_mp_wake_mailbox->apic_id, apicid);
> + smp_store_release(&acpi_mp_wake_mailbox->wakeup_vector, start_ip);
> + smp_store_release(&acpi_mp_wake_mailbox->command,
> + ACPI_MP_WAKE_COMMAND_WAKEUP);
That says that the write to ->apic_id has to happen before the write to
->wakeup_vector which has to happen before the write to ->command. What
you have here *works*, but it doesn't match the comment.
If the problem were the compiler alone, I think three WRITE_ONCE()'s
would also suffice. (Hint: WRITE_ONCE() is insufficient).
I _think_ this will do:
acpi_mp_wake_mailbox->apic_id = apicid;
acpi_mp_wake_mailbox->wakeup_vector = start_ip;
smp_wmb();
WRITE_ONCE(acpi_mp_wake_mailbox->command, ACPI_MP_WAKE_CO...);
But it's the end of the day and I'm sending this out under duress, so
please double-check my logic.
Also, in all practicality, the WRITE_ONCE() isn't going to do much.
->command is 2 bytes and even the stupidest compiler isn't going to
break that up. The compiler also fundamentally understands the ordering
between this ->command write and the below:
READ_ONCE(acpi_mp_wake_mailbox->command).
The READ_ONCE() will also ensure that *it* goes out to memory. *But*,
the WRITE_ONCE() does make it very clear what is supposed to happen.
Powered by blists - more mailing lists