Message ID | 20230213140812.db63c7146ebc396691594b73@linux-foundation.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [GIT,PULL] hotfixes for 6.2 | expand |
On Mon, Feb 13, 2023 at 2:08 PM Andrew Morton <akpm@linux-foundation.org> wrote: > > Kuan-Ying Lee (1): > mm/gup: add folio to list when folio_isolate_lru() succeed Ugh. I really hate fixes like this. The problem came from mis-understanding the return value of folio_isolate_lru(), and thinking that it was a boolean success/failure thing. It wasn't, it was an integer "success/errno" thing, and the sense of the test was wrong. So the patch is - if (!folio_isolate_lru(folio)) + if (folio_isolate_lru(folio)) continue; but at no point was the code *clarified*. Wouldn't it have been much better to write the new code to be if (folio_isolate_lru(folio) < 0) continue; to actually make it clear that this is a "negative error return check". I've pulled this, but I really think that when somebody notices that we had a silly bug because of a misunderstanding like this, it's not just that the bug should be fixed, the code should also be *clarified* at the same time. Linus
The pull request you sent on Mon, 13 Feb 2023 14:08:12 -0800:
> git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm tags/mm-hotfixes-stable-2023-02-13-13-50
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/f6feea56f66d34259c4222fa02e8171c4f2673d1
Thank you!
On 2/14/2023 6:19 AM, Linus Torvalds wrote: > On Mon, Feb 13, 2023 at 2:08 PM Andrew Morton <akpm@linux-foundation.org> wrote: >> >> Kuan-Ying Lee (1): >> mm/gup: add folio to list when folio_isolate_lru() succeed > > Ugh. I really hate fixes like this. > > The problem came from mis-understanding the return value of > folio_isolate_lru(), and thinking that it was a boolean > success/failure thing. > > It wasn't, it was an integer "success/errno" thing, and the sense of > the test was wrong. So the patch is > > - if (!folio_isolate_lru(folio)) > + if (folio_isolate_lru(folio)) > continue; > > but at no point was the code *clarified*. > > Wouldn't it have been much better to write the new code to be > > if (folio_isolate_lru(folio) < 0) > continue; > > to actually make it clear that this is a "negative error return check". > > I've pulled this, but I really think that when somebody notices that > we had a silly bug because of a misunderstanding like this, it's not > just that the bug should be fixed, the code should also be *clarified* > at the same time. Yes, agree, I need to check the return value of folio_isolate_lru() every time when looking at the code. I can help to create a patch to make it clear for all users.