Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757903AbcDEKIN (ORCPT ); Tue, 5 Apr 2016 06:08:13 -0400 Received: from mail-bl2on0076.outbound.protection.outlook.com ([65.55.169.76]:47232 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757201AbcDEKIK (ORCPT ); Tue, 5 Apr 2016 06:08:10 -0400 Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Subject: Re: [PART1 RFC v3 12/12] svm: Manage vcpu load/unload when enable AVIC To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= References: <1458281388-14452-1-git-send-email-Suravee.Suthikulpanit@amd.com> <1458281388-14452-13-git-send-email-Suravee.Suthikulpanit@amd.com> <20160318214450.GB2332@potion.brq.redhat.com> <56FCE556.80306@amd.com> <20160331141908.GA2171@potion.brq.redhat.com> CC: , , , , , , , , From: Suravee Suthikulpanit Message-ID: <57038E6B.3080808@amd.com> Date: Tue, 5 Apr 2016 17:07:39 +0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160331141908.GA2171@potion.brq.redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [125.24.203.122] X-ClientProxiedBy: SINPR01CA0023.apcprd01.prod.exchangelabs.com (10.141.109.23) To BLUPR12MB0436.namprd12.prod.outlook.com (10.162.92.141) X-MS-Office365-Filtering-Correlation-Id: a8bddb48-c418-40fe-ed27-08d35d3a2e09 X-Microsoft-Exchange-Diagnostics: 1;BLUPR12MB0436;2:HxhMmfNpn7NiruUK9wxXbssvLT2DyJLwUbOcu51vYLrTKZPxV6JgvGx5OgLMR1bqx6rEcHJfn7ujFfgRufyGumbS+LtIkpFVyvrwkHnGVka00aKNoxrOqtMm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AgsiDp7t2+QpFvWn1CsEOBBbsxCxxsLzIi30MS7NkmprLe3sAWdfRJMgmzWayNM4AUoTKgtAthldiyisJsDRKbXiemKqHCcbEYLvUDANz7VST12yOq1H55sK2sM5arLPvLIHwOS78buMakADAENPHrh49XtvLJuSklvqoToxjCdAAVmFTelvTwycmulMHq3HoQfsD6AVzWgroHSwp4/afj4k5238qTT4Nw4El3HKNJ2HSpZC1UaOO+Yg2RXtYCbb6K73sLgBbjPZhUUF71rMAImPTxUx93kFlmqoSLvMem86Ta7v59y3gWB4ZD3kyriiiU8AqQ5fHJmq7SfCRusDW7C3kGCbC0FZWZnAEClt;4:gl9s4ezx/GsgUxZkV4Hym2YGcpb8Zq4BXSSrecOrx5uBoDBYB2I3Ig4RIbRlMxInPI2YZ1EnXCbGV83Z1F9rla52k/HCNXLR9oZ7uUAuFGM+sj1Frn5TN+yT6Z+CowzsHUbCN3HIWO0IaEK6GSuH9yIs01OWbqimKlZ+KH5NB5qWABCey0K7dt+rGGKYFvxvHOzQja5vy8BdBnfNAGyExwmBW+AkQQfxSbnPE+ONts1oroeOm/4p8LP+sdmKn+yGufUnAxiEBWiB7nCya6mJjlS76rXDsfo82UChydOn/FvANJoLQzxKo78GMJK1yGaqhNB0NUifLc/NTaORLMI0t7H7Cpua76NarnD/oVV1epUpzydDKUfuAlS2mjK7KSZ9 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001);SRVR:BLUPR12MB0436;BCL:0;PCL:0;RULEID:;SRVR:BLUPR12MB0436; X-Forefront-PRVS: 0903DD1D85 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(24454002)(377424004)(51444003)(164054003)(51914003)(377454003)(77096005)(2950100001)(5004730100002)(64126003)(83506001)(50466002)(189998001)(93886004)(23676002)(92566002)(33656002)(42186005)(86362001)(81166005)(76176999)(4001350100001)(110136002)(36756003)(65816999)(586003)(6116002)(54356999)(87266999)(3846002)(65956001)(66066001)(65806001)(47776003)(1096002)(2906002)(50986999)(2870700001)(99136001)(5008740100001)(59896002)(4326007);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR12MB0436;H:Suravees-MacBook-Pro.local;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTFVQUjEyTUIwNDM2OzIzOnRaa3E5cEFEMlkvRndpT0hhMlhySW94UGpz?= =?utf-8?B?dkt4MWZ3ajk2TG5hQlo0aVh4UitvS0gzcFVkdHMxMmhYQXo1SFlJYXVpMVgw?= =?utf-8?B?TzIyOUZHUDNQSlhKTW0yN0hZeVV6V0FuTGVMVWpZWVZ5aElUaEJsMUlGWjdh?= =?utf-8?B?dlJKVmZmNFpZU3JxdU0rVUZkVmg0T3lneDlCR3M1WXkzT1M1TUhDMS9qdndM?= =?utf-8?B?L3BVVXdQR2o2eW40bzU2ZWxPUzhodVlvTk5DcEhKL0ZLek9yQmwzSnJhbHda?= =?utf-8?B?c29kb0dOdGRXQjJPTXlYckliNk9tdDRqb053T3ZuZTBkazExSENTd09kKzQ1?= =?utf-8?B?NzcxN0o3OHJkNnF4RG9tbDdSRzgvcTUxdzdxeVB3eWFrYVMydDJMb0tTZXY5?= =?utf-8?B?K3RBN0s3aGJQRVJsbzRZZGFXZTNxc0FzMGMrWm9MOWxQWWVwWGd6NUNUVlJE?= =?utf-8?B?K2UzMzZPSFU4RFAvMGNlVXlYM0tWNmU2bmtwNjZFM09uSjA0b2V3SlhnN2xs?= =?utf-8?B?eVZRSTBZcGdjdFhJdzBEcDRGOCt2TXBidWhvS2hjeXIvblcxZkdKZU9uVTBv?= =?utf-8?B?OEZSbVVObDUxM0xjSmZFeFZ3RE0yeFVxZzVoRHpTYXpKVFpOMlZRZW9JR2Ro?= =?utf-8?B?bENJS1FRbDBueGxPeUYyWmpsdVhpMTJKS0VBQ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B0436;5:jeEnJupSutmyUMQO2g2jTkHxRJKLi9e70GLjv/qZNL/JbpN2xLhkg0QxX3pSI7P26HVkNdS0t2UtgLYRiZlToYSlUuk7B3ghgJ78gQs8WT1tPlAXFo8W+jVPj0v2Y+OekBvs2z06LWkEIqqjqwe33g==;24:8cvqIbsClt5/nwru9gwQEsgY1a6PfsK8sje7rNbetmv5NrM9UO5MeR6ZRPBzw+uo8vRLmNjEcUAq/mneom9xicFmPgh4y6oKSQNr4BnBbrw=;20:WkZZ8DQfuBWGf2pg3K32wVJokNksyK4XpLW4p3JueBzFtJ0bqJYe/CZtsV/cEfF4V9QpHB4IjJKwRxBll27eTEyux2eZmsO/YmyDr/zknABTeKqdFLfazdy6Vvrmw1jLX2KRW01QusqRDCd4qaW7aiaUH0n1X6jSoD7Z3A9gdvEtkvdJ5DrDHIA7eQgk2BXUyCs06lSp39lcQykz9zDT3QXVJst4z4PI+wSXP/+0HdaIRZzuJ47IzhreTv87Uy9y X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2016 10:08:00.7040 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR12MB0436 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2475 Lines: 60 Hi Radim, On 3/31/16 21:19, Radim Krčmář wrote: > 2016-03-31 15:52+0700, Suravee Suthikulpanit: >> On 03/19/2016 04:44 AM, Radim Krčmář wrote: >>> 2016-03-18 01:09-0500, Suravee Suthikulpanit: >>>> + } else { >>>> + new_entry = READ_ONCE(*entry); >>>> + /** >>>> + * This handles the case when vcpu is scheduled out >>>> + * and has not yet not called blocking. We save the >>>> + * AVIC running flag so that we can restore later. >>>> + */ >>> >>> is_running must be disabled in between ...blocking and ...unblocking, >>> because we don't want to miss interrupts and block forever. >>> I somehow don't get it from the comment. :) >> >> Not sure if I understand your concern. However, the is_running bit >> setting/clearing should be handled in the avic_set_running below. This part >> only handles othe case when the is_running bit still set when calling >> vcpu_put (and later on loading some other vcpus). This way, when we are >> re-loading this vcpu, we can restore the is_running bit accordingly. > > I think that the comment is misleading. The saved is_running flag only > matters after svm_vcpu_blocking, yet the comment says that it handles > the irrelevant case before. Actually, my understanding is if the svm_vcpu_blocking() is called, the is_running bit would have been cleared. At this point, if the vcpu is unloaded. We should not need to worry about it. Is that not the case here? > Another minor bug is that was_running isn't initialized to 1, so we need > to halt before is_running gets set. Just to make sure, you are referring to the point where the is_running is not set for first time the vcpu is loaded? If so, I agree. Thanks for the good catch. > It would be clearer to toggle a flag in svm_vcpu_(un)blocking and set > is_running = !is_blocking. Not sure what you meant here. We are already setting/unsetting the is_running bit when vcpu is blocking/unblocking. Are you suggesting just simply move the current avic_set_running() into the svm_vcpu_blocking and svm_vcpu_unblocking()? > Doing so will also be immeasurably faster, > because avic_vcpu_load is called far more than svm_vcpu_(un)blocking. Actually, this is not the same as handling normal vcpu blocking and unblocking, which we are already setting/un-setting the is_running bit in the avic_set_running(). The was_running should only be set to 1 if the vcpu is unloaded but has not yet calling halt. Am I missing your points somehow? Thanks, Suravee