From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH v2 9/9] KVM: MMU: Avoid access/dirty update loop if all is well Date: Wed, 19 Sep 2012 19:12:20 +0300 Message-ID: <5059EEE4.4080802@redhat.com> References: <1347797235-20732-1-git-send-email-avi@redhat.com> <1347797235-20732-10-git-send-email-avi@redhat.com> <50582110.4070506@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Xiao Guangrong Return-path: Received: from mx1.redhat.com ([209.132.183.28]:10392 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756526Ab2ISQMi (ORCPT ); Wed, 19 Sep 2012 12:12:38 -0400 In-Reply-To: <50582110.4070506@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On 09/18/2012 10:21 AM, Xiao Guangrong wrote: > On 09/16/2012 08:07 PM, Avi Kivity wrote: > >> + /* >> + * On a write fault, fold the dirty bit into accessed_dirty by shifting it one >> + * place right. >> + * >> + * On a read fault, do nothing. >> + */ >> + accessed_dirty &= pte >> (write_fault >> ilog2(PFERR_WRITE_MASK)); > > It is too trick: it depends on DIRTY_SHIFT = ACCESSED_SHIFT + 1. How about change it > to: > accessed_dirty &= pte >> (!!write_fault >> (DIRTY_SHIFT - ACCESSED_SHIFT)) ? !! forces a branch, unless gcc is really clever. So I changed it to shift = write_fault >> ilog2(PFERR_WRITE_MASK); shift *= PT_DIRTY_SHIFT - PT_ACCESSED_SHIFT; accessed_dirty &= pte >> shift; which should result in the same code. -- error compiling committee.c: too many arguments to function