Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp159587imm; Thu, 30 Aug 2018 10:42:27 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYJPYi2nxZYR7P32B6Pagbnu6w35xKwwjhQp8pCdZs6dfEN3J0Fn5D1STIPSbKO0SIARkDC X-Received: by 2002:a17:902:988a:: with SMTP id s10-v6mr10852034plp.200.1535650947275; Thu, 30 Aug 2018 10:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535650947; cv=none; d=google.com; s=arc-20160816; b=KWGd78wcieFWLU4n8Cs1rbpwR5n5H5biHdDO56k6ToyjZ6KwsbZSjRoW05nfLwZb9+ xVCai161C+vQ03q9Cq90UBtBI61amIywj1DZLPSXBwUTO67LC+xwtHs/w7MyxVeQlN3B e0Q9cvv2BxWDutRzP8InMp/kpgke5FEzxYDioyqpOawaYa8Qib1wKLPM2uAH3Rm2ZQBM sIYQsjw6eVJZJ5xQKOOOjLXshzjWMDzk2RFoR2IOkCEpxlZpiEy5VxVI3ZwdPC7PNvBv 9y5D4PovjVaAlGZPqADoKqQFeSSpBQCad0XY2ee1T+Za5nGFyzUbsL0oET31/3WlWzPJ yMvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from:arc-authentication-results; bh=JryUwmHiLcsPQvaq14FRzvNU3DsRctymch69q6eCe6A=; b=ThG4jtTeYtKzX2FksIFgqszl+XNLO+2r+Tnhm8wSSqjIgybCYZqqw9PA1ITM5Vjmoi ZOqNurfaVSw8nonLSloNigwhec88AdaRrnC9fF0CldRbOujAer5k2sKkCvCYqLo42RdA f0Str0drgwMjB0MvWBNnKpsMAjbYNFA8BWsfCshhPy9tdrh6GYClueYfn9NHn2hBcUKQ dajlEpfUgiefI8L5PB5Dd7j7fLS3yn+A/gQUjqrMyRLFaG9dUtoVK+IWXJgvkRgThwMm 1dqJlwg2G4WbWkkECqRLXHv+ubVUp1EdH/lJx+8otlyhy3UXP6QNe3kw9QAge4Dr+fcp dS7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t80-v6si7660427pfk.228.2018.08.30.10.42.12; Thu, 30 Aug 2018 10:42:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727266AbeH3VoP (ORCPT + 99 others); Thu, 30 Aug 2018 17:44:15 -0400 Received: from smtp20.cstnet.cn ([159.226.251.20]:52855 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725998AbeH3VoO (ORCPT ); Thu, 30 Aug 2018 17:44:14 -0400 Received: from [192.168.1.2] (unknown [110.184.153.119]) by APP-10 (Coremail) with SMTP id tACowAC3vsYWLIhbYUWxBQ--.111S2; Fri, 31 Aug 2018 01:40:39 +0800 (CST) From: Pu Wen Subject: Re: [PATCH v5 01/16] x86/cpu: create Dhyana init file and register new cpu_dev to system To: Andi Kleen Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, thomas.lendacky@amd.com, bp@alien8.de, pbonzini@redhat.com, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org References: <87mut52cf4.fsf@linux.intel.com> Message-ID: <65c91fb2-4b57-8ddb-3363-ac6fe69957b9@hygon.cn> Date: Fri, 31 Aug 2018 01:40:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <87mut52cf4.fsf@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-CM-TRANSID: tACowAC3vsYWLIhbYUWxBQ--.111S2 X-Coremail-Antispam: 1UD129KBjvJXoW7trWxtF15Kr4UJr1xCw1Utrb_yoW8Ww1kpa 1UWr1Fyr4ktrWfAr1xu3y8WFy09ws5Jr48C34YgrW8t3yYvw1q9wnagFyfZ343ArsYgay2 vrWUXa17t3Z0yaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBI14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Jr0_Gr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4j6r 4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcVAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kI c2xKxwCYjI0SjxkI62AI1cAE67vIY487MxkF7I0Ew4C26cxK6c8Ij28IcwCF04k20xvY0x 0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E 7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcV C0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF 04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aV CY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUj0JPtUUUUU== X-Originating-IP: [110.184.153.119] X-CM-SenderInfo: psxzv046klw03qof0z/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-08-30 03:35, Andi Kleen wrote: >Pu Wen writes: >> Add x86 architecture support for new processor Hygon Dhyana Family 18h. >> Rework to create a separated file(arch/x86/kernel/cpu/hygon.c) from the >> AMD init one(arch/x86/kernel/cpu/amd.c) to initialize Dhyana CPU. > >Standard approach would be to move the shared code into a different >file and call it from both amd.c and hygon.c instead of duplicating. Hi Andi, Thanks for your feedback. As Hygon Dhyana arch originate from AMD, we share most arch codes with AMD. In our first patch v1, we direct reuse AMD's init codes in amd.c, which can work out a minimal patch. But the code mixture between AMD and Hygon occur, which might cause problem in long term. To reduce long term maintaining effort, we reworked the patch and do the arch code duplication and removed unnecessary old arch support code/family condition check, which reduce code size to 37%, and give a clear view for hygon arch initialize flow. For long term, it also remove code modification interference between AMD and Hygon, make hygon code easy to modify for it's further products. That's the patch since v2. We did try the standard approach as you suggested between v1 and v2 internally, and found out it's hard to find a clear version. Because amd.c has many family checking to support it's multiple family products, which make the common function strip difficult. Also based on the consideration of common functions also might interference with each other, we finally choose the patch v2 style. It's hard to find a best way between code duplication and code reuse. Any suggestion please let us know. Regards, Pu Wen