当前位置: 首页>>代码示例>>C++>>正文


C++ page_zone函数代码示例

本文整理汇总了C++中page_zone函数的典型用法代码示例。如果您正苦于以下问题:C++ page_zone函数的具体用法?C++ page_zone怎么用?C++ page_zone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了page_zone函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: release_pages

/*
 * Batched page_cache_release().  Decrement the reference count on all the
 * passed pages.  If it fell to zero then remove the page from the LRU and
 * free it.
 *
 * Avoid taking zone->lru_lock if possible, but if it is taken, retain it
 * for the remainder of the operation.
 *
 * The locking in this function is against shrink_cache(): we recheck the
 * page count inside the lock to see whether shrink_cache grabbed the page
 * via the LRU.  If it did, give up: shrink_cache will free it.
 */
void release_pages(struct page **pages, int nr, int cold)
{
	int i;
	struct pagevec pages_to_free;
	struct zone *zone = NULL;
	unsigned long uninitialized_var(flags);

	pagevec_init(&pages_to_free, cold);
	for (i = 0; i < nr; i++) {
		struct page *page = pages[i];

		if (unlikely(PageCompound(page))) {
			if (zone) {
				spin_unlock_irqrestore(&zone->lru_lock, flags);
				zone = NULL;
			}
			put_compound_page(page);
			continue;
		}
        // dyc: if page->ref not zero, continue
		if (!put_page_testzero(page))
			continue;
        // dyc: if in url, remove from it
		if (PageLRU(page)) {
			struct zone *pagezone = page_zone(page);
			if (pagezone != zone) {
				if (zone)
					spin_unlock_irqrestore(&zone->lru_lock,
									flags);
				zone = pagezone;
				spin_lock_irqsave(&zone->lru_lock, flags);
			}
			VM_BUG_ON(!PageLRU(page));
			__ClearPageLRU(page);
			del_page_from_lru(zone, page);
		}
        // dyc: if no space available after adding
		if (!pagevec_add(&pages_to_free, page)) {
			if (zone) {
				spin_unlock_irqrestore(&zone->lru_lock, flags);
				zone = NULL;
			}
            // dyc: return page to buddy system
			__pagevec_free(&pages_to_free);
			pagevec_reinit(&pages_to_free);
  		}
	} // for (i = 0; i < nr; i++)
	if (zone)
		spin_unlock_irqrestore(&zone->lru_lock, flags);

	pagevec_free(&pages_to_free);
}
开发者ID:dycforever,项目名称:sourceReading,代码行数:64,代码来源:swap.c

示例2: __page_cache_release

/*
 * This path almost never happens for VM activity - pages are normally
 * freed via pagevecs.  But it gets used by networking.
 */
static void __page_cache_release(struct page *page)
{
	if (PageLRU(page)) {
		unsigned long flags;
		struct zone *zone = page_zone(page);

		spin_lock_irqsave(&zone->lru_lock, flags);
		VM_BUG_ON(!PageLRU(page));
		__ClearPageLRU(page);
		del_page_from_lru_list(zone, page, page_off_lru(page));
		spin_unlock_irqrestore(&zone->lru_lock, flags);
	}
}
开发者ID:EddyKuo,项目名称:linux-sdk-kernel-source,代码行数:17,代码来源:swap.c

示例3: activate_page

/*
 * FIXME: speed this up?
 */
void fastcall activate_page(struct page *page)
{
	struct zone *zone = page_zone(page);

	spin_lock_irq(&zone->lru_lock);
	if (PageLRU(page) && !PageActive(page)) {
		del_page_from_inactive_list(zone, page);
		SetPageActive(page);
		add_page_to_active_list(zone, page);
		inc_page_state(pgactivate);
	}
	spin_unlock_irq(&zone->lru_lock);
}
开发者ID:BackupTheBerlios,项目名称:tew632-brp-svn,代码行数:16,代码来源:swap.c

示例4: test_pages_in_a_zone

/*
 * Confirm all pages in a range [start, end) is belongs to the same zone.
 */
static int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn)
{
	unsigned long pfn;
	struct zone *zone = NULL;
	struct page *page;
	int i;
	for (pfn = start_pfn;
	     pfn < end_pfn;
	     pfn += MAX_ORDER_NR_PAGES) {
		i = 0;
		/* This is just a CONFIG_HOLES_IN_ZONE check.*/
		while ((i < MAX_ORDER_NR_PAGES) && !pfn_valid_within(pfn + i))
			i++;
		if (i == MAX_ORDER_NR_PAGES)
			continue;
		page = pfn_to_page(pfn + i);
		if (zone && page_zone(page) != zone)
			return 0;
		zone = page_zone(page);
	}
	return 1;
}
开发者ID:acassis,项目名称:emlinux-ssd1935,代码行数:25,代码来源:memory_hotplug.c

示例5: activate_page

/*
 * FIXME: speed this up?
 */
