From patchwork Thu Oct 1 14:29:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 54369 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 36308205D0 for ; Thu, 1 Oct 2015 14:29:54 +0000 (UTC) Received: by wicgb1 with SMTP id gb1sf9078613wic.3 for ; Thu, 01 Oct 2015 07:29:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=/Ygn9gmYLSbZyI8nr7WeRaXVwkhsb7gJJQIDQlK0UtA=; b=k5yGcrHEJI9JPkSkRoHptzuai/3lxtQTGTHadn2CiXKz6itEgkf8wcDHOPhHSZafvY kV+UJqzPhGEMuooBqDUzjofdxILuTiVO9pvrnWUA78ZPeIcAWrXSiV056aHa6AaQIvCx XtlsCOhsTRhshwjm3tJhCZ0GN9SZbls83ZyXjrrwS+BytivwJosDZGihrxQqPFszMDGF ljrdEOT4A3Jq52dUrFnJunq3YB4q26jKfvf7+ug3BxuwF5Ozd+4vNI5bkS9uxaBk1ws6 VZrl4T+iCjqKg2RFfmWOz4n+bcqLlxdvcju5xlkodQYc4PQEHbNzcG7b/VHVpPKOoJSq lY3g== X-Gm-Message-State: ALoCoQnagQ19Rp4im/eb/KhkEUepOeioNoTIauhUFEAs9zKd7cJlj7zISZI9ZKMGBVP3sagLtPkE X-Received: by 10.112.198.33 with SMTP id iz1mr1449120lbc.8.1443709793473; Thu, 01 Oct 2015 07:29:53 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.21.166 with SMTP id 38ls123562lfv.22.gmail; Thu, 01 Oct 2015 07:29:53 -0700 (PDT) X-Received: by 10.25.30.194 with SMTP id e185mr2009341lfe.48.1443709793342; Thu, 01 Oct 2015 07:29:53 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id i8si2965197lbj.130.2015.10.01.07.29.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Oct 2015 07:29:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lahh2 with SMTP id h2so75949141lah.0 for ; Thu, 01 Oct 2015 07:29:53 -0700 (PDT) X-Received: by 10.152.26.41 with SMTP id i9mr3056779lag.36.1443709793196; Thu, 01 Oct 2015 07:29:53 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.59.35 with SMTP id w3csp647985lbq; Thu, 1 Oct 2015 07:29:52 -0700 (PDT) X-Received: by 10.194.2.243 with SMTP id 19mr10517022wjx.140.1443709792544; Thu, 01 Oct 2015 07:29:52 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id s20si4021641wib.107.2015.10.01.07.29.52 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 01 Oct 2015 07:29:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Zherm-0006Yi-QJ; Thu, 01 Oct 2015 15:29:50 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Paolo Bonzini , "Edgar E. Iglesias" Subject: [PATCH v2 2/3] cpu-exec-common.c: Clarify comment about cpu_reload_memory_map()'s RCU operations Date: Thu, 1 Oct 2015 15:29:49 +0100 Message-Id: <1443709790-25180-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1443709790-25180-1-git-send-email-peter.maydell@linaro.org> References: <1443709790-25180-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The reason for cpu_reload_memory_map()'s RCU operations is not so much because the guest could make the critical section very long, but that it could have a critical section within which it made an arbitrary number of changes to the memory map and thus accumulate an unbounded amount of memory data structures awaiting reclamation. Clarify the comment to make this clearer. Signed-off-by: Peter Maydell --- --- cpu-exec-common.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cpu-exec-common.c b/cpu-exec-common.c index 16d305b..b95b09a 100644 --- a/cpu-exec-common.c +++ b/cpu-exec-common.c @@ -42,13 +42,21 @@ void cpu_reload_memory_map(CPUState *cpu) AddressSpaceDispatch *d; if (qemu_in_vcpu_thread()) { - /* Do not let the guest prolong the critical section as much as it - * as it desires. + /* 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. * - * Currently, this is prevented by the I/O thread's periodinc kicking - * of the VCPU thread (iothread_requesting_mutex, qemu_cpu_kick_thread) - * but this will go away once TCG's execution moves out of the global - * mutex. + * 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 reload it below, we can