lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1402519183-12752-2-git-send-email-bobby.prani@gmail.com>
Date:	Wed, 11 Jun 2014 16:39:39 -0400
From:	Pranith Kumar <bobby.prani@...il.com>
To:	paulmck@...ux.vnet.ibm.com, linux-kernel@...r.kernel.org,
	Josh Triplett <josh@...htriplett.org>
Subject: [RFC PATCH 1/5] kernel/rcu/tree.c:1272 fix a sparse warning 

kernel/rcu/tree.c:1272:9: warning: context imbalance in 'rcu_start_future_gp' - different lock contexts for basic block

We can simplify the function by keeping the contexts together and removing
redundant checks.

Signed-off-by: Pranith Kumar <bobby.prani@...il.com>
---
 kernel/rcu/tree.c | 65 ++++++++++++++++++++++++++++++-------------------------
 1 file changed, 35 insertions(+), 30 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index f1ba773..9ab84d3 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1234,49 +1234,54 @@ rcu_start_future_gp(struct rcu_node *rnp, struct rcu_data *rdp,
 	}
 
 	/*
-	 * There might be no grace period in progress.  If we don't already
+	 * There is be no grace period in progress.  If we don't already
 	 * hold it, acquire the root rcu_node structure's lock in order to
-	 * start one (if needed).
+	 * start one.
 	 */
 	if (rnp != rnp_root) {
 		raw_spin_lock(&rnp_root->lock);
 		smp_mb__after_unlock_lock();
+		/*
+		 * Get a new grace-period number.  If there really is no grace
+		 * period in progress, it will be smaller than the one we obtained
+		 * earlier.  Adjust callbacks as needed.  Note that even no-CBs
+		 */
+		c = rcu_cbs_completed(rdp->rsp, rnp_root);
+
+		/*
+		 * If the needed request for the required grace period is already
+		 * recorded, trace and leave.
+		 */
+		if (rnp_root->need_future_gp[c & 0x1]) {
+			trace_rcu_future_gp(rnp, rdp, c, TPS("Prestartedroot"));
+			raw_spin_unlock(&rnp_root->lock);
+			goto out;
+		}
+
+		/* Record the need for the future grace period. */
+		rnp_root->need_future_gp[c & 0x1]++;
+
+		/*
+		 * Start a new grace period since it is not started
+		 */
+		trace_rcu_future_gp(rnp, rdp, c, TPS("Startedroot"));
+		ret = rcu_start_gp_advanced(rdp->rsp, rnp_root, rdp);
+		raw_spin_unlock(&rnp_root->lock);
+		goto out;
 	}
 
+	/* rnp == rnp_root, we already hold the lock */
+	trace_rcu_future_gp(rnp, rdp, c, TPS("StartedLeaf"));
+	ret = rcu_start_gp_advanced(rdp->rsp, rnp, rdp);
+out:
 	/*
-	 * Get a new grace-period number.  If there really is no grace
-	 * period in progress, it will be smaller than the one we obtained
-	 * earlier.  Adjust callbacks as needed.  Note that even no-CBs
-	 * CPUs have a ->nxtcompleted[] array, so no no-CBs checks needed.
+	 * Adjust callbacks as needed.  Note that even no-CBs CPUs
+	 * have a ->nxtcompleted[] array, so no no-CBs checks needed.
 	 */
-	c = rcu_cbs_completed(rdp->rsp, rnp_root);
 	for (i = RCU_DONE_TAIL; i < RCU_NEXT_TAIL; i++)
 		if (ULONG_CMP_LT(c, rdp->nxtcompleted[i]))
 			rdp->nxtcompleted[i] = c;
 
-	/*
-	 * If the needed for the required grace period is already
-	 * recorded, trace and leave.
-	 */
-	if (rnp_root->need_future_gp[c & 0x1]) {
-		trace_rcu_future_gp(rnp, rdp, c, TPS("Prestartedroot"));
-		goto unlock_out;
-	}
-
-	/* Record the need for the future grace period. */
-	rnp_root->need_future_gp[c & 0x1]++;
-
-	/* If a grace period is not already in progress, start one. */
-	if (rnp_root->gpnum != rnp_root->completed) {
-		trace_rcu_future_gp(rnp, rdp, c, TPS("Startedleafroot"));
-	} else {
-		trace_rcu_future_gp(rnp, rdp, c, TPS("Startedroot"));
-		ret = rcu_start_gp_advanced(rdp->rsp, rnp_root, rdp);
-	}
-unlock_out:
-	if (rnp != rnp_root)
-		raw_spin_unlock(&rnp_root->lock);
-out:
 	if (c_out != NULL)
 		*c_out = c;
 	return ret;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