On 7/16/19 7:18 PM, Yang Shi wrote:
Hm I guess you're right, returning with EIO means nothing was queued.I think after your patch, you miss putback_movable_pages() in casesYes, the old code had putback_movable_pages called when !err. But, I
where some were queued, and later the walk returned -EIO. The previous
code doesn't miss it, but it's also not obvious due to the multiple if
(!err) checks. I would rewrite it some thing like this:
if (ret < 0) {
putback_movable_pages(&pagelist);
err = ret;
goto mmap_out; // a new label above up_write()
}
think that is for error handling of mbind_range() if I understand it
correctly since if queue_pages_range() returns -EIO (only MPOL_MF_STRICT
was specified and there was misplaced page) that page list should be
empty . The old code should checked whether that list is empty or not.
So, in the new code I just removed that.Checkpatch probably doesn't catch it, nor did the reviewers of the older
The rest can have reduced identation now.Yes, the goto does eliminate the extra indentation.
Really? The old code doesn't have '{ }' for else, and checkpatch doesn't+ else {While at it, IIRC the kernel style says that when the 'if' part uses
+ err = mbind_range(mm, start, end, new);
- if (nr_failed && (flags & MPOL_MF_STRICT))
- err = -EIO;
- } else
- putback_movable_pages(&pagelist);
+ if (!err) {
+ int nr_failed = 0;
+
+ if (!list_empty(&pagelist)) {
+ WARN_ON_ONCE(flags & MPOL_MF_LAZY);
+ nr_failed = migrate_pages(&pagelist, new_page,
+ NULL, start, MIGRATE_SYNC,
+ MR_MEMPOLICY_MBIND);
+ if (nr_failed)
+ putback_movable_pages(&pagelist);
+ }
+
+ if ((ret > 0) ||
+ (nr_failed && (flags & MPOL_MF_STRICT)))
+ err = -EIO;
+ } else
+ putback_movable_pages(&pagelist);
'{ }' then the 'else' part should as well, and it shouldn't be mixed.
report any error or warning.
code. But coding-style.rst says:
Do not unnecessarily use braces where a single statement will do.
...
This does not apply if only one branch of a conditional statement is a
single
statement; in the latter case use braces in both branches:
.. code-block:: c
if (condition) {
do_this();
do_that();
} else {
otherwise();
}
Thanks,
Vlastimil