> That's out of expectation. Every CMA client should expect that CMA
> allocation can be failed since there are a lot of reasons CMA can fail.
Understood, thank you for the clarification!
> Can't we also consider the request size is greater than half the size of
> CMA as well if we want to go this approach?
Actually, my original intention was to introduce retrying only for cases
when the whole region is requested.
But I agree that potentially could be several branches with optimal handling
for some specific cases and one fallback branch with a generic approach.
I tried to emphasize this idea in the following comment:
> > + * Here we have different options depending on each particular case.
> Furthermore, what happens if the CMA is shared with others and remains
> free memory up to only the requested size? In the case, it also returns
> without further retrial
I think that such cases could be covered in a dedicated branch (I mean if-else
branch).
> I am thinking how we can generalize if we want
> to add retrial option to increase success ratio not only entire range
> request but also other cases
By the way, based on my personal observation, moving the requested pages
range may potentially reduce the success ratio for cases when allocation fails
due to isolation tests.
This is because the pages are updated in the direction from the lower indexes
to higher ones. And if page number N doesn't fit isolation requirements, it is
likely that page N+1 doesn't fit the requirements too. Moreover, page N+1 will
be updated and pass the isolation test later than page N!
So moving the requested pages range in the same direction (from lower to
higher indexes) may reduce the success ratio!
Per my understanding, if allocation fails due to an isolation test it would be better
to request again the same region without any shift!
Please keep in mind, that my experience is based on one particular use case,
so I may be wrong!
> At a quick look, I think the CMA client need to handle the failure.
> If they request entire range, they should try harder(e.g., multiple attempts)
> (Just FYI, folks had tried such a retry option multiple times even though
> it was not entire range request since CMA allocation is fragile)
Thank you for providing this comment, I really appreciate it!
I understood that it is not guaranteed that CMA is allocated from the first attempt,
so a module should retry allocation by itself! We will apply the suggested approach!
Just one comment from my side. In my opinion, retrying allocation by a module
would be a perfect solution, if the module knows the exact reason why the allocation
fails (EBUSY, ENOMEM, etc). Based on the actual error code the module may
choose a proper handling for each particular case. Without knowing the exact error code
(but only having a NULL pointer), retrying looks like a kind of workaround rather than
a proper solution.