Question about __zone_watermark_ok: why there is a "+ 1" in computing free_pages?

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

 



In line 1459, we have "free_pages -= (1 << order) + 1;".
Suppose allocating one 0-order page, here we'll get
    free_pages -= 1 + 1
I wonder why there is a "+ 1"?

1448/*
1449 * Return true if free pages are above 'mark'. This takes into account the order
1450 * of the allocation.
1451 */
1452static bool __zone_watermark_ok(struct zone *z, int order, unsigned long mark,
1453                      int classzone_idx, int alloc_flags, long free_pages)
1454{
1455        /* free_pages my go negative - that's OK */
1456        long min = mark;
1457        int o;
1458
1459        free_pages -= (1 << order) + 1;
1460        if (alloc_flags & ALLOC_HIGH)
1461                min -= min / 2;
1462        if (alloc_flags & ALLOC_HARDER)
1463                min -= min / 4;
1464
1465        if (free_pages <= min + z->lowmem_reserve[classzone_idx])
1466                return false;
1467        for (o = 0; o < order; o++) {
1468                /* At the next order, this order's pages become unavailable */
1469                free_pages -= z->free_area[o].nr_free << o;
1470
1471                /* Require fewer higher order pages to be free */
1472                min >>= 1;
1473
1474                if (free_pages <= min)
1475                        return false;
1476        }
1477        return true;
1478}



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]