From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 12/13] KVM: x86: add KVM_MEM_X86_SMRAM memory slot flag Date: Wed, 06 May 2015 21:43:16 +0200 Message-ID: <554A6ED4.3010900@redhat.com> References: <1430393772-27208-1-git-send-email-pbonzini@redhat.com> <1430393772-27208-13-git-send-email-pbonzini@redhat.com> <20150505171747.GB17198@potion.brq.redhat.com> <5549E337.1090606@redhat.com> <20150506162437.GA27205@potion.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, bsd@redhat.com, guangrong.xiao@linux.intel.com, Yang Zhang , wanpeng.li@linux.intel.com To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Return-path: Received: from mx1.redhat.com ([209.132.183.28]:41274 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750995AbbEFTnY (ORCPT ); Wed, 6 May 2015 15:43:24 -0400 In-Reply-To: <20150506162437.GA27205@potion.brq.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 06/05/2015 18:24, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: > The feature you wanted exposed a flaw in the code, so an extension wa= s > needed. Copying code is the last resort after all options of > abstracting were exhausted ... I might be forcing common paths when > writing it twice requires less brain power, but 200 lines of > structurally identical code seem far from it. Note that it didn't really expose a flaw in the code, just a limitation= =2E There are cases even on x86 where you have no vcpu, for example fillin= g in the EPT identity page tables or VMX TSS. > Reworking stable code is simpler, as we can just cover all features > needed now and omit the hard thinking about future extensions. > (For me, stable code is the first candidate for generalization ... > and I wouldn't copy it, even though it's mostly fine in practice.) Stable simple code is also important to keep simple though. Sometimes code duplication is preferrable to obfuscation. I agree that copying 200 lines of code because of one function three levels down the call chain isn't nice. However, it doesn't seem particularly easy to avoid the duplication even with C++ templates. C is worse. OCaml or Haskell would be nicer. :) Paolo