Re: [PATCH v4] mm: fix is_pinnable_page against on cma page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/11/22 15:37, Minchan Kim wrote:
Yes. But one thing that is still unanswered, that I think you can
answer, is: even if the compiler *did* re-read the mt variable, what
problems could that cause? I claim "no problems", because there is
no combination of 0, _CMA, _ISOLATE, _CMA|ISOLATE that will cause
problems here.

What scenario I am concerning with __READ_ONCE so compiler
inlining get_pageblock_migratetype two times are

         CPU 0                                                       CPU 1
                                                                 alloc_contig_range
is_pinnable_page                                                start_isolate_page_range
                                                                   set_pageblock_migratetype(MIGRATE_ISOLATE)
    if (get_pageeblock_migratetype(page) == MIGRATE_CMA)
        so it's false
                                                                 undo:
                                                                   set_pageblock_migratetype(MIGRATE_CMA)
if (get_pageeblock_migratetype(page) == MIGRATE_ISOLATE)
        so it's false

In the end, CMA memory would be pinned by CPU 0 process
so CMA allocation keep failed until the process release the
refcount.


OK, so the code checks the wrong item each time. But the code really
only needs to know "is either _CMA or _ISOLATE set?". And so you
can just sidestep the entire question by writing it like this:

int mt = get_pageblock_migratetype(page);

if (mt & (MIGRATE_ISOLATE | MIGRATE_CMA))
	return false;


...yes?

thanks,
--
John Hubbard
NVIDIA




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux