Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1685FC433E0 for ; Thu, 4 Feb 2021 10:38:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5C2E964F5E for ; Thu, 4 Feb 2021 10:38:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C2E964F5E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7c1r-00049y-Bi for qemu-devel@archiver.kernel.org; Thu, 04 Feb 2021 05:38:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7bno-00073Y-K2 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 05:23:56 -0500 Received: from mx2.suse.de ([195.135.220.15]:43822) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7bnm-0002lp-Sc for qemu-devel@nongnu.org; Thu, 04 Feb 2021 05:23:56 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0FB49B004; Thu, 4 Feb 2021 10:23:53 +0000 (UTC) Subject: Re: [PATCH v15 21/23] hw/core/cpu: call qemu_init_vcpu in cpu_common_realizefn To: =?UTF-8?Q?Alex_Benn=c3=a9e?= References: <20210201100903.17309-1-cfontana@suse.de> <20210201100903.17309-22-cfontana@suse.de> <871rdxrt08.fsf@linaro.org> From: Claudio Fontana Message-ID: <7500a412-c94a-6990-eb48-9ee78bfb94e3@suse.de> Date: Thu, 4 Feb 2021 11:23:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <871rdxrt08.fsf@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=195.135.220.15; envelope-from=cfontana@suse.de; helo=mx2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.178, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Eduardo Habkost , Richard Henderson , qemu-devel@nongnu.org, Roman Bolshakov , Alistair Francis , Paolo Bonzini , =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 2/3/21 5:51 PM, Alex Bennée wrote: > > Claudio Fontana writes: > >> move the call to qemu_init_vcpu inside cpu_common_realizefn, >> so it does not need to be done explicitly in each target cpu. >> >> Despite this, the way cpu realize is done continues to be not ideal; >> >> ideally the cpu_list_add would be done in common_cpu, >> and in this case we could avoid even more redundant open coded >> additional calls in target/xxx/cpu.c, >> >> but this cannot happen because target cpu code, plugins, etc >> now all came to rely on cpu->index >> (which is updated in cpu_list_add), since no particular order >> was defined previously, so we are stuck with the freak call >> order for the target cpu realizefn. >> >> After this patch the target/xxx/cpu.c realizefn body becomes: >> >> void mycpu_realizefn(DeviceState *dev, Error **errp) >> { >> /* ... */ >> cpu_exec_realizefn(CPU_STATE(dev), errp); >> >> /* ... anything that needs done pre-qemu_vcpu_init */ >> >> xcc->parent_realize(dev, errp); /* does qemu_vcpu_init */ >> >> /* ... anything that needs to be done after qemu_vcpu_init */ >> } > > Uggh, introducing a magic order seems like inviting trouble for later > on. Is there anyway we can improve things? Paolo? > The magic order is there already. I call it "freak order" instead of "magic", because this is more the result of uncontrolled code growth rather than the work of magic :-) This patch attempts to remove one degree of freedom, but the current situation of cpu realizing is basically fubar. This patch attempts to improve things slightly, but as mentioned elsewhere it basically fails to achieve the goal, so I am tempted to just retire it. Maybe someone interested could look at the situation with new eyes (possibly even me later on). Ciao, Claudio