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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3A731C7618A for ; Mon, 20 Mar 2023 12:57:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1peF44-000860-N8; Mon, 20 Mar 2023 08:56:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1peF43-00084c-D6 for qemu-devel@nongnu.org; Mon, 20 Mar 2023 08:56:39 -0400 Received: from smtp-out2.suse.de ([2001:67c:2178:6::1d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1peF41-0003Fz-A0 for qemu-devel@nongnu.org; Mon, 20 Mar 2023 08:56:39 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BDE051F85D; Mon, 20 Mar 2023 12:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1679316995; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RjCQJ/UQYvvlLzZp5zQcmIqh+zxkGzMx9IjQROA6R/8=; b=eI7XYgDm1UA5ya1TV6EVmi3G5lcxJRhUOC3eWj9DuI4LvjkzozO+qy0ZIk8OfLeNDLjcU6 xaAGcm4EHkpk6H9vF79Xq1Sg3EJVWC4xDp+S1PVUc5gaw/Z14rkLFOESdF2XAHxZS/7zJZ AB29fprDpFjjUg//1DkrUNSsq0bguA8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1679316995; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RjCQJ/UQYvvlLzZp5zQcmIqh+zxkGzMx9IjQROA6R/8=; b=o9a6huPkuNtqCtWoYn1GeZLeZoqMR8/pN94QxgM6KpuoPpZzhNzH5eV1ayUpiTiBwC9aXu csDbYyqEZpyPtlCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 756D513A00; Mon, 20 Mar 2023 12:56:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AkT9GgNYGGSTbAAAMHmgww (envelope-from ); Mon, 20 Mar 2023 12:56:35 +0000 Message-ID: Date: Mon, 20 Mar 2023 13:56:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH 02/10] accel/tcg: move cpu_reloading_memory_map into cpu-exec-softmmu Content-Language: en-US To: =?UTF-8?Q?Alex_Benn=c3=a9e?= , Alessandro Di Federico , =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , qemu-devel@nongnu.org Cc: Richard Henderson , Paolo Bonzini , Eduardo Habkost , Fabiano Rosas References: <20230320101035.2214196-1-alex.bennee@linaro.org> <20230320101035.2214196-3-alex.bennee@linaro.org> From: Claudio Fontana In-Reply-To: <20230320101035.2214196-3-alex.bennee@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2001:67c:2178:6::1d; envelope-from=cfontana@suse.de; helo=smtp-out2.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org How is this conditional on CONFIG_TCG? To me it looks like this breaks !CONFIG_TCG. Careful, the meson.build in accel/tcg/meson.build is always recursed. This code was in tcg_ss before, why not simply add it to tcg_ss and then to specific_ss along with the other tcg pieces? Ciao, C On 3/20/23 11:10, Alex Bennée wrote: > This doesn't save much as cpu-exec-common still needs to be built > per-target for its knowledge of CPUState but this helps with keeping > things organised. > > Signed-off-by: Alex Bennée > --- > accel/tcg/cpu-exec-common.c | 30 ---------------------- > accel/tcg/cpu-exec-softmmu.c | 50 ++++++++++++++++++++++++++++++++++++ > accel/tcg/meson.build | 10 ++++++++ > 3 files changed, 60 insertions(+), 30 deletions(-) > create mode 100644 accel/tcg/cpu-exec-softmmu.c > > diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c > index e7962c9348..c6b0ad303e 100644 > --- a/accel/tcg/cpu-exec-common.c > +++ b/accel/tcg/cpu-exec-common.c > @@ -32,36 +32,6 @@ void cpu_loop_exit_noexc(CPUState *cpu) > cpu_loop_exit(cpu); > } > > -#if defined(CONFIG_SOFTMMU) > -void cpu_reloading_memory_map(void) > -{ > - if (qemu_in_vcpu_thread() && current_cpu->running) { > - /* The guest can in theory prolong the RCU critical section as long > - * as it feels like. The major problem with this is that because it > - * can do multiple reconfigurations of the memory map within the > - * critical section, we could potentially accumulate an unbounded > - * collection of memory data structures awaiting reclamation. > - * > - * Because the only thing we're currently protecting with RCU is the > - * memory data structures, it's sufficient to break the critical section > - * in this callback, which we know will get called every time the > - * memory map is rearranged. > - * > - * (If we add anything else in the system that uses RCU to protect > - * its data structures, we will need to implement some other mechanism > - * to force TCG CPUs to exit the critical section, at which point this > - * part of this callback might become unnecessary.) > - * > - * This pair matches cpu_exec's rcu_read_lock()/rcu_read_unlock(), which > - * only protects cpu->as->dispatch. Since we know our caller is about > - * to reload it, it's safe to split the critical section. > - */ > - rcu_read_unlock(); > - rcu_read_lock(); > - } > -} > -#endif > - > void cpu_loop_exit(CPUState *cpu) > { > /* Undo the setting in cpu_tb_exec. */ > diff --git a/accel/tcg/cpu-exec-softmmu.c b/accel/tcg/cpu-exec-softmmu.c > new file mode 100644 > index 0000000000..2318dd8c7d > --- /dev/null > +++ b/accel/tcg/cpu-exec-softmmu.c > @@ -0,0 +1,50 @@ > +/* > + * Emulator main CPU execution loop, softmmu bits > + * > + * Copyright (c) 2003-2005 Fabrice Bellard > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, see . > + */ > + > +#include "qemu/osdep.h" > +#include "hw/core/cpu.h" > +#include "sysemu/cpus.h" > + > +void cpu_reloading_memory_map(void) > +{ > + if (qemu_in_vcpu_thread() && current_cpu->running) { > + /* The guest can in theory prolong the RCU critical section as long > + * as it feels like. The major problem with this is that because it > + * can do multiple reconfigurations of the memory map within the > + * critical section, we could potentially accumulate an unbounded > + * collection of memory data structures awaiting reclamation. > + * > + * Because the only thing we're currently protecting with RCU is the > + * memory data structures, it's sufficient to break the critical section > + * in this callback, which we know will get called every time the > + * memory map is rearranged. > + * > + * (If we add anything else in the system that uses RCU to protect > + * its data structures, we will need to implement some other mechanism > + * to force TCG CPUs to exit the critical section, at which point this > + * part of this callback might become unnecessary.) > + * > + * This pair matches cpu_exec's rcu_read_lock()/rcu_read_unlock(), which > + * only protects cpu->as->dispatch. Since we know our caller is about > + * to reload it, it's safe to split the critical section. > + */ > + rcu_read_unlock(); > + rcu_read_lock(); > + } > +} > diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build > index aeb20a6ef0..bdc086b90d 100644 > --- a/accel/tcg/meson.build > +++ b/accel/tcg/meson.build > @@ -1,3 +1,9 @@ > +# > +# Currently most things here end up in specific_ss eventually because > +# they need knowledge of CPUState. Stuff that that doesn't can live in > +# common user, softmmu or overall code > +# > + > tcg_ss = ss.source_set() > tcg_ss.add(files( > 'tcg-all.c', > @@ -9,6 +15,7 @@ tcg_ss.add(files( > 'translate-all.c', > 'translator.c', > )) > + > tcg_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-exec.c')) > tcg_ss.add(when: 'CONFIG_SOFTMMU', if_false: files('user-exec-stub.c')) > tcg_ss.add(when: 'CONFIG_PLUGIN', if_true: [files('plugin-gen.c')]) > @@ -27,3 +34,6 @@ tcg_module_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files( > 'tcg-accel-ops-icount.c', > 'tcg-accel-ops-rr.c', > )) > + > +# Common softmmu code > +softmmu_ss.add(files('cpu-exec-softmmu.c'))