From patchwork Fri Sep 15 16:32:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 723129 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp483693wro; Fri, 15 Sep 2023 09:34:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFnVM58zeNHIT1cJrvjnhVJNIrXeyOHszSuoyH+9eii9mYYLgM5HqFj8wcsrUwV6gcBpPu X-Received: by 2002:ac8:7d8a:0:b0:412:309f:c0fa with SMTP id c10-20020ac87d8a000000b00412309fc0famr2341806qtd.64.1694795641636; Fri, 15 Sep 2023 09:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694795641; cv=none; d=google.com; s=arc-20160816; b=axGcPMJV0qmh5Q+EXinE43/J1mgwGo9n4FOZgoIFUob7XT8Uvn63zoVZ+gKObj1Fxe 7Itlbf4UpTZjRmdqpxymrWJPV190HqCCzRAMoLn74cLKhQv+BUlOj53VvrZPgozVYA5w n8TleGiCu+c2FjR8MBFeReKnzvmGiN8ipU3DyBxqfGOQcmyau3oR9GWTNgwmvXlcN42A Xy+FNCxuW2eb6yfyPYibS+uTT93/lgN5wj7RMTxr+STI0oUTIVKYHCSbkFY8FUpATSMr d2qKgMvpg3X9M4X5k74/dP2zf0tJ7xvhulcToUkfJtrGthfot12v5xaVkjpii1OCtvFg yPiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iJ6Oywpvjr1xG7Guou9tEnbUmyP3OUnn4VhCnCRzKJY=; fh=ycigHkwOPieh2u5PmcA89sNk/qPD1ZkdDlL8Mchfvw8=; b=n/Sa9wAA8g1QQIoax+alG2g/lQDAaVv8DeZgHovuWKpQxNGGcUXL4IFs3JmlLvSEWs fRDjWwTJ/790ShFrgwJqfPACXeMUYXUxAM0L3z6cWFch5IkYAZ8PMvvDYL/dLx8csYAy UV8DvEsS03bbT/5QlgtdWxYiSpvIHigO7o3qOphMcNUmw3coxPt6JddtKRdR8NmC6vDW 73BwG4qFIktq8H+NAKbjrc+AYa2Ky9xt1scTnkls45SESiYYvRyyXqlKDrtUu4r5/72R nUkWnoA/Q1mw7Kv4QLqc2QiSRv3ujyPXCHYERQ2Ws70FhaPHMhfe+RwAwwaz3TMmyjLN /1oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BoHXb9ez; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a28-20020a05620a16dc00b0076dbc2b8790si2430442qkn.510.2023.09.15.09.34.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Sep 2023 09:34:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BoHXb9ez; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBkc-0008FO-7J; Fri, 15 Sep 2023 12:33:02 -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 1qhBka-0008Ee-Sc for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:33:00 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBkZ-00037L-7W for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:33:00 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-68fb79ef55eso2137444b3a.0 for ; Fri, 15 Sep 2023 09:32:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694795578; x=1695400378; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iJ6Oywpvjr1xG7Guou9tEnbUmyP3OUnn4VhCnCRzKJY=; b=BoHXb9ezG57eYc6uny9thtZ+GyAvtvLAWsvuG7K3IA6JdWWE8iYKOcpa3pwq5uBKKU xTRtw9WvIQlADM1orag8E9Gd18zaPELz5PJ/vm7qYzat/ZqkxV5Wy2dWF7Fkpls/YN69 eQIGbbWTBQCPKOWGB+XNKW4k6XYgMIU+dxIjgOKHrIcYxq2JMy18jbL7xTscPfoOQD0N C5FvXKdkXQZLes3a3hg6C9wHtVHUsc74UGJLatmcToDl1CVCgiV2mWS8M322t/YXK7T8 89Uj22CyPNgETbdrwT3qhn2jYgH32Dx3jId9TSFMlCNOT88Q+MnehVGSTWI5w1qPRKV+ RA6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694795578; x=1695400378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iJ6Oywpvjr1xG7Guou9tEnbUmyP3OUnn4VhCnCRzKJY=; b=gb4vYcHghb+K3wppA3VaK4RR4241nCam3uJm99q6yV+4aGxqJRjeTz17N05rDQjPcu AH0hJnRd2hHN7zkhCEYyIb+nRyRrpeFIR11VJRhv3SswcIzt2WxwA1fqCQngvl57S1Tm F875PsUObkAxRk3YC6TVAPtG3FqwXInFT3wPn2Df+IUfoPBpqYgt/Wstv8MnXjO4Tb+Z +G1Rjf54x3VDhgUx2pKkB4KbkTOgtN3pTT2VfncQC35EJAU6z2pxUnL6PwKb4vSdN7It RWQBgsY56XZgyZACJxFmPgzly4ox4ZRM0Te5IvyvpCGEPm7+RMYULalZ/XxlwAeMvMma YbVw== X-Gm-Message-State: AOJu0YxX28T++bMEPxNf7t4UEwa2gT9fTqd19dMRo05ARAfO5p94hFjg 0/bCi7pqI+ekJoGw2kjVI+uLnpoA0rBZBi0Cz+E= X-Received: by 2002:a05:6a21:18d:b0:129:d944:2e65 with SMTP id le13-20020a056a21018d00b00129d9442e65mr3105614pzb.13.1694795577935; Fri, 15 Sep 2023 09:32:57 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id z3-20020a637e03000000b0057754ae4eb7sm2958497pgc.39.2023.09.15.09.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:32:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH v2 2/3] softmmu: Introduce AddressSpaceDispatch generation numbers Date: Fri, 15 Sep 2023 09:32:53 -0700 Message-Id: <20230915163254.123338-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915163254.123338-1-richard.henderson@linaro.org> References: <20230915163254.123338-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Allow the cpu to easily check if an address space update is required. The acquire/release semantics will be used by a subsequent patch. Signed-off-by: Richard Henderson --- softmmu/physmem.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 88fafec1da..e1c535380a 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -163,6 +163,8 @@ struct CPUAddressSpace { AddressSpace *as; struct AddressSpaceDispatch *memory_dispatch; MemoryListener tcg_as_listener; + uint32_t commit_gen; + uint32_t layout_gen; }; struct DirtyBitmapSnapshot { @@ -2486,14 +2488,23 @@ static void tcg_log_global_after_sync(MemoryListener *listener) } } -static void tcg_commit_cpu(CPUState *cpu, run_on_cpu_data data) +static void tcg_commit_cpu_0(CPUState *cpu, CPUAddressSpace *cpuas) { - CPUAddressSpace *cpuas = data.host_ptr; - cpuas->memory_dispatch = address_space_to_dispatch(cpuas->as); tlb_flush(cpu); } +static void tcg_commit_cpu_1(CPUState *cpu, run_on_cpu_data data) +{ + CPUAddressSpace *cpuas = data.host_ptr; + uint32_t gen = qatomic_load_acquire(&cpuas->layout_gen); + + if (cpuas->commit_gen != gen) { + cpuas->commit_gen = gen; + tcg_commit_cpu_0(cpu, cpuas); + } +} + static void tcg_commit(MemoryListener *listener) { CPUAddressSpace *cpuas; @@ -2518,9 +2529,10 @@ static void tcg_commit(MemoryListener *listener) * all of the tcg machinery for run-on is initialized: thus created. */ if (cpu->created) { - async_run_on_cpu(cpu, tcg_commit_cpu, RUN_ON_CPU_HOST_PTR(cpuas)); + qatomic_store_release(&cpuas->layout_gen, cpuas->layout_gen + 1); + async_run_on_cpu(cpu, tcg_commit_cpu_1, RUN_ON_CPU_HOST_PTR(cpuas)); } else { - tcg_commit_cpu(cpu, RUN_ON_CPU_HOST_PTR(cpuas)); + tcg_commit_cpu_0(cpu, cpuas); } }