From nobody Sun Apr 28 21:27:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517463601742319.31377976259137; Wed, 31 Jan 2018 21:40:01 -0800 (PST) Received: from localhost ([::1]:60942 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eh7bM-0005ek-Uj for importer@patchew.org; Thu, 01 Feb 2018 00:40:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eh7aN-0005JO-Dm for qemu-devel@nongnu.org; Thu, 01 Feb 2018 00:39:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eh7aK-0000T3-Bc for qemu-devel@nongnu.org; Thu, 01 Feb 2018 00:38:59 -0500 Received: from spam.zju.edu.cn ([61.164.42.155]:62298 helo=zju.edu.cn) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eh7aJ-0000RB-NT for qemu-devel@nongnu.org; Thu, 01 Feb 2018 00:38:56 -0500 Received: from jdu4e00u53f7.localdomain (unknown [116.196.87.83]) by mail-app3 (Coremail) with SMTP id cC_KCgDnH27lp3JacfW6AQ--.60427S2; Thu, 01 Feb 2018 13:38:50 +0800 (CST) From: linzhecheng To: qemu-devel@nongnu.org Date: Thu, 1 Feb 2018 13:38:43 +0800 Message-Id: <1517463523-21394-1-git-send-email-linzc@zju.edu.cn> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: cC_KCgDnH27lp3JacfW6AQ--.60427S2 X-Coremail-Antispam: 1UD129KBjvdXoWruryrAr15KFyUZF13JFWfAFb_yoWktrb_u3 47uws8WrWUWFs09ryqyws3Xr1rJr1rCF1F9Fs5trZrAr1xJrWrKws29w1rG3yfZ3yayFZr uryrAr42vr1DGjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbz8FF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxG rwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4 vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IY x2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26c xKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x02 67AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjfU5WlkUUUUU X-CM-SenderInfo: isruiiarqyq6lmxovvfxof0/ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 61.164.42.155 Subject: [Qemu-devel] [PATCH] vcpu: join vcpu thread after it exiting X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, rth@twiddle.net, linzhecheng , linzhecheng , crosthwaite.peter@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As we create vcpu thread with QEMU_THREAD_JOINABLE mode, we should join it after it exiting to cleanup resources. Signed-off-by: linzhecheng diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f290f48..6ff71e4 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -282,9 +282,9 @@ err: =20 static int kvm_get_vcpu(KVMState *s, unsigned long vcpu_id) { - struct KVMParkedVcpu *cpu; + struct KVMParkedVcpu *cpu, *next_cpu; =20 - QLIST_FOREACH(cpu, &s->kvm_parked_vcpus, node) { + QLIST_FOREACH_SAFE(cpu, &s->kvm_parked_vcpus, node, *next_cpu) { if (cpu->vcpu_id =3D=3D vcpu_id) { int kvm_fd; =20 diff --git a/cpus.c b/cpus.c index 2cb0af9..1890bfe 100644 --- a/cpus.c +++ b/cpus.c @@ -1205,6 +1205,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) cpu->created =3D false; qemu_cond_signal(&qemu_cpu_cond); qemu_mutex_unlock_iothread(); + rcu_unregister_thread(); return NULL; } =20 @@ -1759,6 +1760,7 @@ void cpu_remove_sync(CPUState *cpu) cpu_remove(cpu); while (cpu->created) { qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); + qemu_thread_join(cpu->thread); } } =20 --=20 1.8.3.1