public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kishan Kumar <kishank@codeaurora.org>
To: paulmck@linux.vnet.ibm.com, josh@joshtriplett.org,
	rostedt@goodmis.org, mathieu.desnoyers@efficios.com,
	laijs@cn.fujitsu.com, linux-kernel@vger.kernel.org,
	kaushalk@codeaurora.org
Cc: Kishan Kumar <kishank@codeaurora.org>,
	Mohammed Khajapasha <mkhaja@codeaurora.org>,
	Vignesh Radhakrishnan <vigneshr@codeaurora.org>
Subject: [PATCH] rcu: Start grace period even for single callback
Date: Thu, 11 Jun 2015 19:18:18 +0530	[thread overview]
Message-ID: <1434030498-25507-1-git-send-email-kishank@codeaurora.org> (raw)

When we queue a callback for RCU, it goes and sits
on the nxttail of the per-cpu RCU data structure.
Callback is represented via struct callback_head
structure.

struct callback_head {
        struct callback_head *next;
        void (*func)(struct callback_head *head);
};

In case of a single callback queued in the nxttail,
the next field will be NULL. "next" happens to be
the zeroeth element of struct callback_head.

The condition "if(*rdp->nxttail[RCU_NEXT_READY_TAIL])"
in the function cpu_needs_another_gp(), essentially
checks if any callback is queued.

Since *rdp->nxttail[RCU_NEXT_READY_TAIL] dereferences
to the first element, the if condition will just turn
out to be if(NULL) in case there is a single callback
queued. This in turn causes cpu_needs_another_gp() to
return false even though we need a grace period to
process the single callback. This leads to writers
waiting until a second call_back gets queued, which can
cause undesirable effects like boot up delay upto 300
seconds, etc.

Fix this by performing this check on the "func" field
rather than the "next" field of the callback_head.

Signed-off-by: Kishan Kumar <kishank@codeaurora.org>
Signed-off-by: Mohammed Khajapasha <mkhaja@codeaurora.org>
Signed-off-by: Vignesh Radhakrishnan <vigneshr@codeaurora.org>
---
 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index fc3abf1..394a4fa 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -324,7 +324,7 @@ cpu_needs_another_gp(struct rcu_state *rsp, struct rcu_data *rdp)
 		return 1;  /* Yes, a no-CBs CPU needs one. */
 	if (!rdp->nxttail[RCU_NEXT_TAIL])
 		return 0;  /* No, this is a no-CBs (or offline) CPU. */
-	if (*rdp->nxttail[RCU_NEXT_READY_TAIL])
+	if (((struct callback_head *)rdp->nxttail[RCU_NEXT_READY_TAIL])->func)
 		return 1;  /* Yes, this CPU has newly registered callbacks. */
 	for (i = RCU_WAIT_TAIL; i < RCU_NEXT_TAIL; i++)
 		if (rdp->nxttail[i - 1] != rdp->nxttail[i] &&
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation.


             reply	other threads:[~2015-06-11 13:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-11 13:48 Kishan Kumar [this message]
2015-06-11 15:07 ` [PATCH] rcu: Start grace period even for single callback Paul E. McKenney
2015-06-12 12:13   ` kishank
2015-06-12 14:37     ` Paul E. McKenney
2015-06-15 14:06       ` kishank
2015-06-15 17:05         ` Paul E. McKenney
2015-06-22  5:39           ` kishank
2015-06-22 17:29             ` Paul E. McKenney
2015-06-23  9:01               ` kishank
2015-06-23 13:01                 ` Paul E. McKenney
2015-06-24  5:18                   ` kishank

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434030498-25507-1-git-send-email-kishank@codeaurora.org \
    --to=kishank@codeaurora.org \
    --cc=josh@joshtriplett.org \
    --cc=kaushalk@codeaurora.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mkhaja@codeaurora.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=vigneshr@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox