From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH v2 9/9] KVM: MMU: Avoid access/dirty update loop if all is well Date: Tue, 18 Sep 2012 15:21:52 +0800 Message-ID: <50582110.4070506@linux.vnet.ibm.com> References: <1347797235-20732-1-git-send-email-avi@redhat.com> <1347797235-20732-10-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from e28smtp05.in.ibm.com ([122.248.162.5]:49620 "EHLO e28smtp05.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757045Ab2IRHWB (ORCPT ); Tue, 18 Sep 2012 03:22:01 -0400 Received: from /spool/local by e28smtp05.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 18 Sep 2012 12:51:58 +0530 Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8I7LuQN52887720 for ; Tue, 18 Sep 2012 12:51:56 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q8I7LtVY014512 for ; Tue, 18 Sep 2012 17:21:55 +1000 In-Reply-To: <1347797235-20732-10-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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)) ? Otherwise looks good to me. Reviewed-by: Xiao Guangrong