[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5D70A695.60706@huawei.com>
Date: Thu, 5 Sep 2019 14:09:25 +0800
From: zhong jiang <zhongjiang@...wei.com>
To: Matthew Wilcox <willy@...radead.org>
CC: <akpm@...ux-foundation.org>, <vbabka@...e.cz>, <mhocko@...nel.org>,
<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] mm: Unsigned 'nr_pages' always larger than zero
On 2019/9/5 11:12, Matthew Wilcox wrote:
> On Thu, Sep 05, 2019 at 10:17:51AM +0800, zhong jiang wrote:
>> With the help of unsigned_lesser_than_zero.cocci. Unsigned 'nr_pages'
>> compare with zero. And __gup_longterm_locked pass an long local variant
>> 'rc' to check_and_migrate_cma_pages. Hence it is nicer to change the
>> parameter to long to fix the issue.
> I think this patch is right, but I have concerns about this cocci grep.
>
> The code says:
>
> if ((nr_pages > 0) && migrate_allow) {
>
> There's nothing wrong with this (... other than the fact that nr_pages might
> happen to be a negative errno). nr_pages might be 0, and this would be
> exactly the right test for that situation. I suppose some might argue
> that this should be != 0 instead of > 0, but it depends on the situation
> which one would read better.
>
> So please don't blindly make these changes; you're right this time.
Thanks for your affirmation. but Andrew come up with anther fix, using an local long variant
to store the nr_pages. which one do you prefer ?
Thanks,
zhong jiang
Powered by blists - more mailing lists