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

Re: [Xen-devel] [PATCH] timers: limit heap size





On 09/04/2019 16:17, Jan Beulich wrote:
On 09.04.19 at 15:38, <andrew.cooper3@xxxxxxxxxx> wrote:
On 09/04/2019 14:01, Jan Beulich wrote:
@@ -463,9 +463,14 @@ static void timer_softirq_action(void)
      if ( unlikely(ts->list != NULL) )
      {
          /* old_limit == (2^n)-1; new_limit == (2^(n+4))-1 */
-        int old_limit = heap_metadata(heap)->limit;
-        int new_limit = ((old_limit + 1) << 4) - 1;
-        struct timer **newheap = xmalloc_array(struct timer *, new_limit +
1);
+        unsigned int old_limit = heap_metadata(heap)->limit;
+        unsigned int new_limit = ((old_limit + 1) << 4) - 1;
+        struct timer **newheap = NULL;
+
+        /* Don't grow the heap beyond what is representable in its metadata. */
+        if ( new_limit == (typeof(heap_metadata(heap)->limit))new_limit &&
+             new_limit + 1 )
+            newheap = xmalloc_array(struct timer *, new_limit + 1);

It would probably be helpful to have a warn_once/print_once in the case
that we do hit the metadata limit

I can do this, albeit the lack of the constructs you suggest will
make this a little ugly.

Macros implementing such behavior would be more than welcomed. We tend to open-code WARN_ONCE/PRINT_ONCE logic in every place which is not very nice.

Cheers,

--
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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