void fastcall activate_page(struct page *page)
{
	struct zone *zone = page_zone(page);

	spin_lock_irq(&zone->lru_lock);
	if (PageLRU(page) && !PageActive(page)) {
		del_page_from_inactive_list(zone, page);
		SetPageActive(page);
		add_page_to_active_list(zone, page);
		__count_vm_event(PGACTIVATE);
	}
	spin_unlock_irq(&zone->lru_lock);
}
开发者ID:dycforever,项目名称:sourceReading,代码行数:16,代码来源:swap.c

示例6: cma_activate_area

static int __init cma_activate_area(struct cma *cma)
{
	int bitmap_size = BITS_TO_LONGS(cma->count) * sizeof(long);
	unsigned long base_pfn = cma->base_pfn, pfn = base_pfn;
	unsigned i = cma->count >> pageblock_order;
	struct zone *zone;

	cma->bitmap = kzalloc(bitmap_size, GFP_KERNEL);

	if (!cma->bitmap)
		return -ENOMEM;

	WARN_ON_ONCE(!pfn_valid(pfn));
	zone = page_zone(pfn_to_page(pfn));

	do {
		unsigned j;
		base_pfn = pfn;
		for (j = pageblock_nr_pages; j; --j, pfn++) {
			WARN_ON_ONCE(!pfn_valid(pfn));
			/*
			 * alloc_contig_range requires the pfn range
			 * specified to be in the same zone. Make this
			 * simple by forcing the entire CMA resv range
			 * to be in the same zone.
			 */
			if (page_zone(pfn_to_page(pfn)) != zone)
				goto err;
		}
		init_cma_reserved_pageblock(pfn_to_page(base_pfn));
	} while (--i);

	return 0;

err:
	kfree(cma->bitmap);
	return -EINVAL;
}
开发者ID:AdaLovelance,项目名称:lxcGrsecKernels,代码行数:38,代码来源:dma-contiguous.c

示例7: cma_activate_area

static __init int cma_activate_area(unsigned long base_pfn, unsigned long count)
{
	unsigned long pfn = base_pfn;
	unsigned i = count >> pageblock_order;
	struct zone *zone;

	WARN_ON_ONCE(!pfn_valid(pfn));
	zone = page_zone(pfn_to_page(pfn));

	do {
		unsigned j;
		base_pfn = pfn;
		for (j = pageblock_nr_pages; j; --j, pfn++) {
			WARN_ON_ONCE(!pfn_valid(pfn));
			if (page_zone(pfn_to_page(pfn)) != zone) {
				pr_err("%s(%d) err: CMA reserved area should be in common zone\n", __func__, __LINE__);
				return -EINVAL;
			}
		}
		init_cma_reserved_pageblock(pfn_to_page(base_pfn));
	} while (--i);
	return 0;
}
开发者ID:miricy,项目名称:speaker-lichee,代码行数:23,代码来源:dma-contiguous.c

示例8: claim_free_buddy_page

/*
 * Wrest a page from the buddy system.
 *
 * CAVE:
 *
 * This method manipulates buddy-system internal structures to accomplish this
 * goal.
 *
 * Source:
 * This methods implementation has been inspired by  "__rmqueue_smallest"
 */
static inline struct page *
claim_free_buddy_page(struct page * requested) {

    struct page* ret = NULL;

    unsigned int order = 0;
    struct zone *zone;

    int requested_page_count;

    zone = page_zone(requested);
    /* Protect the lru list */
    spin_lock(&zone->lru_lock);

    /* Protect the area */
    spin_lock(&zone->lock);

    requested_page_count = page_count(requested);

    if (likely(0 == requested_page_count) && PageBuddy(requested)) {
        unsigned int current_order;
        struct free_area * area;
        int migratetype;

        migratetype = get_pageblock_migratetype__clone(requested);

        current_order = page_order__clone(requested);

        area = &(zone->free_area[current_order]);

        list_del(&requested->lru);
        rmv_page_order__clone(requested);
        area->nr_free--;
        expand__clone(zone, requested, order, current_order, area, migratetype);

        ret = requested;
    } else {
        printk(KERN_DEBUG "NOT:  likely(0 == requested_page_count {%i}) && PageBuddy(requested){%s} \n", requested_page_count, PageBuddy(requested) ? "true" : "false");
    }

    spin_unlock(&zone->lock);
    spin_unlock(&zone->lru_lock);

    if (ret) {
        if (prep_new_page(ret, 0)) {
            printk(KERN_ALERT "Could not prep_new_page %p, %lu \n", ret, page_to_pfn(ret));
        }
    }
    return ret;
}
开发者ID:IMCG,项目名称:https-github.com-tek-life-kernel-memtest,代码行数:61,代码来源:free_buddy_page_claiming.c

示例9: pagevec_move_tail_fn

static void pagevec_move_tail_fn(struct page *page, void *arg)
{
	int *pgmoved = arg;

	if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) {
		enum lru_list lru = page_lru_base_type(page);
		struct lruvec *lruvec;

		lruvec = mem_cgroup_lru_move_lists(page_zone(page),
						   page, lru, lru);
		list_move_tail(&page->lru, &lruvec->lists[lru]);
		(*pgmoved)++;
	}
}
开发者ID:EddyKuo,项目名称:linux-sdk-kernel-source,代码行数:14,代码来源:swap.c

