문제

I found that on linux 3.0+ GFP_ZERO is no longer defined in headers.

All I found in gfp.h was,

/* Plain integer GFP bitmasks. Do not use this directly. */
...
#define ___GFP_ZERO     0x8000u

I've checked those "exported" bit masks, on one uses GFP_ZERO.

And the author says Do not use this directly, so, how should I get zeroed page,

Is kmalloc + memset the only option I have now?

도움이 되었습니까?

해결책

I think the expected way to zero is kzalloc():

https://www.kernel.org/doc/htmldocs/kernel-api/API-kzalloc.html

but obviously alloc + memset works too.

Update

Sample diff from CFQ showing the expected updates:

-   cfqd = kmalloc_node(sizeof(*cfqd), GFP_KERNEL | __GFP_ZERO, q->node);
+   cfqd = kzalloc_node(sizeof(*cfqd), GFP_KERNEL, q->node);

See also this: https://stackoverflow.com/a/12095263/2908724

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top