Skip to content

sched: Use lock guards, wave 2

Peter Zijlstra lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8sched: Simplify set_user_nice()kernel/sched/core.c kernel/sched/sched.h+11 -70 replies
2/8sched: Simplify syscallskernel/sched/core.c+68 -860 replies
3/8sched: Simplify sched_{set,get}affinity()kernel/sched/core.c+14 -390 replies
4/8sched: Simplify yield_to()kernel/sched/core.c+32 -410 replies
5/8sched: Simplify sched_rr_get_interval()kernel/sched/core.c+16 -240 replies
6/8sched: Simplify sched_move_task()kernel/sched/core.c+4 -60 replies
7/8sched: Simplify tg_set_cfs_bandwidth()include/linux/cpu.h kernel/sched/core.c+23 -210 replies
8/8sched: Misc cleanupskernel/sched/core.c+63 -1040 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/8] sched: Use lock guards, wave 2

Hi, as promised, here is the second part of the SBRM patches.

Now that we're a little used to them, these are a little more involved.

New in this series, over the guard()() and scoped_guard () usage, is CLASS().

CLASS() is very like guard() except it also takes a name argument. So where guard() instantiates an 'anonymous' variable, CLASS() instantiates an explicitly named one.

  CLASS(task_rq_lock, rq_guard)(p);

which can be read like:

class_task_rq_lock_t rq_guard __cleanup(class_task_rq_lock_destructor) =

	class_task_rq_lock_constructor(p);

[[ Notable: guard(name) := CLASS(name, __UNIQUE_ID(guard)) ]]

The advantage in this specific case is that the guard object of task_rq_lock will contain the 'struct rq *' which we'll need.

Another use of CLASS() is:

  CLASS(find_get_task, p)(pid);

Where 'p' is of 'struct task_struct *' type and the constructor does the pid->task_struct lookup and the destructor does put_task_struct.

Again, mostly aimed at getting rid of error gotos. The final patch is a bunch of random conversions that happened while I was poking around and playing with things.

Also available at:

git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git sched/guards2

Next in line is kernel/events/core.c, but I might not bore all of you with those patches :-)