All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Nitesh Narayan Lal <nitesh@redhat.com>,
	kvm@vger.kernel.org, pbonzini@redhat.com
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
	thuth@redhat.com, nilal@redhat.com
Subject: Re: [Patch v1] x86: Fix the logical destination mode test
Date: Tue, 14 Apr 2020 16:01:07 +0200	[thread overview]
Message-ID: <878siyyxng.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <4993e419-5eef-46ba-5dd0-e35c7103190b@redhat.com>

Nitesh Narayan Lal <nitesh@redhat.com> writes:

> On 3/10/20 10:03 AM, Marcelo Tosatti wrote:
>> On Mon, Mar 09, 2020 at 07:15:50PM -0400, Nitesh Narayan Lal wrote:
>>> There are following issues with the ioapic logical destination mode test:
>>>
>>> - A race condition that is triggered when the interrupt handler
>>>   ioapic_isr_86() is called at the same time by multiple vCPUs. Due to this
>>>   the g_isr_86 is not correctly incremented. To prevent this a spinlock is
>>>   added around ‘g_isr_86++’.
>>>
>>> - On older QEMU versions initial x2APIC ID is not set, that is why
>>>   the local APIC IDs of each vCPUs are not configured. Hence the logical
>>>   destination mode test fails/hangs. Adding ‘+x2apic’ to the qemu -cpu params
>>>   ensures that the local APICs are configured every time, irrespective of the
>>>   QEMU version.
>>>
>>> - With ‘-machine kernel_irqchip=split’ included in the ioapic test
>>>   test_ioapic_self_reconfigure() always fails and somehow leads to a state where
>>>   after submitting IOAPIC fixed delivery - logical destination mode request we
>>>   never receive an interrupt back. For now, the physical and logical destination
>>>   mode tests are moved above test_ioapic_self_reconfigure().
>>>
>>> Fixes: b2a1ee7e ("kvm-unit-test: x86: ioapic: Test physical and logical destination mode")
>>> Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com>
>> Looks good to me.
>
> Hi,
>
> I just wanted to follow up and see if there are any more suggestions for me to
> improve this patch before it can be merged.
>
>
>>
>>> ---
>>>  x86/ioapic.c      | 11 +++++++----
>>>  x86/unittests.cfg |  2 +-
>>>  2 files changed, 8 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/x86/ioapic.c b/x86/ioapic.c
>>> index 742c711..3106531 100644
>>> --- a/x86/ioapic.c
>>> +++ b/x86/ioapic.c
>>> @@ -432,10 +432,13 @@ static void test_ioapic_physical_destination_mode(void)
>>>  }
>>>  
>>>  static volatile int g_isr_86;
>>> +struct spinlock ioapic_lock;
>>>  
>>>  static void ioapic_isr_86(isr_regs_t *regs)
>>>  {
>>> +	spin_lock(&ioapic_lock);
>>>  	++g_isr_86;
>>> +	spin_unlock(&ioapic_lock);
>>>  	set_irq_line(0x0e, 0);
>>>  	eoi();
>>>  }
>>> @@ -501,6 +504,10 @@ int main(void)
>>>  	test_ioapic_level_tmr(true);
>>>  	test_ioapic_edge_tmr(true);
>>>  
>>> +	test_ioapic_physical_destination_mode();

I just found out that this particular change causes 'ioapic-split' test
to hang reliably: 

# ./run_tests.sh ioapic-split
FAIL ioapic-split (timeout; duration=90s)
PASS ioapic (26 tests)

unlike 'ioapic' test we run it with '-smp 1' and
'test_ioapic_physical_destination_mode' requires > 1 CPU to work AFAICT.

Why do we move it from under 'if (cpu_count() > 1)' ?

Also, this patch could've been split.

>>> +	if (cpu_count() > 3)
>>> +		test_ioapic_logical_destination_mode();
>>> +
>>>  	if (cpu_count() > 1) {
>>>  		test_ioapic_edge_tmr_smp(false);
>>>  		test_ioapic_level_tmr_smp(false);
>>> @@ -508,11 +515,7 @@ int main(void)
>>>  		test_ioapic_edge_tmr_smp(true);
>>>  
>>>  		test_ioapic_self_reconfigure();
>>> -		test_ioapic_physical_destination_mode();
>>>  	}
>>>  
>>> -	if (cpu_count() > 3)
>>> -		test_ioapic_logical_destination_mode();
>>> -
>>>  	return report_summary();
>>>  }
>>> diff --git a/x86/unittests.cfg b/x86/unittests.cfg
>>> index f2401eb..d658bc8 100644
>>> --- a/x86/unittests.cfg
>>> +++ b/x86/unittests.cfg
>>> @@ -46,7 +46,7 @@ timeout = 30
>>>  [ioapic]
>>>  file = ioapic.flat
>>>  smp = 4
>>> -extra_params = -cpu qemu64
>>> +extra_params = -cpu qemu64,+x2apic
>>>  arch = x86_64
>>>  
>>>  [cmpxchg8b]
>>> -- 
>>> 1.8.3.1

-- 
Vitaly


  parent reply	other threads:[~2020-04-14 14:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1583795750-33197-1-git-send-email-nitesh@redhat.com>
2020-03-09 23:25 ` [Patch v1] x86: Fix the logical destination mode test Nitesh Narayan Lal
2020-03-10 14:03 ` Marcelo Tosatti
2020-03-16 22:27   ` Nitesh Narayan Lal
2020-03-17 15:43     ` Paolo Bonzini
2020-04-14 14:01     ` Vitaly Kuznetsov [this message]
2020-04-14 15:14       ` Nitesh Narayan Lal
2020-04-14 15:30         ` Vitaly Kuznetsov
2020-04-14 15:34           ` Nitesh Narayan Lal
2020-04-14 16:11             ` Vitaly Kuznetsov
2020-04-14 16:27               ` Nitesh Narayan Lal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878siyyxng.fsf@vitty.brq.redhat.com \
    --to=vkuznets@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=nilal@redhat.com \
    --cc=nitesh@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.