Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751665AbbEFTn0 (ORCPT ); Wed, 6 May 2015 15:43:26 -0400 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 Message-ID: <554A6ED4.3010900@redhat.com> Date: Wed, 06 May 2015 21:43:16 +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, bsd@redhat.com, guangrong.xiao@linux.intel.com, Yang Zhang , wanpeng.li@linux.intel.com Subject: Re: [PATCH 12/13] KVM: x86: add KVM_MEM_X86_SMRAM memory slot flag 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> In-Reply-To: <20150506162437.GA27205@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 Content-Length: 1455 Lines: 32 On 06/05/2015 18:24, Radim Krčmář wrote: > The feature you wanted exposed a flaw in the code, so an extension was > 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. There are cases even on x86 where you have no vcpu, for example filling 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/