ANDROID: sched: Track wake_q length
Some partners have value-adds based on aosp/540066, which cannot be carried in ACK in its entirety as it no longer makes sense as-is (the select_idle_capacity() rework upstream solved the issue differently). It seems that those partners do not actually need the wake-wide tweaks, they only need to access the wake_q length for wake-up balance. To support this, add minimal tracking to the wake_q infrastructure in the core kernel, but do that by adding a pointer to the wake_q_head to task_struct directly to not litter all sched classes with an additional sibling_count_hint argument to the select_task_rq callbacks. Modules needing to access the wake_q length can do so by dereferencing p->wake_q_head in the wake-up path when it is non-NULL. Bug: 173981591 Signed-off-by: Quentin Perret <qperret@google.com> Change-Id: I9a98167face92e70aba847d9f04d0c216065478c
This commit is contained in:
committed by
Todd Kjos
parent
4d1ac6a160
commit
1a29b384b0
@@ -1004,6 +1004,7 @@ struct task_struct {
|
|||||||
raw_spinlock_t pi_lock;
|
raw_spinlock_t pi_lock;
|
||||||
|
|
||||||
struct wake_q_node wake_q;
|
struct wake_q_node wake_q;
|
||||||
|
struct wake_q_head *wake_q_head;
|
||||||
|
|
||||||
#ifdef CONFIG_RT_MUTEXES
|
#ifdef CONFIG_RT_MUTEXES
|
||||||
/* PI waiters blocked on a rt_mutex held by this task: */
|
/* PI waiters blocked on a rt_mutex held by this task: */
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
struct wake_q_head {
|
struct wake_q_head {
|
||||||
struct wake_q_node *first;
|
struct wake_q_node *first;
|
||||||
struct wake_q_node **lastp;
|
struct wake_q_node **lastp;
|
||||||
|
int count;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define WAKE_Q_TAIL ((struct wake_q_node *) 0x01)
|
#define WAKE_Q_TAIL ((struct wake_q_node *) 0x01)
|
||||||
@@ -49,6 +50,7 @@ static inline void wake_q_init(struct wake_q_head *head)
|
|||||||
{
|
{
|
||||||
head->first = WAKE_Q_TAIL;
|
head->first = WAKE_Q_TAIL;
|
||||||
head->lastp = &head->first;
|
head->lastp = &head->first;
|
||||||
|
head->count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool wake_q_empty(struct wake_q_head *head)
|
static inline bool wake_q_empty(struct wake_q_head *head)
|
||||||
|
|||||||
@@ -538,6 +538,7 @@ static bool __wake_q_add(struct wake_q_head *head, struct task_struct *task)
|
|||||||
*/
|
*/
|
||||||
*head->lastp = node;
|
*head->lastp = node;
|
||||||
head->lastp = &node->next;
|
head->lastp = &node->next;
|
||||||
|
head->count++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,12 +595,14 @@ void wake_up_q(struct wake_q_head *head)
|
|||||||
/* Task can safely be re-inserted now: */
|
/* Task can safely be re-inserted now: */
|
||||||
node = node->next;
|
node = node->next;
|
||||||
task->wake_q.next = NULL;
|
task->wake_q.next = NULL;
|
||||||
|
task->wake_q_head = head;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wake_up_process() executes a full barrier, which pairs with
|
* wake_up_process() executes a full barrier, which pairs with
|
||||||
* the queueing in wake_q_add() so as not to miss wakeups.
|
* the queueing in wake_q_add() so as not to miss wakeups.
|
||||||
*/
|
*/
|
||||||
wake_up_process(task);
|
wake_up_process(task);
|
||||||
|
task->wake_q_head = NULL;
|
||||||
put_task_struct(task);
|
put_task_struct(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user