Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1829057imu; Wed, 12 Dec 2018 05:10:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/XoMZMy2Oo41phNBfY/9VZCWTq3s5XtpRSmoNyBPRS46/rv0VzbB628nLfjnmGdujKOIZIh X-Received: by 2002:a17:902:bd0b:: with SMTP id p11mr19988096pls.259.1544620225404; Wed, 12 Dec 2018 05:10:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544620225; cv=none; d=google.com; s=arc-20160816; b=ARqs6VSlXNxmBB77mawQUGOs6p+PRPgGkAM3nwsAPmDy5EzoW9xZtI0pKgxsXB921+ oIRtcVqvugEaBGex5LkzhnQlcNGi/Pd8PKqs3WC5I2o7grV0elXOQr9FSPxyn9r+FoPZ jaLAZfl/gqQwr4IQRjAm7tOboGVYQVu0h0lsrmibKTr/F6+JTJYiZ8Hwkz6re5pUXxpG thsaGDFlpg9HFZ0qAZWXEJEqeU7npNVQFJXXVRtjqhAhDWkd7XeuAwXC1iK4ZffRmWrK qH6u5RNoqUGbHxA6E71MQX80ll4bRXgz7YSg2BmMo9YuSvB1Vfsc8MoWjPhxHsI9unCU cX7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=qX8dbIB98u3LpEf2+fTm68JGxdDsmIF9mCwkCFHOJt0=; b=VKqdhDwnHIEBTgSm6M8SRudvyHyLTWChwymxwKUInNNaO08he3v4KqhtfPaxQgT68K Vrvxm/kRYRPfXZ5tGjgTv8SHbQrJJLO8CKqX3316zEJM5Rq0pEi8Zr4lFydU9vMa/qDg VFUuJpMaqDhd9vju5unDuzLXK6Q4oSSo+LdZorQfscuesLPOnsJndg4cW/4fekhgBBNJ du8KFd2O6oX3xr7AUxMRInyNaRCZSdbvOpYjhkJnCQ3GRkADRQ0Jz91+g5qi1TFuN13a oWDXuiz2IltGh1PiXuFHGcyX1H1yWdSg7DASsCSIVqk67wMQ4jK2NkFTdSIwVI7rtaAu 7YsQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e125si15707196pfe.14.2018.12.12.05.10.10; Wed, 12 Dec 2018 05:10:25 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727551AbeLLNJR (ORCPT + 99 others); Wed, 12 Dec 2018 08:09:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35074 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726741AbeLLNJQ (ORCPT ); Wed, 12 Dec 2018 08:09:16 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2F62D821CC; Wed, 12 Dec 2018 13:09:16 +0000 (UTC) Received: from vitty.brq.redhat.com.redhat.com (unknown [10.34.244.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01BA01054FCC; Wed, 12 Dec 2018 13:09:14 +0000 (UTC) From: Vitaly Kuznetsov To: Roman Kagan , Paolo Bonzini Cc: "kvm\@vger.kernel.org" , Radim =?utf-8?B?S3LEjW0=?= =?utf-8?B?w6HFmQ==?= , "linux-kernel\@vger.kernel.org" Subject: Re: [PATCH] x86/hyper-v: Stop caring about EOI for direct stimers In-Reply-To: <20181210183918.GB13294@rkaganb.sw.ru> References: <20181205153621.14343-1-vkuznets@redhat.com> <20181210183918.GB13294@rkaganb.sw.ru> Date: Wed, 12 Dec 2018 14:09:13 +0100 Message-ID: <874lbi28p2.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 12 Dec 2018 13:09:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Roman Kagan writes: > [ Sorry, missed this one ] > > On Wed, Dec 05, 2018 at 04:36:21PM +0100, Vitaly Kuznetsov wrote: >> Turns out we over-engineered Direct Mode for stimers a bit: unlike >> traditional stimers where we may want to try to re-inject the message upon >> EOI, Direct Mode stimers just set the irq in APIC and kvm_apic_set_irq() >> fails only when APIC is disabled (see APIC_DM_FIXED case in >> __apic_accept_irq()). Remove the redundant part. >> >> Suggested-by: Roman Kagan >> Signed-off-by: Vitaly Kuznetsov >> --- >> arch/x86/kvm/hyperv.c | 36 +++--------------------------------- >> 1 file changed, 3 insertions(+), 33 deletions(-) >> >> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c >> index e6a2a085644a..0a16a77e6ac3 100644 >> --- a/arch/x86/kvm/hyperv.c >> +++ b/arch/x86/kvm/hyperv.c >> @@ -56,21 +56,8 @@ static inline int synic_get_sint_vector(u64 sint_value) >> static bool synic_has_vector_connected(struct kvm_vcpu_hv_synic *synic, >> int vector) >> { >> - struct kvm_vcpu *vcpu = synic_to_vcpu(synic); >> - struct kvm_vcpu_hv *hv_vcpu = vcpu_to_hv_vcpu(vcpu); >> - struct kvm_vcpu_hv_stimer *stimer; >> int i; >> >> - for (i = 0; i < ARRAY_SIZE(hv_vcpu->stimer); i++) { >> - stimer = &hv_vcpu->stimer[i]; >> - if (stimer->config.enable && stimer->config.direct_mode && >> - stimer->config.apic_vector == vector) >> - return true; >> - } >> - >> - if (vector < HV_SYNIC_FIRST_VALID_VECTOR) >> - return false; >> - >> for (i = 0; i < ARRAY_SIZE(synic->sint); i++) { >> if (synic_get_sint_vector(synic_read_sint(synic, i)) == vector) >> return true; >> @@ -96,14 +83,14 @@ static bool synic_has_vector_auto_eoi(struct kvm_vcpu_hv_synic *synic, >> static void synic_update_vector(struct kvm_vcpu_hv_synic *synic, >> int vector) >> { >> + if (vector < HV_SYNIC_FIRST_VALID_VECTOR) >> + return; >> + >> if (synic_has_vector_connected(synic, vector)) >> __set_bit(vector, synic->vec_bitmap); >> else >> __clear_bit(vector, synic->vec_bitmap); >> >> - if (vector < HV_SYNIC_FIRST_VALID_VECTOR) >> - return; >> - >> if (synic_has_vector_auto_eoi(synic, vector)) >> __set_bit(vector, synic->auto_eoi_bitmap); >> else >> @@ -382,9 +369,7 @@ int kvm_hv_synic_set_irq(struct kvm *kvm, u32 vpidx, u32 sint) >> >> void kvm_hv_synic_send_eoi(struct kvm_vcpu *vcpu, int vector) >> { >> - struct kvm_vcpu_hv *hv_vcpu = vcpu_to_hv_vcpu(vcpu); >> struct kvm_vcpu_hv_synic *synic = vcpu_to_synic(vcpu); >> - struct kvm_vcpu_hv_stimer *stimer; >> int i; >> >> trace_kvm_hv_synic_send_eoi(vcpu->vcpu_id, vector); >> @@ -392,14 +377,6 @@ void kvm_hv_synic_send_eoi(struct kvm_vcpu *vcpu, int vector) >> for (i = 0; i < ARRAY_SIZE(synic->sint); i++) >> if (synic_get_sint_vector(synic_read_sint(synic, i)) == vector) >> kvm_hv_notify_acked_sint(vcpu, i); >> - >> - for (i = 0; i < ARRAY_SIZE(hv_vcpu->stimer); i++) { >> - stimer = &hv_vcpu->stimer[i]; >> - if (stimer->msg_pending && stimer->config.enable && >> - stimer->config.direct_mode && >> - stimer->config.apic_vector == vector) >> - stimer_mark_pending(stimer, false); >> - } >> } >> >> static int kvm_hv_set_sint_gsi(struct kvm *kvm, u32 vpidx, u32 sint, int gsi) >> @@ -566,8 +543,6 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer) >> static int stimer_set_config(struct kvm_vcpu_hv_stimer *stimer, u64 config, >> bool host) >> { >> - struct kvm_vcpu *vcpu = stimer_to_vcpu(stimer); >> - struct kvm_vcpu_hv *hv_vcpu = vcpu_to_hv_vcpu(vcpu); >> union hv_stimer_config new_config = {.as_uint64 = config}, >> old_config = {.as_uint64 = stimer->config.as_uint64}; >> >> @@ -580,11 +555,6 @@ static int stimer_set_config(struct kvm_vcpu_hv_stimer *stimer, u64 config, >> new_config.enable = 0; >> stimer->config.as_uint64 = new_config.as_uint64; >> >> - if (old_config.direct_mode) >> - synic_update_vector(&hv_vcpu->synic, old_config.apic_vector); >> - if (new_config.direct_mode) >> - synic_update_vector(&hv_vcpu->synic, new_config.apic_vector); >> - >> stimer_mark_pending(stimer, false); >> return 0; >> } > > As discussed in another thread, it seems worth while to make > stimer_set_config reject vectors 0..15. > > Besides I'd rather sqwash this patch into the one that introduced direct > timers, before it reached Linus' tree. I'm fine either way, I'm going to send v2 with a new patch adding the check to stimer_set_config() and leave it up to Paolo if he would want to squash them all together before sending to Linus. (Actually I don't see direct stimers in kvm/queue but I think I heard 'queued' from Paolo...) -- Vitaly