linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
	 "David Hildenbrand (Arm)" <david@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	 Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	Zi Yan <ziy@nvidia.com>,
	 "Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Nico Pache <npache@redhat.com>,
	 Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
	Barry Song <baohua@kernel.org>,
	 Lance Yang <lance.yang@linux.dev>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [stable-6.6.y] mm: khugepaged refuses to freeze
Date: Tue, 10 Feb 2026 19:12:10 +0900	[thread overview]
Message-ID: <zlqncghw2xfhi73fwgotiz7ziaxrhrnnk5wv2tpdqkuksk2bol@jovasy65p4s5> (raw)
In-Reply-To: <a6e73466-030f-4b9d-a0b8-502916c139f8@linux.alibaba.com>

On (26/02/10 18:07), Baolin Wang wrote:
> > > > Do you mean “struct dev_pm_ops”, which is used to register PM callbacks
> > > > for devices? However, I don’t know how to use it with a kernel thread.
> > > > 
> > > > Also look at how kswapd does it, kswapd also uses
> > > > kthread_freezable_should_stop() to check the freeze state.
> > > 
> > > Right, mimicking what kswapd does sound reasonable!
> > 
> > I may be missing something, as I'm not seeing dev_pm_ops in vmscan code.
> > Would something like this work?
> > 
> > ---
> > 
> > diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> > index fa6a018b20a8..c5d89ec223d3 100644
> > --- a/mm/khugepaged.c
> > +++ b/mm/khugepaged.c
> > @@ -394,8 +394,12 @@ static inline int hpage_collapse_test_exit(struct mm_struct *mm)
> >   static inline int hpage_collapse_test_exit_or_disable(struct mm_struct *mm)
> >   {
> > +	bool was_frozen;
> > +	int ret = kthread_freezable_should_stop(&was_frozen);
> > +
> >   	return hpage_collapse_test_exit(mm) ||
> > -		mm_flags_test(MMF_DISABLE_THP_COMPLETELY, mm);
> > +		mm_flags_test(MMF_DISABLE_THP_COMPLETELY, mm) ||
> > +		was_frozen || ret;
> >   }
> 
> Since the hpage_collapse_test_exit_or_disable() can be called by
> madvise_callapse(), which is not a kernel thread. So I think using the
> try_to_freeze() is enough?

I guess try_to_freeze() should work.

> or pass the cc->is_khugepaged to check if current thread is khugepaged.

Or I guess I can check `current->flags & PF_KTHREAD` in
hpage_collapse_test_exit_or_disable().


  reply	other threads:[~2026-02-10 10:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-06  2:47 Sergey Senozhatsky
2026-02-06  3:33 ` Baolin Wang
2026-02-06  3:38   ` Sergey Senozhatsky
2026-02-06  4:31     ` Sergey Senozhatsky
2026-02-06  5:12       ` Baolin Wang
2026-02-06  8:36         ` David Hildenbrand (Arm)
2026-02-06  8:55           ` Baolin Wang
2026-02-06  9:00             ` David Hildenbrand (Arm)
2026-02-10  3:21               ` Sergey Senozhatsky
2026-02-10 10:07                 ` Baolin Wang
2026-02-10 10:12                   ` Sergey Senozhatsky [this message]
2026-02-10 10:21                   ` David Hildenbrand (Arm)
2026-02-11  1:03                     ` Baolin Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=zlqncghw2xfhi73fwgotiz7ziaxrhrnnk5wv2tpdqkuksk2bol@jovasy65p4s5 \
    --to=senozhatsky@chromium.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=lance.yang@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=npache@redhat.com \
    --cc=ryan.roberts@arm.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox