Skip to content

Commit aebec5f

Browse files
Boris Ostrovskyvijay-suman
authored andcommitted
sched: Add interface for copying core scheduling cookie between two tasks
Orabug: 34152329 Signed-off-by: Boris Ostrovsky <[email protected]> Reviewed-by: Libo Chen <[email protected]> Reviewed-by: Chris Hyser <[email protected]>
1 parent 36c4211 commit aebec5f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

include/linux/sched.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,10 +2186,13 @@ extern void sched_core_fork(struct task_struct *p);
21862186
extern int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type,
21872187
unsigned long uaddr);
21882188
extern int sched_core_idle_cpu(int cpu);
2189+
extern void sched_cs_copy(struct task_struct *src, struct task_struct *dst);
21892190
#else
21902191
static inline void sched_core_free(struct task_struct *tsk) { }
21912192
static inline void sched_core_fork(struct task_struct *p) { }
21922193
static inline int sched_core_idle_cpu(int cpu) { return idle_cpu(cpu); }
2194+
static inline void sched_cs_copy(struct task_struct *src,
2195+
struct task_struct *dst) { }
21932196
#endif
21942197

21952198
extern void sched_set_stop_task(int cpu, struct task_struct *stop);

kernel/sched/core_sched.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,22 @@ static void __sched_core_set(struct task_struct *p, unsigned long cookie)
125125
sched_core_put_cookie(cookie);
126126
}
127127

128+
void sched_cs_copy(struct task_struct *src, struct task_struct *dst)
129+
{
130+
unsigned long cookie;
131+
132+
get_task_struct(src);
133+
get_task_struct(dst);
134+
135+
cookie = sched_core_clone_cookie(src);
136+
__sched_core_set(dst, cookie);
137+
sched_core_put_cookie(cookie);
138+
139+
put_task_struct(dst);
140+
put_task_struct(src);
141+
}
142+
EXPORT_SYMBOL(sched_cs_copy);
143+
128144
/* Called from prctl interface: PR_SCHED_CORE */
129145
int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type,
130146
unsigned long uaddr)

0 commit comments

Comments
 (0)