mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	 f4c2c90bb7
			
		
	
	
		f4c2c90bb7
		
	
	
	
	
		
			
			Add a non-blocking trylock method to lock backend interface, mutex and spinlock implementations. It includes a C helper for spin_trylock. Rust Binder will use this method together with the new shrinker abstractions to avoid deadlocks in the memory shrinker. Link: https://lore.kernel.org/all/20240912-shrinker-v1-1-18b7f1253553@google.com Signed-off-by: Filipe Xavier <felipe_life@live.com> Reviewed-by: Fiona Behrens <me@kloenk.dev> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Boqun Feng <boqun.feng@gmail.com> Link: https://lore.kernel.org/r/BL0PR02MB4914579914884B5D7473B3D6E96A2@BL0PR02MB4914.namprd02.prod.outlook.com [ Slightly reworded. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
		
			
				
	
	
		
			29 lines
		
	
	
	
		
			557 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
	
		
			557 B
		
	
	
	
		
			C
		
	
	
	
	
	
| // SPDX-License-Identifier: GPL-2.0
 | |
| 
 | |
| #include <linux/export.h>
 | |
| #include <linux/spinlock.h>
 | |
| 
 | |
| void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,
 | |
| 				  struct lock_class_key *key)
 | |
| {
 | |
| #ifdef CONFIG_DEBUG_SPINLOCK
 | |
| 	__raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
 | |
| #else
 | |
| 	spin_lock_init(lock);
 | |
| #endif
 | |
| }
 | |
| 
 | |
| void rust_helper_spin_lock(spinlock_t *lock)
 | |
| {
 | |
| 	spin_lock(lock);
 | |
| }
 | |
| 
 | |
| void rust_helper_spin_unlock(spinlock_t *lock)
 | |
| {
 | |
| 	spin_unlock(lock);
 | |
| }
 | |
| 
 | |
| int rust_helper_spin_trylock(spinlock_t *lock)
 | |
| {
 | |
| 	return spin_trylock(lock);
 | |
| }
 |