mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Friesen <chris.friesen@windriver.com>
To: LKML <linux-kernel@vger.kernel.org>
Subject: [scheduler] questions around scheduler, task states, etc.
Date: Mon, 14 Apr 2025 12:00:36 -0600	[thread overview]
Message-ID: <d9c750c7-6a30-437b-90a5-e6e786f803fc@windriver.com> (raw)

In do_wait(), we basically do:

add_wait_queue()
set_current_state(TASK_INTERRUPTIBLE)
__do_wait()
schedule()
__set_current_state(TASK_RUNNING)
remove_wait_queue()

Would it be valid to move the set_current_state(TASK_INTERRUPTIBLE) call 
to *after* the call to __do_wait()?   Or would that break something?

The reason I ask is that I'm working on a system (6.6 kernel with RT 
patches) that uses stalld, and it only evaluates tasks in the 
TASK_RUNNING state.  There seems to be a code path in __do_wait() where 
the code can be preempted by a high-priority CPU hog while partially 
holding tasklist_lock, and this leads to bad things because stalld 
doesn't consider the preempted task as actually being runnable due to 
the task state being TASK_INTERRUPTIBLE.

If we could defer setting the state to TASK_INTERRUPTIBLE until right 
before we call schedule(), I think that would avoid the issue.

I'm not currently subscribed to the list, so please CC me on replies.

Thanks,
Chris Friesen

                 reply	other threads:[~2025-04-14 18:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=d9c750c7-6a30-437b-90a5-e6e786f803fc@windriver.com \
    --to=chris.friesen@windriver.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®