summaryrefslogtreecommitdiff
path: root/arch/s390
diff options
context:
space:
mode:
authorHeiko Carstens <hca@linux.ibm.com>2023-02-13 12:35:18 +0100
committerHeiko Carstens <hca@linux.ibm.com>2023-02-15 11:07:01 +0100
commitf96f41aae2b5bd34d32f462c7b45c0f4fad2b59e (patch)
treedf5d5a0ad3e9718943b226116b8d4034068b08ed /arch/s390
parentb977f03ec44aef7f6728bfe1a48f3ee5b0776001 (diff)
s390/processor: add test_and_set_cpu_flag() and test_and_clear_cpu_flag()
Add test_and_set_cpu_flag() and test_and_clear_cpu_flag() helper functions. Reviewed-by: Sven Schnelle <svens@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Diffstat (limited to 'arch/s390')
-rw-r--r--arch/s390/include/asm/processor.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
index 9f89d3821d16..e98d9650764b 100644
--- a/arch/s390/include/asm/processor.h
+++ b/arch/s390/include/asm/processor.h
@@ -59,6 +59,22 @@ static __always_inline bool test_cpu_flag(int flag)
return S390_lowcore.cpu_flags & (1UL << flag);
}
+static __always_inline bool test_and_set_cpu_flag(int flag)
+{
+ if (test_cpu_flag(flag))
+ return true;
+ set_cpu_flag(flag);
+ return false;
+}
+
+static __always_inline bool test_and_clear_cpu_flag(int flag)
+{
+ if (!test_cpu_flag(flag))
+ return false;
+ clear_cpu_flag(flag);
+ return true;
+}
+
/*
* Test CIF flag of another CPU. The caller needs to ensure that
* CPU hotplug can not happen, e.g. by disabling preemption.