您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ swapcache_free函数代码示例

51自学网 2021-06-03 08:34:46
  C++
这篇教程C++ swapcache_free函数代码示例写得很实用,希望能帮到您。

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

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

示例1: add_to_swap

int add_to_swap(struct page *page){	swp_entry_t entry;	int err;	VM_BUG_ON(!PageLocked(page));	VM_BUG_ON(!PageUptodate(page));	entry = get_swap_page();	if (!entry.val)		return 0;	if (unlikely(PageTransHuge(page)))		if (unlikely(split_huge_page(page))) {			swapcache_free(entry, NULL);			return 0;		}	err = add_to_swap_cache(page, entry,			__GFP_HIGH|__GFP_NOMEMALLOC|__GFP_NOWARN);	if (!err) {			SetPageDirty(page);		return 1;	} else {			swapcache_free(entry, NULL);		return 0;	}}
开发者ID:Alex-V2,项目名称:One_M8_4.4.3_kernel,代码行数:29,


示例2: add_to_swap

/** * add_to_swap - allocate swap space for a page * @page: page we want to move to swap * * Allocate swap space for the page and add the page to the * swap cache.  Caller needs to hold the page lock.  */int add_to_swap(struct page *page){	swp_entry_t entry;	int err;	VM_BUG_ON(!PageLocked(page));	VM_BUG_ON(!PageUptodate(page));#ifdef CONFIG_HSWAP	if (!current_is_kswapd())		entry = get_lowest_prio_swap_page();	else#endif	entry = get_swap_page();	if (!entry.val)		return 0;	if (unlikely(PageTransHuge(page)))		if (unlikely(split_huge_page(page))) {			swapcache_free(entry, NULL);			return 0;		}	/*	 * Radix-tree node allocations from PF_MEMALLOC contexts could	 * completely exhaust the page allocator. __GFP_NOMEMALLOC	 * stops emergency reserves from being allocated.	 *	 * TODO: this could cause a theoretical memory reclaim	 * deadlock in the swap out path.	 */	/*	 * Add it to the swap cache and mark it dirty	 */	err = add_to_swap_cache(page, entry,			__GFP_HIGH|__GFP_NOMEMALLOC|__GFP_NOWARN);	if (!err) {	/* Success */		SetPageDirty(page);		return 1;	} else {	/* -ENOMEM radix-tree allocation failure */		/*		 * add_to_swap_cache() doesn't return -EEXIST, so we can safely		 * clear SWAP_HAS_CACHE flag.		 */		swapcache_free(entry, NULL);		return 0;	}}
开发者ID:qqzwc,项目名称:Solid_Kernel-G3-STOCK-MM,代码行数:56,


示例3: add_to_swap

/** * add_to_swap - allocate swap space for a page * @page: page we want to move to swap * * Allocate swap space for the page and add the page to the * swap cache.  Caller needs to hold the page lock. */int add_to_swap(struct page *page, struct list_head *list){    swp_entry_t entry;    int err;    VM_BUG_ON_PAGE(!PageLocked(page), page);    VM_BUG_ON_PAGE(!PageUptodate(page), page);    entry = get_swap_page();    if (!entry.val)        return 0;    if (mem_cgroup_try_charge_swap(page, entry)) {        swapcache_free(entry);        return 0;    }    if (unlikely(PageTransHuge(page)))        if (unlikely(split_huge_page_to_list(page, list))) {            swapcache_free(entry);            return 0;        }    /*     * Radix-tree node allocations from PF_MEMALLOC contexts could     * completely exhaust the page allocator. __GFP_NOMEMALLOC     * stops emergency reserves from being allocated.     *     * TODO: this could cause a theoretical memory reclaim     * deadlock in the swap out path.     */    /*     * Add it to the swap cache.     */    err = add_to_swap_cache(page, entry,                            __GFP_HIGH|__GFP_NOMEMALLOC|__GFP_NOWARN);    if (!err) {        return 1;    } else {	/* -ENOMEM radix-tree allocation failure */        /*         * add_to_swap_cache() doesn't return -EEXIST, so we can safely         * clear SWAP_HAS_CACHE flag.         */        swapcache_free(entry);        return 0;    }}
开发者ID:oldzhu,项目名称:linux,代码行数:55,


示例4: delete_from_swap_cache

/** * delete_from_swap_cache:page从交换区高速缓存中删除 */void delete_from_swap_cache(struct page *page){	swp_entry_t entry;	entry.val = page_private(page);	spin_lock_irq(&swapper_space.tree_lock);	__delete_from_swap_cache(page);	spin_unlock_irq(&swapper_space.tree_lock);	swapcache_free(entry, page);	page_cache_release(page);}
开发者ID:yl849646685,项目名称:linux-2.6.32,代码行数:16,


示例5: find_get_page

struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,			struct vm_area_struct *vma, unsigned long addr){	struct page *found_page, *new_page = NULL;	int err;	do {		found_page = find_get_page(&swapper_space, entry.val);		if (found_page)			break;		if (!new_page) {			new_page = alloc_page_vma(gfp_mask, vma, addr);			if (!new_page)				break;				}		err = radix_tree_preload(gfp_mask & GFP_KERNEL);		if (err)			break;		err = swapcache_prepare(entry);		if (err == -EEXIST) {				radix_tree_preload_end();			continue;		}		if (err) {					radix_tree_preload_end();			break;		}				__set_page_locked(new_page);		SetPageSwapBacked(new_page);		err = __add_to_swap_cache(new_page, entry);		if (likely(!err)) {			radix_tree_preload_end();			lru_cache_add_anon(new_page);			swap_readpage(new_page);			return new_page;		}		radix_tree_preload_end();		ClearPageSwapBacked(new_page);		__clear_page_locked(new_page);		swapcache_free(entry, NULL);	} while (err != -ENOMEM);	if (new_page)		page_cache_release(new_page);	return found_page;}
开发者ID:Alex-V2,项目名称:One_M8_4.4.3_kernel,代码行数:51,


