[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 1/6] xen: add reference counter support
- To: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Wed, 12 Apr 2023 12:12:06 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; 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=XGLAXe+N1thtgbkL0MNg4MOYeKvGBwUt6nAxSEZ7hAE=; b=bU2WHp39JQw32OAfFvhVPcjDP8StWjuHN8uc5H65YhPkPDFeajMnZFQpq7OhSooPbEqcrBT9KrAk048RMn0O5Gj29doBTviIcLTf7nBqXa448nmuM6C79LKHQ/LwM7o5bVNcSHLATOo49xYRDKwLR03Rg8815vFogbjOU7PqYu5OuDfAxrq1VzwduHWqT5wOgSAPrIBvopryCtvaP5h/+EcZzusvvFCQAul25PGpPomiOxzM6JO7EYbX+1llgfPm6brcv6tKdCJZ7+MMFtSp6YGrzpcAFim/ICYnrxSy9uyfQmjFDnqlDcSRxIahtK7ToxKIFssdcXp2JOR+JMaIEA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kjaZUU1gW5/aoVSRY5GSDXFZrVphfdUWzFMmjXqe6lXybFJVyjYRKY0Fzl4gQ2amX58cj0KpGFSy5yllhKy5jYUp6B3UNiWcAcm7GGDGoksDW88pF3BJns32oNxTTXm/xhz+KJmGIBngWvvt8bkw8iZR7dk4SuCUBLyf2OyfodBPRAX3C6aLE/Mfkx9NvFLs/LwQ2IxIgjA28QiQx5ZXTUotlJDtSIacSsLKGCWFwRR4rVB1BNvkSQPRvgmv5Xm6ebuFNljhIMN/k508Mf//0MFFvCDM9na+V36oIrSSKKslDkDFGKYRYJHgPFnvEUl8psuXarY1WczamQfPMP0MwQ==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Wed, 12 Apr 2023 10:12:34 +0000
- Ironport-data: A9a23:M0iZQ6D5b6woVxVW/8viw5YqxClBgxIJ4kV8jS/XYbTApDl01zJWn GZOCDyOPK3eY2b2c48gO4vi9ENV6J7Wz95hQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbyRFu8pvlDs15K6p4G9B5ARkDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw4MxSWzFl8 84hOW4HQR/c3eSm8Zy5Y7w57igjBJGD0II3nFhFlGicIdN4BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTI+uxuvDS7IA9ZidABNPLPfdOHX4NNl1uwr WPa5WXpRBodMbRzzBLcqi7x27+QwHmTtIQ6CbOW+v9IsVyogS8XWC0WT2SYkKKchRvrMz5YA wlOksY0loAM80isQsj4TgePineOtR4BWPJdC+Q/rgqKz8L88wufQ2QJUDNFQNgnr9MtAywn0 EeTmNHkDiApt6eaIVqf/LqJqTK5OQAOMHQPIyQDSGMt4cTnoYw1pgLCSJBkCqHdpsbuBTj6z jSOrS4/r7Yel8gG0+O851+vqy2ojojESEgy/Aq/Y46+xgZwZYrga4n271HetK9ENNzAEQXHu 2UYkc+D6uxIFYuKiCGGXOQKGveu+uqBNzrfx1VoGvHN6giQxpJqRqgIiBkWGaujGpxslePBC KMLhT5s2Q==
- Ironport-hdrordr: A9a23:xWYB7K15bhx7g/Yd09QZCgqjBQhyeYIsimQD101hICG9Lfb0qy n+pp4mPEHP4wr5AEtQ4uxpOMG7MBDhHO1OkPMs1NaZLULbUQ6TQL2KgrGSpAEIdxeeygcZ79 YZT0EcMqy7MbEZt7ed3ODQKb9Jr7e6GeKT9J7jJhxWPGNXgtRbnmNE43GgYyhLrWd9ZaYRJd 653I5qtjCgcXMYYoCQHX8eRdXOoNXNidbPfQMGLwRP0njDsRqYrJrBVzSI1BYXVD1ChZ0493 LergD/7qK/99mm1x7n0XPJ5Zg+oqqv9jIDPr3DtiEmEESttu+aXvUjZ1REhkF2nAib0idqrD ALmWZkAy080QKUQoj/m2qQ5+Cp6kdQ11bSjXuVhmbip8viLQhKdvapw7gpPycxonBQwu1Uwe ZF2XmUuIFQCg6FlCPh58LQXxUvjUasp2E++NRj+UC3fLFuHIO5l7Zvi399AdMFBmb3+YonGO 5hAIXV4+tXa0qTazTcsnN0yNKhU3wvFlPeK3Jy8vC9wnxThjR03kEYzMsQkjMJ8488UYBN46 DBPr5znL9DQ8cKZeZ2BfsHQ8GwFmvRKCi8eV66MBDiDuUKKnjNo5n47PE84/yrYoUByN8olJ HIQDpjxBsPkoLVeL+zNbFwg2PwqT+GLEXQI+llluhEhoE=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Tue, Apr 11, 2023 at 10:27:45PM +0000, Volodymyr Babchuk wrote:
>
> Hello Roger,
>
> Sorry for the late answer.
>
> Roger Pau Monné <roger.pau@xxxxxxxxxx> writes:
>
> > On Tue, Mar 14, 2023 at 08:56:29PM +0000, Volodymyr Babchuk wrote:
> >> We can use reference counter to ease up object lifetime management.
> >> This patch adds very basic support for reference counters. refcnt
> >> should be used in the following way:
> >>
> >> 1. Protected structure should have refcnt_t field
> >>
> >> 2. This field should be initialized with refcnt_init() during object
> >> construction.
> >>
> >> 3. If code holds a valid pointer to a structure/object it can increase
> >> refcount with refcnt_get(). No additional locking is required.
> >>
> >> 4. Code should call refcnt_put() before dropping pointer to a
> >> protected structure. `destructor` is a call back function that should
> >> destruct object and free all resources, including structure protected
> >> itself. Destructor will be called if reference counter reaches zero.
> >>
> >> 5. If code does not hold a valid pointer to a protected structure it
> >> should use other locking mechanism to obtain a pointer. For example,
> >> it should lock a list that hold protected objects.
> >
> > Sorry, I didn't look at the previous versions, but did we consider
> > importing refcount_t and related logic from Linux?
>
> Well, I considered this. But it is more complex. It has separate
> refcount module, which just counts references + kref code, that is
> capable of calling destructors. I am not sure if Xen need this
> division. In any case, I tried to replicate Linux behavior as close as
> possible. On other hand, Jan suggests to rework API, so it will be
> differ from Linux one...
OK, just asking because it's likely for the interface to grow if there
are more users of refcounting, and at some point we might need a set
of features similar to Linux.
Thanks, Roger.
|