Re: [PATCH 1/4] mm/mempolicy: kernel_migrate_pages: simplify the usage of put_task_struct()

From: Gregory Price

Date: Tue May 26 2026 - 12:01:02 EST


On Mon, May 25, 2026 at 10:27:06AM +0200, Oleg Nesterov wrote:
> On 05/24, Gregory Price wrote:
> >
> > On Sun, May 24, 2026 at 06:57:59PM +0200, Oleg Nesterov wrote:
> > >
> > > mm = get_task_mm(task);
> > > - put_task_struct(task);
> > > -
> >
> > Hm, I was a little trigger-happy on that review, I just realized that
> > this increases the scope in which there is a task reference held (i.e.
> > we're now holding a reference across do_migrate_pages())
> >
> > I don't *think* that's an issue, but it might we worth looking at the
> > changelog to see if this was done intentionally.
>
> I did this to simplify the code and the next changes. We pin this task's
> memory across do_migrate_pages(), so I think that delaying put_task_struct()
> doesn't add too much.
>
> But of course, this is not necessary, I can rework if you don't like it.
>

Not necessary, just a curiosity whether holding the reference across the
larger scope has any functional difference. Like I said, I don't think
that's an issue, but might be worth just checking the history on the
function to see if it was done that way on purpose.

> Thanks for review!
>
> Oleg.
>