[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 1/6] xen: add reference counter support
- To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Thu, 16 Mar 2023 17:32:38 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=+5A5UClfPp3pJqednDcydShOlj0zF6zB+PI1wCzxjUo=; b=GW+ywiY7uJzi3hPe5q/O2rhi1VfCCWQ53ewqr0gbWHYKHpBYpeu4hR8CXZzOS6Fq9iYCE8czDF7Q69q0hpATUM4+5eJhqFUKvwwbAmjpcyGgCIAkFzI+ET31JAAMoFP7tWjW/ZYLwzNRTbW8inspdeX0/rGxNA8AIGS9U/kBPC5z9TmiNwjq1y8GGpQri47bQ63GZ1B12Wnoz24SSG6NL6Z0w0EcZ4UmQrzF8pX8I49xIA9B5wsVLn9Q5PUFG8TmSMzvkxWAocg0cwIEMWeckLI3KEivKbOnEYw2GC7sZTtWIzoNkeSDkXmDDhKsz/FGMGdGYWh/PFxo4BaIyyUTkg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cu2+0z//gFUQXWvfpTMgksh8yZEhbHz6Yk02d+8K6I9paqk3UdF6xH641vgvKPhPwFf+flb0+tGs286VuxYgb5DaYY4iLN0ScCxAs7E3w4jMyQ7Ju6IQxfWzSXLF2OTV2Xp3Dol5ruO+mVEEKO4IU7JTLwWeXaDQGtFPLcedCbbn6iJL79x4YWRxzLBnGGS/fkV5nVXpwOPnw+s7gaW6OQg1tSkaK4kPqb1fckNPj/f6N/Mg3twx+/HO/mtD3+1A2fyVMutIbzFJi9LqmxO1AKvmoWgVGlnxkpxxFY7TKUwWLXNsv8jVt8+GWTfqcsdGEFnNcJWuflsd4eVKYxcKJQ==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Thu, 16 Mar 2023 16:32:50 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 16.03.2023 17:19, Roger Pau Monné wrote:
> On Tue, Mar 14, 2023 at 08:56:29PM +0000, Volodymyr Babchuk wrote:
>> +static inline void refcnt_get(refcnt_t *refcnt)
>> +{
>> + int old = atomic_add_unless(&refcnt->refcnt, 1, 0);
>
> Occurred to me while looking at the next patch:
>
> Don't you also need to print a warning (and saturate the counter
> maybe?) if old == 0, as that would imply the caller is attempting
> to take a reference of an object that should be destroyed? IOW: it
> would point to some kind of memory leak.
Hmm, I notice the function presently returns void. I think what to do
when the counter is zero needs leaving to the caller. See e.g.
get_page() which will simply indicate failure to the caller in case
the refcnt is zero. (There overflow handling also is left to the
caller ... All that matters is whether a ref can be acquired.)
Jan
|