From patchwork Fri Jul 23 19:34:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1509345 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=N1s+SFWe; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GWfmx4J1Mz9sX2 for ; Sat, 24 Jul 2021 05:40:33 +1000 (AEST) Received: from localhost ([::1]:47558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m7127-0001al-BN for incoming@patchwork.ozlabs.org; Fri, 23 Jul 2021 15:40:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m70wq-0006Vx-L5 for qemu-devel@nongnu.org; Fri, 23 Jul 2021 15:35:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35091) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m70wo-0002RR-WD for qemu-devel@nongnu.org; Fri, 23 Jul 2021 15:35:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627068902; h=from:from:reply-to:subject:subject: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=QMg0qB0xoJcBQNJ7ML75cem+ABD+BhEtcoCp8aunrsI=; b=N1s+SFWecTTaUAcTmPmnubtzHqltAA7M4v/nKO9fxO5HFwAm9s2ExF5Ko+tK/+mKNbhbzu eqeLtWpD5p28ulxVqWIxDtk0d9bZFJko0iPqffelEWakYI1CNS4wfIoppTnbIVCycls8mP 3ROqiHDrX/IR8mugdh3JP5aArxWoB7M= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-oFh2Ztc3OgKNCx-mA8wOSQ-1; Fri, 23 Jul 2021 15:35:01 -0400 X-MC-Unique: oFh2Ztc3OgKNCx-mA8wOSQ-1 Received: by mail-qt1-f199.google.com with SMTP id e16-20020ac867100000b0290257b7db4a28so1719407qtp.9 for ; Fri, 23 Jul 2021 12:35:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QMg0qB0xoJcBQNJ7ML75cem+ABD+BhEtcoCp8aunrsI=; b=PjFtMCDyomvqEOMEHIYYlhok3ICnIaYdtW5NvQVQ8gRcLph8s65S5NWluMw4mYwZej /kvD/Ueb2RlUR1QybxcRmgotleqBUNqm891OtU+akgtRpXquUl3X5ONW66o41NVafRKT q13TzTJsD7WdEoxitI0XIZK6qEu8tsYbsa041dg03Aek8mTD2g3qjgRvJYEL1rFfauku ogMEGoiR9nPB2R01zQXlcCQJdD6muUb/CbXKIiZuARSN79z6DrOhUO7RlBo6UCVh6JQD 3k3ez6J+G6xdXShWPuaiyle4Eex+2+mK27oCv/YqBG91jUibqKMm+ODlFK+JfjGGr5aN lC+A== X-Gm-Message-State: AOAM532O8YNCDXtQ9QDf6TsGcDtiS729JHOqUSB4D78kLn/U4pbtULIY 4LkDUsdUypzmX+5oI6yXjXOdJcLBF8uGKveXpEiJJ2GpMplvM4vsA9ae5iEpeydwHCuDu+gH1E4 RzeJsrZftt9P9+oc7M+HDdrDsRWyADh0SSUAvExUEOFeZ3hBOL9CnZti3jVNGMNxK X-Received: by 2002:a37:af84:: with SMTP id y126mr6244203qke.448.1627068900297; Fri, 23 Jul 2021 12:35:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU4kG86Sfik4q0KCkLzzZF61DSrf2SX8hJegsv3o89r0TgiQhJrBiHqC89+clAOdS3KQiG5g== X-Received: by 2002:a37:af84:: with SMTP id y126mr6244175qke.448.1627068900020; Fri, 23 Jul 2021 12:35:00 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-65-184-144-111-238.dsl.bell.ca. [184.144.111.238]) by smtp.gmail.com with ESMTPSA id o2sm12659104qkm.109.2021.07.23.12.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jul 2021 12:34:59 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v2 7/9] cpus: Introduce qemu_mutex_unlock_iothread_prepare() Date: Fri, 23 Jul 2021 15:34:42 -0400 Message-Id: <20210723193444.133412-8-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723193444.133412-1-peterx@redhat.com> References: <20210723193444.133412-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.472, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=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: Paolo Bonzini , David Hildenbrand , peterx@redhat.com, Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The prepare function before unlocking BQL. There're only three places that can release the BQL: unlock(), cond_wait() or cond_timedwait(). Signed-off-by: Peter Xu --- softmmu/cpus.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/softmmu/cpus.c b/softmmu/cpus.c index 9131f77f87..6085f8edbe 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -66,6 +66,10 @@ static QemuMutex qemu_global_mutex; +static void qemu_mutex_unlock_iothread_prepare(void) +{ +} + bool cpu_is_stopped(CPUState *cpu) { return cpu->stopped || !runstate_is_running(); @@ -523,16 +527,19 @@ void qemu_mutex_unlock_iothread(void) { g_assert(qemu_mutex_iothread_locked()); iothread_locked = false; + qemu_mutex_unlock_iothread_prepare(); qemu_mutex_unlock(&qemu_global_mutex); } void qemu_cond_wait_iothread(QemuCond *cond) { + qemu_mutex_unlock_iothread_prepare(); qemu_cond_wait(cond, &qemu_global_mutex); } void qemu_cond_timedwait_iothread(QemuCond *cond, int ms) { + qemu_mutex_unlock_iothread_prepare(); qemu_cond_timedwait(cond, &qemu_global_mutex, ms); }