From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 7A54EC43461 for ; Tue, 8 Sep 2020 07:10:30 +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 C02332078E for ; Tue, 8 Sep 2020 07:10:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C02332078E 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]:56796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kFXls-0002PB-Sw for qemu-devel@archiver.kernel.org; Tue, 08 Sep 2020 03:10:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFXlM-0001y5-Hi for qemu-devel@nongnu.org; Tue, 08 Sep 2020 03:09:56 -0400 Received: from mx2.suse.de ([195.135.220.15]:57700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFXlK-0001Ov-Rt for qemu-devel@nongnu.org; Tue, 08 Sep 2020 03:09:56 -0400 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 5CDA7AB8B; Tue, 8 Sep 2020 07:09:54 +0000 (UTC) Subject: Re: [PULL 3/5] softmmu/cpus: Only set parallel_cpus for SMP To: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= References: <20200903214101.1746878-1-richard.henderson@linaro.org> <20200903214101.1746878-4-richard.henderson@linaro.org> <1f573d2d-b3bb-21ab-bbcd-b759fc14ad2b@suse.de> <3dfae924-34c9-e36a-77bf-f3abcdeaf268@amsat.org> <7454d121-3ebd-623a-55a3-4ba6e7e870dc@suse.de> From: Claudio Fontana Message-ID: <75c313df-da09-f3c2-5d34-0bfaad4290a9@suse.de> Date: Tue, 8 Sep 2020 09:09:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: 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-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/08 00:22:31 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x (no timestamps) [generic] X-Spam_score_int: -59 X-Spam_score: -6.0 X-Spam_bar: ------ X-Spam_report: (-6.0 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-1.825, 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: peter.maydell@linaro.org, Richard Henderson , qemu-devel@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 9/7/20 6:49 PM, Philippe Mathieu-Daudé wrote: > On 9/7/20 6:30 PM, Claudio Fontana wrote: >> On 9/7/20 12:20 PM, Philippe Mathieu-Daudé wrote: >>> On 9/7/20 12:05 PM, Claudio Fontana wrote: >>>> Hi Richard, >>>> >>>> currently rebasing on top of this one, >>>> just a question, why is the patch not directly using "current_machine"? >>> >>> For user mode? >> >> In user mode I'd not expect softmmu/cpus.c to be built at all... > > Which is why :) current_machine is NULL in user-mode. Ciao Philippe, then why does the patch change softmmu/cpus.c in a way that accounts for user mode? The function that the patch changes is never called in user mode. The patch could instead use current_machine without any concern of it being NULL, it will always be set in vl.c . Ciao, Claudio > >> >> Ciao, >> >> Claudio >> >>> >>>> >>>> Is using MACHINE(qdev_get_machine()) preferrable here? >>>> >>>> Thanks, >>>> >>>> Claudio >>>> >>>> On 9/3/20 11:40 PM, Richard Henderson wrote: >>>>> Do not set parallel_cpus if there is only one cpu instantiated. >>>>> This will allow tcg to use serial code to implement atomics. >>>>> >>>>> Reviewed-by: Philippe Mathieu-Daudé >>>>> Signed-off-by: Richard Henderson >>>>> --- >>>>> softmmu/cpus.c | 11 ++++++++++- >>>>> 1 file changed, 10 insertions(+), 1 deletion(-) >>>>> >>>>> diff --git a/softmmu/cpus.c b/softmmu/cpus.c >>>>> index a802e899ab..e3b98065c9 100644 >>>>> --- a/softmmu/cpus.c >>>>> +++ b/softmmu/cpus.c >>>>> @@ -1895,6 +1895,16 @@ static void qemu_tcg_init_vcpu(CPUState *cpu) >>>>> if (!tcg_region_inited) { >>>>> tcg_region_inited = 1; >>>>> tcg_region_init(); >>>>> + /* >>>>> + * If MTTCG, and we will create multiple cpus, >>>>> + * then we will have cpus running in parallel. >>>>> + */ >>>>> + if (qemu_tcg_mttcg_enabled()) { >>>>> + MachineState *ms = MACHINE(qdev_get_machine()); >>>> >>>> MachineState *ms = current_machine; >>>> ? >>>> >>>> >>>>> + if (ms->smp.max_cpus > 1) { >>>>> + parallel_cpus = true; >>>>> + } >>>>> + } >>>>> } >>>>> >>>>> if (qemu_tcg_mttcg_enabled() || !single_tcg_cpu_thread) { >>>>> @@ -1904,7 +1914,6 @@ static void qemu_tcg_init_vcpu(CPUState *cpu) >>>>> >>>>> if (qemu_tcg_mttcg_enabled()) { >>>>> /* create a thread per vCPU with TCG (MTTCG) */ >>>>> - parallel_cpus = true; >>>>> snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/TCG", >>>>> cpu->cpu_index); >>>>> >>>>> >>>> >>>> >> >>