From nobody Fri Dec 19 16:06:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 17389411704311008.1464015022066; Fri, 7 Feb 2025 07:12:50 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id B779D14F5; Fri, 7 Feb 2025 10:12:49 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id CFCB314F9; Fri, 7 Feb 2025 10:12:30 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2D64F14EE; Fri, 7 Feb 2025 10:12:28 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A97CD14E5 for ; Fri, 7 Feb 2025 10:12:27 -0500 (EST) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-412-MOiTz2wOP6Cn2Pg1l-iSaw-1; Fri, 07 Feb 2025 10:12:26 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4361d4e8359so16904805e9.3 for ; Fri, 07 Feb 2025 07:12:25 -0800 (PST) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390db11200sm91727445e9.38.2025.02.07.07.12.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 07:12:23 -0800 (PST) Received: from wheatley.brq.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 7FA22838F7A5 for ; Fri, 07 Feb 2025 16:12:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738941147; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uT0wOSeVX/Ekgv7WjBFIgS60JqFipjNCpyovT2aaQjo=; b=SpaCAQHgrS2HDb4zUU1GyOms13JKWHEkOgBlHaOE2Xtmv0PMXkLv7ltS0qYCSsUfclD8Ir ikQZ/zMZKThys6Kgw4mteIF38q7G6/+JyIuoLqF0ATXq/VQ4/2s2w9A3jng+Cn4FFKCH6M iX0ku399NsUcneJ0nmkiEPKe3IrywX4= X-MC-Unique: MOiTz2wOP6Cn2Pg1l-iSaw-1 X-Mimecast-MFC-AGG-ID: MOiTz2wOP6Cn2Pg1l-iSaw X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738941145; x=1739545945; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uT0wOSeVX/Ekgv7WjBFIgS60JqFipjNCpyovT2aaQjo=; b=lkY0zaNOGnr4zxmfNGacRWLT0LYzt9xRWvqfl0MjHL4deiGxgCkAcd3GyiyCR8oL/V oQrWBekkXgUResOSneguvzuzdmsYGTChebJ3hRxjpdLFWfTr0DHqiSU8Tl80VBeldxqu Ez7hYfXIOzopoTReVxi8qIY0R6StDeo+Talyy2t1eYyLhgEj5/TEEB39a1EPdTxIr3OR 41x/QkrKO2+ljQMD+V8HWvOOvInlgzIwlNFOETdck9P+pmDj8w3xhKN4LNDB0q5BcuwK lXvE7emLQI/zH696hnNwMl3cNURAs3Almz8mwAA/oWUymk6fEEj1pZZfQqoUZOOpzJpt uF5w== X-Gm-Message-State: AOJu0YxlrMUBSgXnjWCCotmJtv+EJio8SAxLh7xaFU2GLiWj4o/qNAku nUu6e4jCGC4EzzbvzWSdQSyTuiebS+Lg2/He2R6s9s35gKGyFMlH2eKrk+tAEbW/YxN2VTmckvm bBfjqmDCXJNijLRRKqlgtkPhUNettJ4r6/Ebd+SmlSGS6aQBnAWLPayvrJkpTZrMAAEWq7MVehD ZYV4Y7Kvv84CINX0mA6iOpXAUqamdaes+aj63J6HM= X-Gm-Gg: ASbGncvv7ME8mur2pShoqNJNm4Rry7TQ6VC4+QqpNoXS4ZlGBd9PSdT47f2Z3mppncZ T793oJuexgAP8fm0uuswQpbUFo0/k6rtqHvGNPcK9Ff5LdaXFHSeY2I3KUyoetouORc1p442ksP USQH8yGndbj9A1Mm22nQ+nnG0Su+l4+BJD/sBg4w1mFOUxgVY/IhvDQgK1gKhP4GmnDM6EEzZTN c/atRTA46aT6SFroxvejVgQ0JuGmW/RYVlsLWJIewxqB6tAs3gFhxqxF3C4OyPYKnYHaq6Bx01v NyhWCPAa8nKHJKXJ27+bK8OKrWWvaIpJcWm014WW X-Received: by 2002:a05:600c:3d0b:b0:431:44f6:566f with SMTP id 5b1f17b1804b1-4392498fc5dmr31491495e9.13.1738941144840; Fri, 07 Feb 2025 07:12:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IERfOLsTqyh6xJg8cXsVRd3fBTKvZPaxi1hxbv1Dq6Trx6iEO5LECv02qBkHSoc5ag2NoN1tQ== X-Received: by 2002:a05:600c:3d0b:b0:431:44f6:566f with SMTP id 5b1f17b1804b1-4392498fc5dmr31491095e9.13.1738941144312; Fri, 07 Feb 2025 07:12:24 -0800 (PST) From: Martin Kletzander To: devel@lists.libvirt.org Subject: [PATCH] node_device: Do not lock the driver state needlessly Date: Fri, 7 Feb 2025 16:12:22 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: vYDPqayIEl2Q86dRxueXOQLaS6P2dnIZ9g-BNYtx6EM_1738941145 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: XPBAAEXDIRISMNRWWRZGRF6WQ3DV4PPB X-Message-ID-Hash: XPBAAEXDIRISMNRWWRZGRF6WQ3DV4PPB X-MailFrom: mkletzan@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1738941173058019000 Content-Type: text/plain; charset="utf-8"; x-default="true" When processing the PCI devices we can only read the configs for each of them if running as privileged. That information is saved in the driver state as a boolean introduced in commit 643c74abff01. However since that version it is only written to once during nodeStateInitialize() and only read from that point (apart from some commits around v3.9.0 release when it was not even set, but that was fixed before v3.10.0). And it is only read once, just to store that boolean in a temporary variable which is also used in only one condition. Rewrite this without locking and save few lines of code. Signed-off-by: Martin Kletzander Reviewed-by: J=C3=A1n Tomko --- src/node_device/node_device_udev.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 7b4ff80f8fb4..be5ee0108c85 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -430,7 +430,6 @@ udevProcessPCI(virNodeDeviceDriverState *driver_state, g_autofree char *linkpath =3D NULL; int ret =3D -1; char *p; - bool privileged =3D false; =20 linkpath =3D g_strdup_printf("%s/config", udev_device_get_syspath(devi= ce)); if (virFileWaitForExists(linkpath, 10, 100) < 0) { @@ -440,10 +439,6 @@ udevProcessPCI(virNodeDeviceDriverState *driver_state, goto cleanup; } =20 - VIR_WITH_MUTEX_LOCK_GUARD(&driver_state->lock) { - privileged =3D driver_state->privileged; - } - pci_dev->klass =3D -1; if (udevGetIntProperty(device, "PCI_CLASS", &pci_dev->klass, 16) < 0) goto cleanup; @@ -491,7 +486,7 @@ udevProcessPCI(virNodeDeviceDriverState *driver_state, goto cleanup; =20 /* We need to be root to read PCI device configs */ - if (privileged) { + if (driver_state->privileged) { if (virPCIGetHeaderType(pciDev, &pci_dev->hdrType) < 0) goto cleanup; =20 --=20 2.48.1