mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/9] sched: Use lock guards, wave 1
@ 2023-08-01 20:41 Peter Zijlstra
  2023-08-01 20:41 ` [PATCH 1/9] sched: Simplify get_nohz_timer_target() Peter Zijlstra
                   ` (9 more replies)
  0 siblings, 10 replies; 26+ messages in thread
From: Peter Zijlstra @ 2023-08-01 20:41 UTC (permalink / raw)
  To: mingo
  Cc: peterz, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, bristot, vschneid, linux-kernel

Hi,

This is the first of two series converting kernel/sched/core.c to use the shiny
new Scope-Based Resource Management machinery that has recently been merged:

  https://lkml.kernel.org/r/20230612093537.614161713%40infradead.org

TL;DR:

	void foo()
	{
		raw_spin_lock(&lock);
		if (!cond)
			goto unlock;
		...
	unlock:
		raw_spin_unlock(&lock);
	}

can now be written like:

	void foo()
	{
		guard(raw_spinlock)(&lock);
		if (!cond)
			return;
		...
	}

or:

	void foo()
	{
		scoped_guard (raw_spinlock, &lock) {
			if (!cond)
				break;
			...
		}
	}

Where guard() instantiates a 'cleanup' variable that is initialized by an
expression that locks and returns the lock pointer. When this variable goes out
of scope, the cleanup does the unlock. And scoped_guard() does the same but
creates an explicit scope (using for).

By having the unlock be implicit, the code becomes simpler since it is no
longer needed to manually track the various exit/error cases and many goto's
just go away.

Specifically, every patch in this series is aimed at removing an out/unlock
label and it's corresponding gotos.

If there are no objections / comments, I'm aiming to post the second batch at
the end of the week.

Also available at:

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



^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2023-08-14 15:08 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-01 20:41 [PATCH 0/9] sched: Use lock guards, wave 1 Peter Zijlstra
2023-08-01 20:41 ` [PATCH 1/9] sched: Simplify get_nohz_timer_target() Peter Zijlstra
2023-08-06 21:39   ` Joel Fernandes
2023-08-09 19:48     ` Peter Zijlstra
2023-08-11  7:35       ` Joel Fernandes
2023-08-14 15:08   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-08-01 20:41 ` [PATCH 2/9] sched: Simplify sysctl_sched_uclamp_handler() Peter Zijlstra
2023-08-14 15:08   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-08-01 20:41 ` [PATCH 3/9] sched: Simplify: migrate_swap_stop() Peter Zijlstra
2023-08-14 15:08   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-08-01 20:41 ` [PATCH 4/9] sched: Simplify wake_up_if_idle() Peter Zijlstra
2023-08-14 15:08   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-08-01 20:41 ` [PATCH 5/9] sched: Simplify ttwu() Peter Zijlstra
2023-08-09 15:21   ` Valentin Schneider
2023-08-09 19:26     ` Peter Zijlstra
2023-08-10  8:03       ` Valentin Schneider
2023-08-14 15:08   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-08-01 20:41 ` [PATCH 6/9] sched: Simplify sched_exec() Peter Zijlstra
2023-08-14 15:08   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-08-01 20:41 ` [PATCH 7/9] sched: Simplify sched_tick_remote() Peter Zijlstra
2023-08-14 15:08   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-08-01 20:41 ` [PATCH 8/9] sched: Simplify try_steal_cookie() Peter Zijlstra
2023-08-14 15:08   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-08-01 20:41 ` [PATCH 9/9] sched: Simplify sched_core_cpu_{starting,deactivate}() Peter Zijlstra
2023-08-14 15:08   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-08-09 15:35 ` [PATCH 0/9] sched: Use lock guards, wave 1 Valentin Schneider

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®