From nobody Tue Feb 10 01:14:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1644843138; cv=none; d=zohomail.com; s=zohoarc; b=cPAOUunRWt2pKuDbG6J5We+7b13A+vcQYXp4wIlsGcwZGxW2Etkef4rwQ7tw27fQ/8NFlPWPkefoYFg3Wc4Z8tPMlzr9kqIp/H5CHOK9AMHLjJoHZogF17pJheYicXpiO2dPNfP53l4DIp20W7qXIa+T2N9pmIdkdTc0X1nctsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644843138; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zeSvT8nyHnSFT792WE5Ua5JbmI9OXUZowMFJT4YXSxY=; b=l2cxJ5MLDhxot7ehPALonoF5fxelATfkxEKxo5AfhwQy2S03f/4dyJQCvHIb3P1UQAEx/n+ped22YXeP9+mjibtabfdvw85Mxy6MZRS5BbP3C6XzCkzGkxgNy/dTL6PN09cobz9U+V9Bgkf/qK55oOmKIi1a+DQ/ANzvrSm1nzE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1644843138111206.6685873902661; Mon, 14 Feb 2022 04:52:18 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.271503.465983 (Exim 4.92) (envelope-from ) id 1nJape-0004Uu-Un; Mon, 14 Feb 2022 12:51:54 +0000 Received: by outflank-mailman (output) from mailman id 271503.465983; Mon, 14 Feb 2022 12:51:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nJape-0004U6-Pt; Mon, 14 Feb 2022 12:51:54 +0000 Received: by outflank-mailman (input) for mailman id 271503; Mon, 14 Feb 2022 12:51:53 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nJapd-0003jk-Dh for xen-devel@lists.xenproject.org; Mon, 14 Feb 2022 12:51:53 +0000 Received: from esa3.hc3370-68.iphmx.com (esa3.hc3370-68.iphmx.com [216.71.145.155]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e113971b-8d94-11ec-8eb8-a37418f5ba1a; Mon, 14 Feb 2022 13:51:51 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e113971b-8d94-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1644843111; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=OM1G6c/BDHwKCEjd4XaBXduFB7GfRa2QTRUE5y+VtvI=; b=I9b5R5jBLFqhk5tgOpGizR7lsaaH5Hbb7S5/Kgqmce23ynZTM8y2xA8b PnYOch9sXd5SZn0UE4Ms2T0ZavPIiDMqMCxun/WAnkTigOlgw5qvCkt2f GRIY3eS/0XAoqDIWz9wrzoFqfLhRAxy0tnJIq8NlDHKp3UzZCnNIkG97U U=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: bMVoiWl/SqiephNQZZdM0jr+KyVglX9h9DTAuRNTCIiLqueZt+NbwSDLC87RExF/DKY0E2LLi7 VxNv0TYS77xL+lUtl9j3Y/DsmlH3DzjAJqcI0FcNBQQhZQtlKVTYqBS9B8+y7YJR2RIIiHJA/q mktrqta4Pj4xG51lZmNUM/ExSMtTMBbdvtGjLVx0nh63fsdOvpBE6cL6yd9iaB5c4BEf9WtDEV OHFI7Q+50beCDZeLXEx9+F+8cwlUdkGy5+80Y9YeYDwvc6MjDM8Uh2OBOG4LWszVFJZwM642Pp T9E7rXgPS10tsEwL5uUY3kZa X-SBRS: 5.1 X-MesageID: 64148317 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:HX3pta0YVdWs3LQelvbD5cx2kn2cJEfYwER7XKvMYLTBsI5bp2AGz jEWWGHVb/3ZYDT3e9sjPo62/EsEsZ+ByoVmGws/pC1hF35El5HIVI+TRqvS04J+DSFhoGZPt Zh2hgzodZhsJpPkS5PE3oHJ9RGQ74nRLlbHILOCanAZqTNMEn9700o5wrJh2+aEvPDia++zk YKqyyHgEAfNNw5cagr4PIra9XuDFNyr0N8plgRWicJj5TcypFFMZH4rHomjLmOQf2VhNrXSq 9Avbl2O1jixEx8FUrtJm1tgG6EAaua60QOm0hK6V0U+6/TrS+NbPqsTbZIhhUlrZzqhrvshx 4tm5JyLFlkrZuqcur8SDRlVHHQrVUFG0OevzXmXtMWSywvNcmf2wuUoB0YzVWEa0r8pWycUr 6VecW1TKEDY7w616OvTpu1Er8IvNsT0eqgYvWlt12rxBvc6W5HTBa7N4Le02R9u2pkSTa2HO KL1bxJJMC3nZBkfB24eUrdg29+XmXPSbR9X/Qf9Sa0fvDGIkV0ZPKLWGMrYfJmGSNtY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I3KNGOKhILCFuBfxLqn7zr8GzDvss5xvJ 0QFpSW0eeAbmSSW/yKgjWFLw== X-IronPort-AV: E=Sophos;i="5.88,367,1635220800"; d="scan'208";a="64148317" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper Subject: [PATCH v2 01/70] xen/domain: Improve pirq handling Date: Mon, 14 Feb 2022 12:50:18 +0000 Message-ID: <20220214125127.17985-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220214125127.17985-1-andrew.cooper3@citrix.com> References: <20220214125127.17985-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1644843138847100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" free_pirq_struct() has no external users, so shouldn't be exposed. Making = it static necessistates moving the function as domain_destroy() uses it. Rework pirq_get_info() to have easier-to-follow logic. The one functional change is to the insertion failure path; we should not be using a full call_rcu() chain to free an otherwise local structure we failed to insert i= nto the radix tree to begin with. Signed-off-by: Andrew Cooper --- v2: * Drop likely/unlikey --- xen/common/domain.c | 62 ++++++++++++++++++++++++++------------------= ---- xen/include/xen/domain.h | 1 - 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 2048ebad86ff..571ef4fe615e 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -365,6 +365,39 @@ static int __init parse_extra_guest_irqs(const char *s) } custom_param("extra_guest_irqs", parse_extra_guest_irqs); =20 +static void _free_pirq_struct(struct rcu_head *head) +{ + xfree(container_of(head, struct pirq, rcu_head)); +} + +static void free_pirq_struct(void *ptr) +{ + struct pirq *pirq =3D ptr; + + call_rcu(&pirq->rcu_head, _free_pirq_struct); +} + +struct pirq *pirq_get_info(struct domain *d, int pirq) +{ + struct pirq *info =3D pirq_info(d, pirq); + + if ( info ) + return info; + + info =3D alloc_pirq_struct(d); + if ( !info ) + return NULL; + + info->pirq =3D pirq; + if ( radix_tree_insert(&d->pirq_tree, pirq, info) =3D=3D 0 ) + return info; /* Success. */ + + /* Don't use call_rcu() to free a struct we failed to insert. */ + _free_pirq_struct(&info->rcu_head); + + return NULL; +} + /* * Release resources held by a domain. There may or may not be live * references to the domain, and it may or may not be fully constructed. @@ -1780,35 +1813,6 @@ long do_vm_assist(unsigned int cmd, unsigned int typ= e) } #endif =20 -struct pirq *pirq_get_info(struct domain *d, int pirq) -{ - struct pirq *info =3D pirq_info(d, pirq); - - if ( !info && (info =3D alloc_pirq_struct(d)) !=3D NULL ) - { - info->pirq =3D pirq; - if ( radix_tree_insert(&d->pirq_tree, pirq, info) ) - { - free_pirq_struct(info); - info =3D NULL; - } - } - - return info; -} - -static void _free_pirq_struct(struct rcu_head *head) -{ - xfree(container_of(head, struct pirq, rcu_head)); -} - -void free_pirq_struct(void *ptr) -{ - struct pirq *pirq =3D ptr; - - call_rcu(&pirq->rcu_head, _free_pirq_struct); -} - struct migrate_info { long (*func)(void *data); void *data; diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 160c8dbdab33..b4d202fda9fd 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -44,7 +44,6 @@ void free_vcpu_struct(struct vcpu *v); #ifndef alloc_pirq_struct struct pirq *alloc_pirq_struct(struct domain *); #endif -void free_pirq_struct(void *); =20 /* * Initialise/destroy arch-specific details of a VCPU. --=20 2.11.0