2

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?

Charles
  • 50,943
  • 13
  • 104
  • 142
daisy
  • 22,498
  • 29
  • 129
  • 265

1 Answers1

4

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

Community
  • 1
  • 1
bishop
  • 37,830
  • 11
  • 104
  • 139