Unverified Commit 69a352ba authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!3375 locking/osq_lock: Avoid false sharing in optimistic_spin_node

parents d8c5ade4 c25cf09d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
struct optimistic_spin_node {
	struct optimistic_spin_node *next, *prev;
	int locked; /* 1 if lock acquired */
	int cpu; /* encoded CPU # + 1 value */
	int cpu ____cacheline_aligned; /* encoded CPU # + 1 value */
};

struct optimistic_spin_queue {
+7 −1
Original line number Diff line number Diff line
@@ -96,6 +96,12 @@ bool osq_lock(struct optimistic_spin_queue *lock)

	node->locked = 0;
	node->next = NULL;
	/*
	 * After this cpu member is initialized for the first time, it
	 * would no longer change in fact. That could avoid cache misses
	 * when spin and access the cpu member by other CPUs.
	 */
	if (node->cpu != curr)
		node->cpu = curr;

	/*