From patchwork Thu Mar 26 19:30:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 184859 Delivered-To: patch@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp447046ilr; Thu, 26 Mar 2020 12:38:50 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtPdSkPNoiyTEQz4rmwBrl9n+VkcvM9HZ8z1xfhwPXv5tI2QJ/M4QfIMKY5pr3U/Ri0890Z X-Received: by 2002:a37:6592:: with SMTP id z140mr10132056qkb.257.1585251530486; Thu, 26 Mar 2020 12:38:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585251530; cv=none; d=google.com; s=arc-20160816; b=w76nrQhwQl1qQS7vnD/R8VJ5/rC8LRo2s+2ZZzy1VNXSrq1MRo+KhXEpOV7bYgj4TJ nD+eblAu6KIeQWGIBjlgTZJenV49xhxgx/vqam69l+NdbrOxyCwYIxJYCXUNyBVmAQLI r8PjzjSIMIutFZm8GHVQRnVa7Ozwxkeowj7EkSYzB50xclPNe8tA1hkAVmTT86dQ8Yr+ THON6A416hvW1xmcx4JJ81XjsGYqvWZaQ+MhtNXfG5PV0Zs5+245r+oGjay1/jmNPwSc 7kMvIFX1eZKJRUTC5VBCYEQdMSdBY4ks9Bl5lkYjqDwVNsaBltoXSNw1ZPbVhNton508 x9Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=Jjmk8HMVsaMAjw4OpmNeL2f8ls8xSfNsLsqnnyNmPuQ=; b=qSy2j0GWZ+WVcKQoou+rxAqK0/YTA2ueq4yTJtF/xIcEmDNbO6GAOL1wGTCfeQFvUT +noikhgzj9ZgkiVNYd8a9/CuF7OBycMc84IOmao8mvqjyU9Cue1KT6bdolUpVKlOtWXv QoB1cjelOKP5NCsTeQ4JplBJkahNCcmrFomoL1ycwPjtgvskCxmeXrDVaxTNIIlVngjG mYUyXmND2+2jelujRbe5tVX5XIkKt36RmAY3XSAtGKpmnDR4L/MEqI59NaODN/W5BEVm P72da26hfBrCAuxR9rF7B27dIkFBj8X/8pc9yFELKgnp5sqLE1GLJ7HThuCP5BAw4uae s5iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rLimLxqz; 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=fail (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 e24si2054448qts.40.2020.03.26.12.38.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Mar 2020 12:38:50 -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=fail header.i=@linaro.org header.s=google header.b=rLimLxqz; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHYL3-0007BS-UK for patch@linaro.org; Thu, 26 Mar 2020 15:38:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58390) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHYJy-00061Z-Ie for qemu-devel@nongnu.org; Thu, 26 Mar 2020 15:37:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHYJx-0001Mn-EH for qemu-devel@nongnu.org; Thu, 26 Mar 2020 15:37:42 -0400 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]:45602) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jHYJx-0001MT-9o for qemu-devel@nongnu.org; Thu, 26 Mar 2020 15:37:41 -0400 Received: by mail-qk1-x743.google.com with SMTP id c145so8135332qke.12 for ; Thu, 26 Mar 2020 12:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jjmk8HMVsaMAjw4OpmNeL2f8ls8xSfNsLsqnnyNmPuQ=; b=rLimLxqzAGiQnmDaz/CubO/0wZKhPAnzFUe5PvwwJRvz5PfYW33GroA8H403Azn/kk SYLK7FIg5UkDYHUOAIcaUwWvBtbbCC4sA7rhmL2vPsyelMPbAY5nwkIXxrE/0bLNR0SS v4IN4AY10MnYUePV3MqcA5qVG/HL3dP7P4GjrH9OGPjEbQYnP4SRrtv8r+o9ogJvrcsv yiIDnXOvbeiaLmG6xdcFCbttGrU1UADJBO+x59ZXbU3ftHfUi/7eqvtBifJF5o6Dz5np CvtLb8E6P7k0n9oZIqxvWidLRSPhAfgkX9Q4Rm8qOg5JekLGwpVfgCufqxFQMeTxTiaA rTzQ== 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=Jjmk8HMVsaMAjw4OpmNeL2f8ls8xSfNsLsqnnyNmPuQ=; b=Z/+ekdm4m002U+il+qCD7iIvZUQtXGnVVGPvpX/T2aAUhpUulJGHAUmnXKEGLACLVR LULrJFk9znOTppUynIiHfn4/VTpMDS7z0FdMVysOhGVRPICk8ykpO46GgzB0ykSYcLsa gXHerN3pyCMxirWzDqLdL1cH6F7DAnDzd67aHYEIzTFQ031M0sKRBbDcPZsmSI5xt6Vn atN159akWfU0jI6HoNLtM0foEaB/g/4wz+mA8zg7cQ22kz9jSGDnwds5LXCejpHJkNe2 mdHIJ+CrlkuJax87eRDzJTjcgWn7LFjHk8S3cQeWLbdLL7p4nBaceYLeW85zvi3LZGyz YrqA== X-Gm-Message-State: ANhLgQ0E3q39a5FUqh/whb4aeYEXFK84qCsp8tOXsCzJORhbWcrL7/GX AsfMPgUf4/ZheyEm8ibvJJOxZAp+X22tPw== X-Received: by 2002:a05:620a:120e:: with SMTP id u14mr9313433qkj.23.1585251460510; Thu, 26 Mar 2020 12:37:40 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:fd55:4e67:1038:8302]) by smtp.gmail.com with ESMTPSA id u51sm2161916qth.46.2020.03.26.12.37.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2020 12:37:39 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 06/74] cpu: introduce process_queued_cpu_work_locked Date: Thu, 26 Mar 2020 15:30:48 -0400 Message-Id: <20200326193156.4322-7-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200326193156.4322-1-robert.foley@linaro.org> References: <20200326193156.4322-1-robert.foley@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::743 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: richard.henderson@linaro.org, "Emilio G. Cota" , alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This completes the conversion to cpu_mutex_lock/unlock in the file. Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Robert Foley --- cpus-common.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/cpus-common.c b/cpus-common.c index bf5794cc17..f4a0f9ba3b 100644 --- a/cpus-common.c +++ b/cpus-common.c @@ -333,20 +333,19 @@ void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, queue_work_on_cpu(cpu, wi); } -void process_queued_cpu_work(CPUState *cpu) +/* Called with the CPU's lock held */ +static void process_queued_cpu_work_locked(CPUState *cpu) { struct qemu_work_item *wi; bool has_bql = qemu_mutex_iothread_locked(); - qemu_mutex_lock(&cpu->lock); if (QSIMPLEQ_EMPTY(&cpu->work_list)) { - qemu_mutex_unlock(&cpu->lock); return; } while (!QSIMPLEQ_EMPTY(&cpu->work_list)) { wi = QSIMPLEQ_FIRST(&cpu->work_list); QSIMPLEQ_REMOVE_HEAD(&cpu->work_list, node); - qemu_mutex_unlock(&cpu->lock); + cpu_mutex_unlock(cpu); if (wi->exclusive) { /* Running work items outside the BQL avoids the following deadlock: * 1) start_exclusive() is called with the BQL taken while another @@ -372,13 +371,19 @@ void process_queued_cpu_work(CPUState *cpu) qemu_mutex_unlock_iothread(); } } - qemu_mutex_lock(&cpu->lock); + cpu_mutex_lock(cpu); if (wi->free) { g_free(wi); } else { atomic_mb_set(&wi->done, true); } } - qemu_mutex_unlock(&cpu->lock); qemu_cond_broadcast(&cpu->cond); } + +void process_queued_cpu_work(CPUState *cpu) +{ + cpu_mutex_lock(cpu); + process_queued_cpu_work_locked(cpu); + cpu_mutex_unlock(cpu); +}