From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753376AbbDHMXO (ORCPT ); Wed, 8 Apr 2015 08:23:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57563 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751300AbbDHMXL (ORCPT ); Wed, 8 Apr 2015 08:23:11 -0400 Message-ID: <55251DAA.7000507@redhat.com> Date: Wed, 08 Apr 2015 14:23:06 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= CC: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH] KVM: use slowpath for cross page cached accesses References: <1428438897-22206-1-git-send-email-rkrcmar@redhat.com> <5524EBB7.3080906@redhat.com> <20150408092611.GA2164@potion.brq.redhat.com> <55250643.3090402@redhat.com> <20150408121648.GA3519@potion.brq.redhat.com> In-Reply-To: <20150408121648.GA3519@potion.brq.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/04/2015 14:16, Radim Krčmář wrote: > 2015-04-08 12:43+0200, Paolo Bonzini: >> On 08/04/2015 11:26, Radim Krčmář wrote: >>> Only cross-memslot writes have NULL memslot. >> >> The power of wrong comments... >> >> Considering how kvm_gfn_to_hva_cache_init is used (one 1-byte field, two >> 4-byte fields, one 28-bytes struct that is 32-bytes aligned, one >> 32-bytes field that is in practice cacheline-aligned), I wonder if we >> should just use ghc->memslot = NULL for cross page writes. This would >> bypass the bug you are fixing here, and avoid worries about partial writes. > > Good idea, and it could make those comments right :) > (Though in general, I prefer less constraints on APIs ...) It doesn't put constraints, it still handles cross page writes right (just slower). copy_to_user in some sense is the API that constrains us to do this. > Partial writes would be a pain; copy_to_user API does not define which > bytes were not written. I think the write can't fail mid-page, which > makes our implementation ok No, writes can't fail mid-page (I guess in atomic context it's theoretically possible, but we're equipped to handle the failure in that case). Patch applied, thanks! Paolo