[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v6 03/13] vpci: move lock outside of struct vpci
- To: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Tue, 8 Feb 2022 09:57:47 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=r6dl6oDcwP6vNPLsSPRdvGWsCVk6qpkkuzkbgkHQM24=; b=H/DE5BMdOnzdw9H0L99C26dN9flvC58GB+xwE5SoPwbYNulIQrCyK57JBp0Ka8Da6p9UFAOqwPwzojS01USb5B4LfcL3w4ZhXYkgAJCXTudczmoDRc9+aQiSxapcCPRLbXeWutBVB/QFJqLMBMtA/mcNqtt/AqLR9GOT7nVNcmv9OtkK1/z2HSyoScVOxmQSJ83nQdB9fubT8PGvD52VKoGYs517Lq4Z8mmItw1CWY38fz1MsBQLareR5hSknxuAnLPDFwMW3LLpA4CZgxi72NUl8DFQbmaekue2GwJG0OviQ6RDeFg13oexDtPiMjf9X4fXDgy4C3PbSynq0XWkaQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=edp6yAZKeXhGos7Ffh0y2w3rfh132E93j17H5317ad1gM1u8T2MAT/BUjkKE365j02tQaGWFY8tRDKLFl4Hz8MrtrK3oyS5H1I8OU+La60f8fdRQpyAdCG8ojnG2b0RGlBA5SltM7XN0jIcFVqz9okphM3g+Vbp+Cu4VqfcYKKMpeMzRyrlQmcqZqPiWgp2nMDZw6dWLlqVDH9bZ8N9CwhybX36U0l41bc5krpnEIRV4FwFWH+S1SkCHSCwm17+5NfSK+Rtp8jI2w3Tq2xCvk49qwv4E7vgp4SwlarTjN47OqNvLocyiTVKtAioLaJfTl+nJuSqOZayGz0VNGMhpxQ==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Cc: "julien@xxxxxxx" <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, "andrew.cooper3@xxxxxxxxxx" <andrew.cooper3@xxxxxxxxxx>, "george.dunlap@xxxxxxxxxx" <george.dunlap@xxxxxxxxxx>, "paul@xxxxxxx" <paul@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Delivery-date: Tue, 08 Feb 2022 08:57:59 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 08.02.2022 08:35, Oleksandr Andrushchenko wrote:
> 1.1. Semi read lock upgrade in modify bars
> --------------------------------------------------------------
> In this case both vpci_read and vpci_write take a read lock and when it comes
> to modify_bars:
>
> 1. read_unlock(d->vpci_lock)
> 2. write_lock(d->vpci_lock)
> 3. Check that pdev->vpci is still available and is the same object:
> if (pdev->vpci && (pdev->vpci == old_vpci) )
> {
> /* vpci structure is valid and can be used. */
> }
> else
> {
> /* vpci has gone, return an error. */
> }
>
> Pros:
> - no per-device vpci lock is needed?
> - solves overlap code ABBA in modify_bars
> - readers and writers are NOT serialized
> - NO need to carefully select read paths, so they are guaranteed not to lead
> to lock upgrade use-cases
>
> Cons:
> - ???
The "pdev->vpci == old_vpci" is fragile: The struct may have got re-
allocated, and it just so happened that the two pointers are identical.
Same then for the subsequent variant 2.
Jan
|