From nobody Tue Feb 10 15:46:14 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709921597; cv=none; d=zohomail.com; s=zohoarc; b=XFVPLSX4QKXWmcLIpIjIu+uEvNgdQ3RgEI7glYxRcpbpn+u9Ak5G81gEpDMcq8Mhp2Xijm+OuGQuBNZv4+FCJZMen0d0kZGA2c5A9MmVrBKSRdDUon1OFTMr3DkM3W55ih/pmZPTunPmEV/8sL2GxAy9l+dQOELi2NjWplyDX4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709921597; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3zgiv6UZ6Oh2NFmnmSITDqW1+MhIa91EcBCRfhCM6ng=; b=QzKD9vF0C/iKUScLmgTRhBMP3pkPlIVkgSz1PGK+CwuwGwYEp1oUuhJlznM+vMplhYByJ5w/ZcV1Gvz39tBFisl7JdMN/Z3rCYx9R24Mua6rAdgH4rK2oK13AiHkuD3zC7iA9R6EpwQPa6ZF47C5dXPRt5NPJSeGEElZvlczi/c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709921597754693.7956086501157; Fri, 8 Mar 2024 10:13:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riehj-00077p-Pf; Fri, 08 Mar 2024 13:12:23 -0500 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 1riehe-00076d-9a for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rieha-0005nR-5F for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:17 -0500 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-20-e02MUPo9OSisFZBaEPB4bQ-1; Fri, 08 Mar 2024 13:12:11 -0500 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a450265c7b6so142675066b.0 for ; Fri, 08 Mar 2024 10:12:11 -0800 (PST) Received: from [192.168.10.118] ([151.49.77.21]) by smtp.gmail.com with ESMTPSA id qk2-20020a170906d9c200b00a3fb9f1f10csm34462ejb.161.2024.03.08.10.12.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:12:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709921533; 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=3zgiv6UZ6Oh2NFmnmSITDqW1+MhIa91EcBCRfhCM6ng=; b=R3Dl5OWil3Tv6mrbFLl1G//UmrBvMzigLXQqCqIjRC/vcYPBj/6FRcLP4MNY3GQx3ex1lI D8CwaykPz+iArlNF55bO5mDSidQ4fG9r09MrCzW3OixBrnqHYCVS7a4RXbmU9lxCVUmFpZ zWPTXwgizww40RdPO/Gddm8QL8ayxbI= X-MC-Unique: e02MUPo9OSisFZBaEPB4bQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921529; x=1710526329; 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=3zgiv6UZ6Oh2NFmnmSITDqW1+MhIa91EcBCRfhCM6ng=; b=mE/LcDqSVMHoPdEO38mNG5PXO9l6t5bHKPePuYGB5zMdR9iasS0rMDseSN/gWYWcLi CHotN7664ae80XMVfQQDbx5uCJSy0GcKWeeZZ5OGlwQXMXhlTIzl4D/O+CfFCr7hqiNn UcxtpIcqFGAUPAr5tqmw3Y7ws3ThtReyh+rRAwwWeGUhwfHqLv7rTpEyL8kVc10rbFIc 0YwR6Y3EAjqh6sPyNTPvKSHZXFW09AmGz6C7kV+qLjBxmmdLGzPGMDjOTxm9QyzQkuU4 cTrNuevJUgO/81jup9SaP2WSMkdHhrROngzr8juOlmaSpB0nVWtHP9c6Ix2v+IDz3wAQ yBmg== X-Gm-Message-State: AOJu0YwS1eC/4S0vjHi+kjuTl5DKlzPdia488IlnNknJjw4R/sJNerCV Le3djbMGw8MbvLT7tkwMQFe9dpL9TJbPbei/466EL6O2BnWJ0tt6ccDIgkIurcf7klaE76Dzise tzAbii6B0n5hvQDqr53QNGAwj3xWDtG95QUKpRnZyghq5xEmRmoYX3WhUqib/5GVtrmNpryp6ON FzNXlB45QpmfMczXctGeNQjPoQB8s0GLZd7pqG X-Received: by 2002:a17:906:5a9a:b0:a44:48db:9060 with SMTP id l26-20020a1709065a9a00b00a4448db9060mr13864474ejq.19.1709921529511; Fri, 08 Mar 2024 10:12:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYXYgTpjHVOuKD6hlcLFJDwpr/l1BA+IeuIzlRiODg8q/CRESZpSO+iBDeDanQBBqO+b9I+A== X-Received: by 2002:a17:906:5a9a:b0:a44:48db:9060 with SMTP id l26-20020a1709065a9a00b00a4448db9060mr13864461ejq.19.1709921529115; Fri, 08 Mar 2024 10:12:09 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Dmitrii Gavrilov , qemu-stable@nongnu.org Subject: [PULL 2/9] system/qdev-monitor: move drain_call_rcu call under if (!dev) in qmp_device_add() Date: Fri, 8 Mar 2024 19:11:54 +0100 Message-ID: <20240308181202.617329-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240308181202.617329-1-pbonzini@redhat.com> References: <20240308181202.617329-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709921599519100005 Content-Type: text/plain; charset="utf-8" From: Dmitrii Gavrilov Original goal of addition of drain_call_rcu to qmp_device_add was to cover the failure case of qdev_device_add. It seems call of drain_call_rcu was misplaced in 7bed89958bfbf40df what led to waiting for pending RCU callbacks under happy path too. What led to overall performance degradation of qmp_device_add. In this patch call of drain_call_rcu moved under handling of failure of qdev_device_add. Signed-off-by: Dmitrii Gavrilov Message-ID: <20231103105602.90475-1-ds-gavr@yandex-team.ru> Fixes: 7bed89958bf ("device_core: use drain_call_rcu in in qmp_device_add",= 2020-10-12) Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- system/qdev-monitor.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index a13db763e5d..874d65191ce 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -858,19 +858,18 @@ void qmp_device_add(QDict *qdict, QObject **ret_data,= Error **errp) return; } dev =3D qdev_device_add(opts, errp); - - /* - * Drain all pending RCU callbacks. This is done because - * some bus related operations can delay a device removal - * (in this case this can happen if device is added and then - * removed due to a configuration error) - * to a RCU callback, but user might expect that this interface - * will finish its job completely once qmp command returns result - * to the user - */ - drain_call_rcu(); - if (!dev) { + /* + * Drain all pending RCU callbacks. This is done because + * some bus related operations can delay a device removal + * (in this case this can happen if device is added and then + * removed due to a configuration error) + * to a RCU callback, but user might expect that this interface + * will finish its job completely once qmp command returns result + * to the user + */ + drain_call_rcu(); + qemu_opts_del(opts); return; } --=20 2.43.2