示例10: cma_activate_area

static __init int cma_activate_area(unsigned long base_pfn, unsigned long count)
{
	unsigned long pfn = base_pfn;
	unsigned i = count >> pageblock_order;
	struct zone *zone;

	WARN_ON_ONCE(!pfn_valid(pfn));
	zone = page_zone(pfn_to_page(pfn));

	do {
		unsigned j;
		base_pfn = pfn;
		for (j = pageblock_nr_pages; j; --j, pfn++) {
			WARN_ON_ONCE(!pfn_valid(pfn));
			if (page_zone(pfn_to_page(pfn)) != zone)
				return -EINVAL;
		}
		init_cma_reserved_pageblock(pfn_to_page(base_pfn));
	} while (--i);
	adjust_managed_cma_page_count(zone, count);

	return 0;
}
开发者ID:alsandeep,项目名称:kernel-4.x,代码行数:23,代码来源:dma-contiguous.c

示例11: __page_cache_release

/*
 * This path almost never happens for VM activity - pages are normally
 * freed via pagevecs.  But it gets used by networking.
 */
void fastcall __page_cache_release(struct page *page)
{
	unsigned long flags;
	struct zone *zone = page_zone(page);

	spin_lock_irqsave(&zone->lru_lock, flags);
	if (TestClearPageLRU(page))
		del_page_from_lru(zone, page);
	if (page_count(page) != 0)
		page = NULL;
	spin_unlock_irqrestore(&zone->lru_lock, flags);
	if (page)
		free_hot_page(page);
}
开发者ID:BackupTheBerlios,项目名称:tew632-brp-svn,代码行数:18,代码来源:swap.c

示例12: __page_cache_release

/*
 * This path almost never happens for VM activity - pages are normally
 * freed via pagevecs.  But it gets used by networking.
 */
static void __page_cache_release(struct page *page)
{
	if (PageLRU(page)) {
		struct zone *zone = page_zone(page);
		struct lruvec *lruvec;
		unsigned long flags;

		spin_lock_irqsave(&zone->lru_lock, flags);
		lruvec = mem_cgroup_page_lruvec(page, zone);
		VM_BUG_ON_PAGE(!PageLRU(page), page);
		__ClearPageLRU(page);
		del_page_from_lru_list(page, lruvec, page_off_lru(page));
		spin_unlock_irqrestore(&zone->lru_lock, flags);
	}
}
开发者ID:7799,项目名称:linux,代码行数:19,代码来源:swap.c

示例13: unset_migratetype_isolate

void unset_migratetype_isolate(struct page *page, unsigned migratetype)
{
	struct zone *zone;
	unsigned long flags, nr_pages;

	zone = page_zone(page);
	spin_lock_irqsave(&zone->lock, flags);
	if (get_pageblock_migratetype(page) != MIGRATE_ISOLATE)
		goto out;
	nr_pages = move_freepages_block(zone, page, migratetype);
	__mod_zone_freepage_state(zone, nr_pages, migratetype);
	set_pageblock_migratetype(page, migratetype);
out:
	spin_unlock_irqrestore(&zone->lock, flags);
}
开发者ID:andrewgreen5610,项目名称:linux,代码行数:15,代码来源:page_isolation.c

示例14: __page_cache_release

/*
 * This path almost never happens for VM activity - pages are normally
 * freed via pagevecs.  But it gets used by networking.
 */
static void __page_cache_release(struct page *page)
{
	if (PageLRU(page)) {
		unsigned long flags;
		struct zone *zone = page_zone(page);

		spin_lock_irqsave(&zone->lru_lock, flags);
		VM_BUG_ON(!PageLRU(page));
		__ClearPageLRU(page);
		del_page_from_lru(zone, page);
		spin_unlock_irqrestore(&zone->lru_lock, flags);
	} else if (PageIONBacked(page)) {
		ClearPageActive(page);
		ClearPageUnevictable(page);
	}
}
开发者ID:svirid75,项目名称:alcatel_ot_4020D_kernel,代码行数:20,代码来源:swap.c

示例15: msm_iommu_pagetable_alloc

int msm_iommu_pagetable_alloc(struct msm_iommu_pt *pt)
{
	pt->fl_table = (unsigned long *)__get_free_pages(GFP_KERNEL,
							  get_order(SZ_16K));
	if (!pt->fl_table)
		return -ENOMEM;

#ifdef CONFIG_LGE_MEMORY_INFO
	__mod_zone_page_state(page_zone(virt_to_page((void *)pt->fl_table)),
							NR_IOMMU_PAGES, (1UL << get_order(SZ_16K)));
#endif
	memset(pt->fl_table, 0, SZ_16K);
	clean_pte(pt->fl_table, pt->fl_table + NUM_FL_PTE, pt->redirect);

	return 0;
}
开发者ID:Carter07,项目名称:Dorimanx-LG-G2-D802-Kernel,代码行数:16,代码来源:msm_iommu_pagetable.c


注:本文中的page_zone函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。