English 中文(简体)
在X86年寄送国际自然学会之后,是否会发现记忆?
原标题:Will memory write be visible after sending an IPI on x86?

我阅读了Intel 64和I-32建筑,SDM vol 3A, 9.2 MEMORY ORDERING,但有一个问题使我和我都保持下去。

如果我先致函记忆地址,然后向加工商发送一台X2APIC的间断裂器,即发送国际自然及自然资源研究所不需要书面记忆(合理使用护堤)。 国际自然及自然资源研究所的另一个核心反馈是,它是否读到正确的价值?

例如:

Initially x = 0

加工商0:

mov [ _x], 1
wrmsr       # use x2APIC to send IPI

过程1:

# resive IPI, in the interrupt service routine:
mov r1, [ _x]

是否允许?

最佳回答

这是一个令人感兴趣的问题。 面对这一点,人们会认为,自以来,该编码是一份连续的指令,它冲动了以前的记本,而且所有内容都很好。 即便如此,引用手册:

These instructions force the processor to complete all modifications to flags, registers, and memory by previous instructions and to drain all buffered writes to memory before the next instruction is fetched and executed.

(Emphasis mine)

It doesn t say anything about the ordering with respect to sending the IPI as that is part of the current instruction, not the next one. So this theoretically means the other core could execute the mov r1, [ _x] while the originating core is still busy flushing stuff but is very unlikely given that the target core would need to service the interrupt which probably has a lot higher latency.

如“@harold”所述,这一点是空洞的,因为“WRMSR并非总是序列化。 阅读我最初错过的脚注:

WRMSR to the IA32_TSC_DEADLINE MSR (MSR index 6E0H) and the X2APIC MSRs (MSR indices 802H to 83FH) are not serializing.

因此,绝对不能保证转录到<条码>x的文字。

问题回答

来自Intel® 64和I-32建筑软件开发商手册第3A卷:系统方案拟订指南,第一部分

11.12.3 MSR Access in x2APIC Mode

To allow for efficient access to the APIC registers in x2APIC mode, the serializing semantics of WRMSR are relaxed when writing to the APIC registers. Thus, system software should not use “WRMSR to APIC registers in x2APIC mode” as a serializing instruction. Read and write accesses to the APIC registers will occur in program order. A WRMSR to an APIC register may complete before all preceding stores are globally visible; software can prevent this by inserting a serializing instruction or the sequence MFENCE;LFENCE before the WRMSR.

The RDMSR instruction is not serializing and this behavior is unchanged when reading APIC registers in x2APIC mode. System software accessing the APIC registers using the RDMSR instruction should not expect a serializing behavior. (Note: The MMIO-based xAPIC interface is mapped by system software as an un-cached region. Consequently, read/writes to the xAPIC-MMIO interface have serializing semantics in the xAPIC mode.)

然而,我仍然不知道这是否会与友好进程者合作。

加工商1在英特尔邮联处理国际消费物价指数时,有可能遵守加工商0撰写的价值。 保证在向X2APIC移交独立会计师事务所之前必须设置一个障碍,因为写作X2APIC MSRs不是《英特尔公司指令》的序列。

AMD CPUs don t need a fence after writing x2APIC/TSC_DEADLINE MSRs.

这里指的是在跨核心职能要求时的欧伦特角守则。 在向目标CPU派遣IPI之前,它有“历史;存在”。 对AMD CPUs来说,软弱无力的休眠是一例。

static void x2apic_send_IPI(int cpu, int vector)
{
    u32 dest = per_cpu(x86_cpu_to_apicid, cpu);

    /* x2apic MSRs are special and need a special fence: */
    weak_wrmsr_fence();
    __x2apic_send_IPI_dest(dest, vector, APIC_DEST_PHYSICAL);
}

/*
 * Make previous memory operations globally visible before
 * a WRMSR.
 *
 * MFENCE makes writes visible, but only affects load/store
 * instructions.  WRMSR is unfortunately not a load/store
 * instruction and is unaffected by MFENCE.  The LFENCE ensures
 * that the WRMSR is not reordered.
 *
 * Most WRMSRs are full serializing instructions themselves and
 * do not require this barrier.  This is only required for the
 * IA32_TSC_DEADLINE and X2APIC MSRs.
 */
static inline void weak_wrmsr_fence(void)
{
    alternative("mfence; lfence", "", ALT_NOT(X86_FEATURE_APIC_MSRS_FENCE));
}




相关问题
What resources are shared between threads?

Recently, I have been asked a question in an interview what s the difference between a process and a thread. Really, I did not know the answer. I thought for a minute and gave a very weird answer. ...

Random access of multiple files and file caching

This relates to some software I ve been given to "fix". The easiest and quickest solution would make it open and read 10 random files out of hundreds and extract some very short strings for processing ...

What form is DLL & what makes it processor dependent

I know DLL contains one or more exported functions that are compiled, linked, and stored separately.. My question is about not about how to create it.. but it is all about in what form it is stored.. ...

Thread behavior on multicore machines

Does the threads of a single process run in parallel on a multi-core machine on windows XP? Is the behavior same on different windows versions (windows server editions) I have heard that only threads ...

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....

热门标签