[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 1/6] xen: add reference counter support


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 16 Mar 2023 17:39:23 +0100
  • 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=e4Y/IfAsZDMKUgAM9+PkH8rUoGUHG8O3E0KVlxvudLo=; b=ncDLW/kK5XTRP6mAcMBvostApCfKGPFV2F4SY5LiGP+aXa28OKVh79lYhoEpva3YucNZKenJd7bX/RrMwbLcZrzyX8slsbqeb6PZ9gZP3Kvnn8oZbWPh34RDKIiTfZXNZQaVg6/rQs2AP+umH5VHV+OSIWMLw29uWYwyd3wC2wnqekKyeyzDc7a+1O+nI9tpjrTQ4dqssxcresjdzmhehUyHkuXzkMHWtx9CuZkohn3g7sxQiFNwYeqnjymoke4ajg9PZE2n5NMApLCPiu3OkdjkHi9FYh5Jmpt8Ax5ZuDSRzf9Adctr5P6hebkUA58jEu5tFGLFpVPs2OE5Z1lafA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jvQZOj89snpfhDIag1Z2RXTQ1qmBHyZbafwTpw6SBlQBBkEpsHFujap5OXU8RQNjkTRMEIPBqec9xkfO+La311+ksk9kQiO6QKp/tJ2X7a2svAwTfzr24qvfHd5IJmuNGGFTmEtcDw2TtfQi2wHxp3x7D6FMnDhjKpmRqBCG4tkzDYJLxkv1wTx7wr1MRpzNy+qActjYJjd61RY25jhT5cQ6Kx6brm0mT4z4N+quIXNZ5Ie9pdHQ665kkH0B/rW/pWELlx3E2mYqkCr3CERPCprk3GgG5iWL9HuRex+0+6f0fh0raS+NauIgQ9fPOKVB+mdYMw305vdpFRYvUliUyw==
  • 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>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 16 Mar 2023 16:39:50 +0000
  • Ironport-data: A9a23:hihvg64zB/EiwgAXw3Vg1QxRtNrGchMFZxGqfqrLsTDasY5as4F+v jRNXG3UaP6MZmD9eN5yYIq/pk8Au8eGzIJlSgc+/C48Hi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRGvynTraCYnsrLeNdYH9JoQp5nOIkiZJfj9G8Agec0 fv/uMSaM1K+s9JOGjt8B5mr9VU+7JwehBtC5gZlPasS4geB/5UoJMl3yZ+ZfiOQrrZ8RoZWd 86bpJml82XQ+QsaC9/Nut4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5iXBYoUm9Fii3hojxE4 I4lWapc6+seFvakdOw1C3G0GszlVEFM0OevzXOX6aR/w6BaGpdFLjoH4EweZOUlFuhL7W5mp cE4JDctMyC6hMmcmY2RT/dV1sYoM5y+VG8fkikIITDxK98DGMmGaYOaoNhS0XE3m9xEGuvYa 4wBcz1zYR/cYhpJfFAKFJY5m+TujX76G9FagAvN+exrvC6OnEoojumF3Nn9I7RmQe1PmUmVv CTe9nnRCRAGLt2PjzGC9xpAg8eWxXqjBttKRe3QGvhCgkCz+0sUDQAtaEK9pv+XqlaDCtVcJ BlBksYphe1onKCxdfH/VRClpH+PvjYHRsFdVeY97Wml2qfSpgqUGGUAZjpAc8A98t87QyQw0 V2ElM+vAiZg2JWXVHac+7G8vT60fy8PIgcqfjQYRAEI593ipoAbjR/VSNtnVqmvgbXdBjXY0 z2M6i8kiN07s8kP0Kmq+EHdtBilrJPJUw0d6x3eWySu6QYRWWK+T4mh6Fye5/AQKo+cFwCFp CJdxZnY6/0SB5aQkiDLWP8KALyi+/eCNnvbnEJrGJ4isT+q/hZPYLxt3d23H28xWu5sRNMjS BO7Vd95jHOLAEaXUA==
  • Ironport-hdrordr: A9a23:3gKr5K8xJ2WlIW9fV+9uk+AUI+orL9Y04lQ7vn2ZKCYlCfBw8v rFoB11726XtN98YgBEpTn4Atj8fZq+z+8M3WByB8bFYOCOggLBR+FfBO3Zslnd8kXFl9K1vp 0QCpSWZueAamSSuvyKmjVQ0OxN/DBEys2VbCvloEuFHTsaCJ2INz0JejpzyHcGOjWu2KBJaK Z0OvA31gZJFhwsH7uG77A+MdT+mw==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Mar 16, 2023 at 05:32:38PM +0100, Jan Beulich wrote:
> 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.)

Hm, likely.  I guess pages never go away even when it's refcount
reaches 0.

For the pdev case attempting to take a refcount on an object that has
0 refcounts implies that the caller is using leaked memory, as the
point an object reaches 0 it supposed to be destroyed.

Returning success would be fine, as then for the pdev use-case we
could print a warning and likely take some action to prevent further
damage if possible.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.