Skip to contentSkip to conversation

Question About Functions "__free_pages_check" and "check_new_page" in page_alloc.c

DISCUSSION Wang Xiaoqiang 3 participants 5 messages May 16, 2016 – May 17, 2016 Memory management

lore
Share & tools
lore
#0 lore raw

Hi all,

I am really confused about these two functions. The following code snippet:

if(unlikely(atomic_read(&page->_mapcount) != -1))

		bad_reason ="nonzero mapcount";if(unlikely(page->mapping != NULL))
		bad_reason ="non-NULL mapping";if(unlikely(page_ref_count(page) !=0))
		bad_reason ="nonzero _count";
        ...

Wouldn't the previous value of "bad_reason" be overwritten by the later? Hope to receive from you.

--

thx!
Wang Xiaoqiang

#1 lore raw
Quoted 11 lines · Wang Xiaoqiang

Hi all,

I am really confused about these two functions. The following code snippet:

if(unlikely(atomic_read(&page->_mapcount) != -1))

		bad_reason ="nonzero mapcount";if(unlikely(page->mapping != NULL))
		bad_reason ="non-NULL mapping";if(unlikely(page_ref_count(page) !=0))
		bad_reason ="nonzero _count";
        ...

Wouldn't the previous value of "bad_reason" be overwritten by the later? Hope to receive from you.

yes it would. Why that would matter. The checks should be in an order which could give us a more specific reason with later checks. bad_page() will then print more detailed information.

Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw
Quoted 2 lines

yes it would. Why that would matter. The checks should be in an order which could give us a more specific reason with later checks. bad_page()

I see, you mean the later "bad_reason" is the superset of the previous one.

Quoted 4 lines

will then print more detailed information.
--
Michal Hocko
SUSE Labs

thank you, Michal.

#3 lore raw
Quoted 4 lines · Wang Xiaoqiang
Quoted 2 lines

yes it would. Why that would matter. The checks should be in an order which could give us a more specific reason with later checks. bad_page()

I see, you mean the later "bad_reason" is the superset of the previous one.

Not exactly. It's not possible to sort all the reasons like that. But as Michal said, bad_page() will print all the relevant info so you can reconstruct all reasons from it. The bad_reason text is mostly a hint what to check first.

Quoted 10 lines
Quoted 4 lines

will then print more detailed information.
--
Michal Hocko
SUSE Labs

thank you, Michal.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw

thank you very much! Vlastimil.

Quoted 17 lines · Vlastimil Babka
Quoted 4 lines · Wang Xiaoqiang
Quoted 2 lines

yes it would. Why that would matter. The checks should be in an order which could give us a more specific reason with later checks. bad_page()

I see, you mean the later "bad_reason" is the superset of the previous one.

Not exactly. It's not possible to sort all the reasons like that. But as Michal said, bad_page() will print all the relevant info so you can reconstruct all reasons from it. The bad_reason text is mostly a hint what to check first.

Quoted 6 lines
Quoted 4 lines

will then print more detailed information.
--
Michal Hocko
SUSE Labs

thank you, Michal.