diff mbox series

[v4,21/30] context_tracking: Explicitely use CT_STATE_KERNEL where it is missing

Message ID 20250114175143.81438-22-vschneid@redhat.com (mailing list archive)
State Handled Elsewhere
Headers show
Series context_tracking,x86: Defer some IPIs until a user->kernel transition | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR fail PR summary
conchuod/patch-21-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh took 139.13s
conchuod/patch-21-test-2 fail .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh took 1007.06s
conchuod/patch-21-test-3 fail .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh took 1229.64s
conchuod/patch-21-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh took 21.13s
conchuod/patch-21-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh took 23.13s
conchuod/patch-21-test-6 warning .github/scripts/patches/tests/checkpatch.sh took 0.48s
conchuod/patch-21-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh took 44.05s
conchuod/patch-21-test-8 success .github/scripts/patches/tests/header_inline.sh took 0.01s
conchuod/patch-21-test-9 success .github/scripts/patches/tests/kdoc.sh took 0.55s
conchuod/patch-21-test-10 success .github/scripts/patches/tests/module_param.sh took 0.01s
conchuod/patch-21-test-11 success .github/scripts/patches/tests/verify_fixes.sh took 0.00s
conchuod/patch-21-test-12 success .github/scripts/patches/tests/verify_signedoff.sh took 0.04s

Commit Message

Valentin Schneider Jan. 14, 2025, 5:51 p.m. UTC
CT_STATE_KERNEL being zero means it can be (and is) omitted in a handful of
places. A later patch will change CT_STATE_KERNEL into a non-zero value,
prepare that by using it where it should be:

o In the initial CT state
o At kernel entry / exit

No change in functionality intended.

Signed-off-by: Valentin Schneider <vschneid@redhat.com>
---
 kernel/context_tracking.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index 938c48952d265..a61498a8425e2 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -31,7 +31,7 @@  DEFINE_PER_CPU(struct context_tracking, context_tracking) = {
 	.nesting = 1,
 	.nmi_nesting = CT_NESTING_IRQ_NONIDLE,
 #endif
-	.state = ATOMIC_INIT(CT_RCU_WATCHING),
+	.state = ATOMIC_INIT(CT_RCU_WATCHING | CT_STATE_KERNEL),
 };
 EXPORT_SYMBOL_GPL(context_tracking);
 
@@ -147,7 +147,7 @@  static void noinstr ct_kernel_exit(bool user, int offset)
 	instrumentation_end();
 	WRITE_ONCE(ct->nesting, 0); /* Avoid irq-access tearing. */
 	// RCU is watching here ...
-	ct_kernel_exit_state(offset);
+	ct_kernel_exit_state(offset - CT_STATE_KERNEL);
 	// ... but is no longer watching here.
 	rcu_task_exit();
 }
@@ -175,7 +175,7 @@  static void noinstr ct_kernel_enter(bool user, int offset)
 	}
 	rcu_task_enter();
 	// RCU is not watching here ...
-	ct_kernel_enter_state(offset);
+	ct_kernel_enter_state(offset + CT_STATE_KERNEL);
 	// ... but is watching here.
 	instrumentation_begin();
 
@@ -537,7 +537,7 @@  void noinstr __ct_user_enter(enum ctx_state state)
 				 * RCU only requires CT_RCU_WATCHING increments to be fully
 				 * ordered.
 				 */
-				raw_atomic_add(state, &ct->state);
+				raw_atomic_add(state - CT_STATE_KERNEL, &ct->state);
 			}
 		}
 	}
@@ -647,7 +647,7 @@  void noinstr __ct_user_exit(enum ctx_state state)
 				 * RCU only requires CT_RCU_WATCHING increments to be fully
 				 * ordered.
 				 */
-				raw_atomic_sub(state, &ct->state);
+				raw_atomic_sub(state - CT_STATE_KERNEL, &ct->state);
 			}
 		}
 	}