示例6: delete_from_swap_cache

/* * This must be called only on pages that have * been verified to be in the swap cache and locked. * It will never put the page into the free list, * the caller has a reference on the page. */void delete_from_swap_cache(struct page *page){    swp_entry_t entry;    struct address_space *address_space;    entry.val = page_private(page);    address_space = swap_address_space(entry);    spin_lock_irq(&address_space->tree_lock);    __delete_from_swap_cache(page);    spin_unlock_irq(&address_space->tree_lock);    swapcache_free(entry);    put_page(page);}
开发者ID:oldzhu,项目名称:linux,代码行数:21,


示例7: find_get_page

/*  * Locate a page of swap in physical memory, reserving swap cache space * and reading the disk if it is not already cached. * A failure return means that either the page allocation failed or that * the swap entry is no longer in use. */struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,			struct vm_area_struct *vma, unsigned long addr){	struct page *found_page, *new_page = NULL;	int err;	do {		/*		 * First check the swap cache.  Since this is normally		 * called after lookup_swap_cache() failed, re-calling		 * that would confuse statistics.		 */		found_page = find_get_page(&swapper_space, entry.val);		if (found_page)			break;		/*		 * Get a new page to read into from swap.		 */		if (!new_page) {			new_page = alloc_page_vma(gfp_mask, vma, addr);			if (!new_page)				break;		/* Out of memory */		}		/*		 * call radix_tree_preload() while we can wait.		 */		err = radix_tree_preload(gfp_mask & GFP_KERNEL);		if (err)			break;		/*		 * Swap entry may have been freed since our caller observed it.		 */		err = swapcache_prepare(entry);		if (err == -EEXIST) {	/* seems racy */			radix_tree_preload_end();			continue;		}		if (err) {		/* swp entry is obsolete ? */			radix_tree_preload_end();			break;		}		/* May fail (-ENOMEM) if radix-tree node allocation failed. */		__set_page_locked(new_page);		SetPageSwapBacked(new_page);		err = __add_to_swap_cache(new_page, entry);		if (likely(!err)) {			radix_tree_preload_end();			/*			 * Initiate read into locked page and return.			 */			lru_cache_add_anon(new_page);			swap_readpage(new_page);			return new_page;		}		radix_tree_preload_end();		ClearPageSwapBacked(new_page);		__clear_page_locked(new_page);		/*		 * add_to_swap_cache() doesn't return -EEXIST, so we can safely		 * clear SWAP_HAS_CACHE flag.		 */		swapcache_free(entry, NULL);	} while (err != -ENOMEM);	if (new_page)		page_cache_release(new_page);	return found_page;}
开发者ID:yl849646685,项目名称:linux-2.6.32,代码行数:78,


示例8: swap_address_space

struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,                                     struct vm_area_struct *vma, unsigned long addr,                                     bool *new_page_allocated){    struct page *found_page, *new_page = NULL;    struct address_space *swapper_space = swap_address_space(entry);    int err;    *new_page_allocated = false;    do {        /*         * First check the swap cache.  Since this is normally         * called after lookup_swap_cache() failed, re-calling         * that would confuse statistics.         */        found_page = find_get_page(swapper_space, entry.val);        if (found_page)            break;        /*         * Get a new page to read into from swap.         */        if (!new_page) {            new_page = alloc_page_vma(gfp_mask, vma, addr);            if (!new_page)                break;		/* Out of memory */        }        /*         * call radix_tree_preload() while we can wait.         */        err = radix_tree_maybe_preload(gfp_mask & GFP_KERNEL);        if (err)            break;        /*         * Swap entry may have been freed since our caller observed it.         */        err = swapcache_prepare(entry);        if (err == -EEXIST) {            radix_tree_preload_end();            /*             * We might race against get_swap_page() and stumble             * across a SWAP_HAS_CACHE swap_map entry whose page             * has not been brought into the swapcache yet, while             * the other end is scheduled away waiting on discard             * I/O completion at scan_swap_map().             *             * In order to avoid turning this transitory state             * into a permanent loop around this -EEXIST case             * if !CONFIG_PREEMPT and the I/O completion happens             * to be waiting on the CPU waitqueue where we are now             * busy looping, we just conditionally invoke the             * scheduler here, if there are some more important             * tasks to run.             */            cond_resched();            continue;        }        if (err) {		/* swp entry is obsolete ? */            radix_tree_preload_end();            break;        }        /* May fail (-ENOMEM) if radix-tree node allocation failed. */        __SetPageLocked(new_page);        __SetPageSwapBacked(new_page);        err = __add_to_swap_cache(new_page, entry);        if (likely(!err)) {            radix_tree_preload_end();            /*             * Initiate read into locked page and return.             */            lru_cache_add_anon(new_page);            *new_page_allocated = true;            return new_page;        }        radix_tree_preload_end();        __ClearPageLocked(new_page);        /*         * add_to_swap_cache() doesn't return -EEXIST, so we can safely         * clear SWAP_HAS_CACHE flag.         */        swapcache_free(entry);    } while (err != -ENOMEM);    if (new_page)        put_page(new_page);    return found_page;}
开发者ID:oldzhu,项目名称:linux,代码行数:90,


示例9: zswap_get_swap_cache_page

/* * zswap_get_swap_cache_page * * This is an adaption of read_swap_cache_async() * * This function tries to find a page with the given swap entry * in the swapper_space address space (the swap cache).  If the page * is found, it is returned in retpage.  Otherwise, a page is allocated, * added to the swap cache, and returned in retpage. * * If success, the swap cache page is returned in retpage * Returns ZSWAP_SWAPCACHE_EXIST if page was already in the swap cache * Returns ZSWAP_SWAPCACHE_NEW if the new page needs to be populated, *     the new page is added to swapcache and locked * Returns ZSWAP_SWAPCACHE_FAIL on error */static int zswap_get_swap_cache_page(swp_entry_t entry,				struct page **retpage){	struct page *found_page, *new_page = NULL;	struct address_space *swapper_space = swap_address_space(entry);	int err;	*retpage = NULL;	do {		/*		 * First check the swap cache.  Since this is normally		 * called after lookup_swap_cache() failed, re-calling		 * that would confuse statistics.		 */		found_page = find_get_page(swapper_space, entry.val);		if (found_page)			break;		/*		 * Get a new page to read into from swap.		 */		if (!new_page) {			new_page = alloc_page(GFP_KERNEL);			if (!new_page)				break; /* Out of memory */		}		/*		 * call radix_tree_preload() while we can wait.		 */		err = radix_tree_preload(GFP_KERNEL);		if (err)			break;		/*		 * Swap entry may have been freed since our caller observed it.		 */		err = swapcache_prepare(entry);		if (err == -EEXIST) { /* seems racy */			radix_tree_preload_end();			continue;		}		if (err) { /* swp entry is obsolete ? */			radix_tree_preload_end();			break;		}		/* May fail (-ENOMEM) if radix-tree node allocation failed. */		__set_page_locked(new_page);		SetPageSwapBacked(new_page);		err = __add_to_swap_cache(new_page, entry);		if (likely(!err)) {			radix_tree_preload_end();			lru_cache_add_anon(new_page);			*retpage = new_page;			return ZSWAP_SWAPCACHE_NEW;		}		radix_tree_preload_end();		ClearPageSwapBacked(new_page);		__clear_page_locked(new_page);		/*		 * add_to_swap_cache() doesn't return -EEXIST, so we can safely		 * clear SWAP_HAS_CACHE flag.		 */		swapcache_free(entry, NULL);	} while (err != -ENOMEM);	if (new_page)		page_cache_release(new_page);	if (!found_page)		return ZSWAP_SWAPCACHE_FAIL;	*retpage = found_page;	return ZSWAP_SWAPCACHE_EXIST;}
开发者ID:barryjabshire,项目名称:SimplKernel-LL-G925F,代码行数:90,



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


C++ swapl函数代码示例
C++ swap_free函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。