linux-4.4.1/cma_alloc()
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
*参照元 [#k36c4542]
#backlinks
*説明 [#x060ae1a]
-パス: [[linux-4.4.1/mm/cma.c]]
-FIXME: これは何?
--説明
**引数 [#m2ca9094]
-struct cma *cma
--
--[[linux-4.4.1/cma]]
-size_t count
--
-unsigned int align
--
**返り値 [#k5d5a970]
-struct page *
--
--[[linux-4.4.1/page]]
**参考 [#te23a298]
*実装 [#h0e93adc]
/**
* cma_alloc() - allocate pages from contiguous area
* @cma: Contiguous memory region for which the alloca...
* @count: Requested number of pages.
* @align: Requested alignment of pages (in PAGE_SIZE or...
*
* This function allocates part of contiguous memory on ...
* contiguous memory area.
*/
struct page *cma_alloc(struct cma *cma, size_t count, un...
{
unsigned long mask, offset;
unsigned long pfn = -1;
unsigned long start = 0;
unsigned long bitmap_maxno, bitmap_no, bitmap_co...
struct page *page = NULL;
int ret;
if (!cma || !cma->count)
return NULL;
pr_debug("%s(cma %p, count %zu, align %d)\n", __...
count, align);
-
--[[linux-4.4.1/pr_debug()]]
if (!count)
return NULL;
mask = cma_bitmap_aligned_mask(cma, align);
offset = cma_bitmap_aligned_offset(cma, align);
bitmap_maxno = cma_bitmap_maxno(cma);
bitmap_count = cma_bitmap_pages_to_bits(cma, cou...
-
--[[linux-4.4.1/cma_bitmap_aligned_mask()]]
--[[linux-4.4.1/cma_bitmap_aligned_offset()]]
--[[linux-4.4.1/cma_bitmap_maxno()]]
--[[linux-4.4.1/cma_bitmap_pages_to_bits()]]
for (;;) {
mutex_lock(&cma->lock);
bitmap_no = bitmap_find_next_zero_area_o...
bitmap_maxno, start, bit...
offset);
-
--[[linux-4.4.1/mutex_lock()]]
--[[linux-4.4.1/bitmap_find_next_zero_area_off()]]
if (bitmap_no >= bitmap_maxno) {
mutex_unlock(&cma->lock);
break;
}
bitmap_set(cma->bitmap, bitmap_no, bitma...
-
--[[linux-4.4.1/mutex_unlock()]]
--[[linux-4.4.1/bitmap_set()]]
/*
* It's safe to drop the lock here. We'v...
* our exclusive use. If the migration f...
* lock again and unmark it.
*/
mutex_unlock(&cma->lock);
pfn = cma->base_pfn + (bitmap_no << cma-...
mutex_lock(&cma_mutex);
ret = alloc_contig_range(pfn, pfn + coun...
mutex_unlock(&cma_mutex);
-
--[[linux-4.4.1/alloc_contig_range()]]
--[[linux-4.4.1/MIGRATE_CMA]]
if (ret == 0) {
page = pfn_to_page(pfn);
break;
}
-
--[[linux-4.4.1/pfn_to_page()]]
cma_clear_bitmap(cma, pfn, count);
if (ret != -EBUSY)
break;
-
--[[linux-4.4.1/cma_clear_bitmap()]]
pr_debug("%s(): memory range at %p is bu...
__func__, pfn_to_page(pfn));
/* try again with a bit different memory...
start = bitmap_no + mask + 1;
}
trace_cma_alloc(pfn, page, count, align);
-
--[[linux-4.4.1/trace_cma_alloc()]]
pr_debug("%s(): returned %p\n", __func__, page);
return page;
}
*コメント [#o7fb96ad]
終了行:
*参照元 [#k36c4542]
#backlinks
*説明 [#x060ae1a]
-パス: [[linux-4.4.1/mm/cma.c]]
-FIXME: これは何?
--説明
**引数 [#m2ca9094]
-struct cma *cma
--
--[[linux-4.4.1/cma]]
-size_t count
--
-unsigned int align
--
**返り値 [#k5d5a970]
-struct page *
--
--[[linux-4.4.1/page]]
**参考 [#te23a298]
*実装 [#h0e93adc]
/**
* cma_alloc() - allocate pages from contiguous area
* @cma: Contiguous memory region for which the alloca...
* @count: Requested number of pages.
* @align: Requested alignment of pages (in PAGE_SIZE or...
*
* This function allocates part of contiguous memory on ...
* contiguous memory area.
*/
struct page *cma_alloc(struct cma *cma, size_t count, un...
{
unsigned long mask, offset;
unsigned long pfn = -1;
unsigned long start = 0;
unsigned long bitmap_maxno, bitmap_no, bitmap_co...
struct page *page = NULL;
int ret;
if (!cma || !cma->count)
return NULL;
pr_debug("%s(cma %p, count %zu, align %d)\n", __...
count, align);
-
--[[linux-4.4.1/pr_debug()]]
if (!count)
return NULL;
mask = cma_bitmap_aligned_mask(cma, align);
offset = cma_bitmap_aligned_offset(cma, align);
bitmap_maxno = cma_bitmap_maxno(cma);
bitmap_count = cma_bitmap_pages_to_bits(cma, cou...
-
--[[linux-4.4.1/cma_bitmap_aligned_mask()]]
--[[linux-4.4.1/cma_bitmap_aligned_offset()]]
--[[linux-4.4.1/cma_bitmap_maxno()]]
--[[linux-4.4.1/cma_bitmap_pages_to_bits()]]
for (;;) {
mutex_lock(&cma->lock);
bitmap_no = bitmap_find_next_zero_area_o...
bitmap_maxno, start, bit...
offset);
-
--[[linux-4.4.1/mutex_lock()]]
--[[linux-4.4.1/bitmap_find_next_zero_area_off()]]
if (bitmap_no >= bitmap_maxno) {
mutex_unlock(&cma->lock);
break;
}
bitmap_set(cma->bitmap, bitmap_no, bitma...
-
--[[linux-4.4.1/mutex_unlock()]]
--[[linux-4.4.1/bitmap_set()]]
/*
* It's safe to drop the lock here. We'v...
* our exclusive use. If the migration f...
* lock again and unmark it.
*/
mutex_unlock(&cma->lock);
pfn = cma->base_pfn + (bitmap_no << cma-...
mutex_lock(&cma_mutex);
ret = alloc_contig_range(pfn, pfn + coun...
mutex_unlock(&cma_mutex);
-
--[[linux-4.4.1/alloc_contig_range()]]
--[[linux-4.4.1/MIGRATE_CMA]]
if (ret == 0) {
page = pfn_to_page(pfn);
break;
}
-
--[[linux-4.4.1/pfn_to_page()]]
cma_clear_bitmap(cma, pfn, count);
if (ret != -EBUSY)
break;
-
--[[linux-4.4.1/cma_clear_bitmap()]]
pr_debug("%s(): memory range at %p is bu...
__func__, pfn_to_page(pfn));
/* try again with a bit different memory...
start = bitmap_no + mask + 1;
}
trace_cma_alloc(pfn, page, count, align);
-
--[[linux-4.4.1/trace_cma_alloc()]]
pr_debug("%s(): returned %p\n", __func__, page);
return page;
}
*コメント [#o7fb96ad]
ページ名: