- 论坛徽章:
- 0
|
先贴上源码: 注意红色标记
void *__alloc_percpu(size_t size, size_t align)
{
int i;
struct percpu_data *pdata = kmalloc(sizeof (*pdata), GFP_KERNEL);
if (!pdata)
return NULL;
for (i = 0; i < NR_CPUS; i++) {
if (!cpu_possible(i))
continue;
pdata->ptrs = kmem_cache_alloc_node(
kmem_find_general_cachep(size, GFP_KERNEL),
cpu_to_node(i));
if (!pdata->ptrs)
goto unwind_oom;
memset(pdata->ptrs, 0, size);
}
/* Catch derefs w/o wrappers */
return (void *) (~(unsigned long) pdata);
unwind_oom:
while (--i >= 0) {
if (!cpu_possible(i))
continue;
kfree(pdata->ptrs);
}
kfree(pdata);
return NULL;
}
问题是,为什么这里要取反?? |
|