|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 1 of 2] Global virq for low memory situations
>>> On 28.02.12 at 22:56, Andres Lagar-Cavilla <andres@xxxxxxxxxxxxxxxx> wrote:
> @@ -300,6 +301,91 @@ static unsigned long init_node_heap(int
> return needed;
> }
>
> +/* Default to 64 MiB */
> +#define DEFAULT_LOW_MEM_VIRQ (((paddr_t) 64) << 20)
> +#define MAX_LOW_MEM_VIRQ (((paddr_t) 1024) << 20)
> +
> +static paddr_t __read_mostly opt_low_mem_virq = DEFAULT_LOW_MEM_VIRQ;
> +size_param("low_mem_virq_limit", opt_low_mem_virq);
> +
> +/* Thresholds to control hysteresis. In pages */
> +/* When memory grows above this threshold, reset hysteresis.
> + * -1 initially to not reset until at least one virq issued. */
> +static unsigned long low_mem_virq_high = -1UL;
> +/* Threshold at which we issue virq */
> +static unsigned long low_mem_virq_th = 0;
> +/* Original threshold after all checks completed */
> +static unsigned long low_mem_virq_orig = 0;
> +/* Order for current threshold */
> +static unsigned int low_mem_virq_th_order = 0;
> +
> +/* Perform bootstrapping checks and set bounds */
> +static void __init setup_low_mem_virq(void)
> +{
> + unsigned int order;
> + paddr_t threshold;
> +
> + /* Dom0 has already been allocated by now. So check we won't
> + * be complaining immediately with whatever's left of the heap. */
> + threshold = min(opt_low_mem_virq,
> + ((paddr_t) total_avail_pages) << PAGE_SHIFT);
> +
> + /* Then, cap to some predefined maximum */
> + threshold = min(threshold, MAX_LOW_MEM_VIRQ);
> +
> + /* If the user specified no knob, and we are at the current available
> + * level, halve the threshold. */
> + if ( (opt_low_mem_virq == DEFAULT_LOW_MEM_VIRQ)
This condition being true is not an indication that there was nothing
specified on the command line.
> + && (threshold == (((paddr_t) total_avail_pages) << PAGE_SHIFT)) )
> + threshold >>= 1;
> +
> + /* Threshold bytes -> pages */
> + low_mem_virq_th = threshold >> PAGE_SHIFT;
> +
> + /* Next, round the threshold down to the next order */
> + order = get_order_from_pages(low_mem_virq_th);
This has undefined (and unexpected by you) behavior if
low_mem_virq_th is zero (which I would think ought to mean "disable
this whole logic").
> + if ( (1UL << order) > low_mem_virq_th )
> + order--;
> +
> + /* Set bounds, ready to go */
> + low_mem_virq_th = low_mem_virq_orig = 1UL << order;
> + low_mem_virq_th_order = order;
> +
> + printk("Initial low memory virq threshold set at 0x%lx pages.\n",
> + low_mem_virq_th);
> +}
> +
> +static void check_low_mem_virq(void)
> +{
> + if ( total_avail_pages <= low_mem_virq_th )
> + {
> + send_global_virq(VIRQ_ENOMEM);
> +
> + /* Update thresholds. Next warning will be when we drop below
> + * next order. However, we wait until we grow beyond one
> + * order above us to complain again at the current order */
> + low_mem_virq_high = 1UL << (low_mem_virq_th_order + 1);
> + if ( low_mem_virq_th_order > 0 )
> + low_mem_virq_th_order--;
> + low_mem_virq_th = 1UL << low_mem_virq_th_order;
> + return;
> + }
> +
> + if ( total_avail_pages >= low_mem_virq_high )
> + {
> + /* Reset hysteresis. Bring threshold up one order.
> + * If we are back where originally set, set high
> + * threshold to -1 to avoid further growth of
> + * virq threshold. */
> + low_mem_virq_th_order++;
> + low_mem_virq_th = 1UL << low_mem_virq_th_order;
> + if ( low_mem_virq_th == low_mem_virq_orig )
> + low_mem_virq_high = -1UL;
> + else
> + low_mem_virq_high = 1UL << (low_mem_virq_th_order + 2);
> + }
> +}
> +
> /* Allocate 2^@order contiguous pages. */
> static struct page_info *alloc_heap_pages(
> unsigned int zone_lo, unsigned int zone_hi,
Also, could you please check your patches for not introducing trailing
whitespace?
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |