From nobody Fri May 16 05:09:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501156063622942.9597044994526; Thu, 27 Jul 2017 04:47:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C77C8B134; Thu, 27 Jul 2017 11:47:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 757CA6C42F; Thu, 27 Jul 2017 11:47:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 23C23180B467; Thu, 27 Jul 2017 11:47:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6RBlZUP028573 for ; Thu, 27 Jul 2017 07:47:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id E00405D72E; Thu, 27 Jul 2017 11:47:35 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6974C5D72D for ; Thu, 27 Jul 2017 11:47:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9C77C8B134 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 27 Jul 2017 13:47:25 +0200 Message-Id: <74d99eb7b207d56d9f7099ad9fd66ab7e0e270e2.1501155886.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/7] virNodeDeviceObjList: Derive from virObjectRWLockable X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 27 Jul 2017 11:47:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There is no reason why two threads trying to look up two node devices should mutually exclude each other. Utilize new virObjectRWLockable that was just introduced. Signed-off-by: Michal Privoznik --- src/conf/virnodedeviceobj.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 3ab93a3ea..808365e21 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -40,7 +40,7 @@ struct _virNodeDeviceObj { }; =20 struct _virNodeDeviceObjList { - virObjectLockable parent; + virObjectRWLockable parent; =20 /* name string -> virNodeDeviceObj mapping * for O(1), lockless lookup-by-name */ @@ -63,7 +63,7 @@ virNodeDeviceObjOnceInit(void) virNodeDeviceObjDispose))) return -1; =20 - if (!(virNodeDeviceObjListClass =3D virClassNew(virClassForObjectLocka= ble(), + if (!(virNodeDeviceObjListClass =3D virClassNew(virClassForObjectRWLoc= kable(), "virNodeDeviceObjList", sizeof(virNodeDeviceObjL= ist), virNodeDeviceObjListDisp= ose))) @@ -231,7 +231,7 @@ virNodeDeviceObjListSearch(virNodeDeviceObjListPtr devs, { virNodeDeviceObjPtr obj; =20 - virObjectLock(devs); + virObjectLockRead(devs); obj =3D virHashSearch(devs->objs, callback, data, NULL); virObjectRef(obj); virObjectUnlock(devs); @@ -284,7 +284,7 @@ virNodeDeviceObjListFindByName(virNodeDeviceObjListPtr = devs, { virNodeDeviceObjPtr obj; =20 - virObjectLock(devs); + virObjectLockRead(devs); obj =3D virNodeDeviceObjListFindByNameLocked(devs, name); virObjectUnlock(devs); if (obj) @@ -462,7 +462,7 @@ virNodeDeviceObjListNew(void) if (virNodeDeviceObjInitialize() < 0) return NULL; =20 - if (!(devs =3D virObjectLockableNew(virNodeDeviceObjListClass))) + if (!(devs =3D virObjectRWLockableNew(virNodeDeviceObjListClass))) return NULL; =20 if (!(devs->objs =3D virHashCreate(50, virObjectFreeHashData))) { @@ -767,7 +767,7 @@ virNodeDeviceObjListNumOfDevices(virNodeDeviceObjListPt= r devs, struct virNodeDeviceCountData data =3D { .conn =3D conn, .aclfilter =3D aclfilter, .matchstr =3D cap, .coun= t =3D 0 }; =20 - virObjectLock(devs); + virObjectLockRead(devs); virHashForEach(devs->objs, virNodeDeviceObjListNumOfDevicesCallback, &= data); virObjectUnlock(devs); =20 @@ -828,7 +828,7 @@ virNodeDeviceObjListGetNames(virNodeDeviceObjListPtr de= vs, .conn =3D conn, .aclfilter =3D aclfilter, .matchstr =3D cap, .name= s =3D names, .nnames =3D 0, .maxnames =3D maxnames, .error =3D false }; =20 - virObjectLock(devs); + virObjectLockRead(devs); virHashForEach(devs->objs, virNodeDeviceObjListGetNamesCallback, &data= ); virObjectUnlock(devs); =20 @@ -932,7 +932,7 @@ virNodeDeviceObjListExport(virConnectPtr conn, .conn =3D conn, .aclfilter =3D aclfilter, .flags =3D flags, .devices =3D NULL, .ndevices =3D 0, .error =3D false }; =20 - virObjectLock(devs); + virObjectLockRead(devs); if (devices && VIR_ALLOC_N(data.devices, virHashSize(devs->objs) + 1) < 0) { virObjectUnlock(devs); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list