All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rong Tao <rtoax@foxmail.com>
To: mark.rutland@arm.com, elver@google.com,
	linux-kernel@vger.kernel.org, peterz@infradead.org,
	rongtao@cestc.cn, rtoax@foxmail.com, tglx@linutronix.de
Subject: [PATCH 1/2] stop_machine: Use non-atomic read multi_stop_data::state clearly
Date: Fri, 20 Oct 2023 22:43:33 +0800	[thread overview]
Message-ID: <tencent_49AFDBA31F885906234219591097D42ABE08@qq.com> (raw)
In-Reply-To: <cover.1697811778.git.rongtao@cestc.cn>

From: Rong Tao <rongtao@cestc.cn>

commit b1fc58333575 ("stop_machine: Avoid potential race behaviour")
solved the race behaviour problem, to better show that race behaviour
does not exist, pass the 'curstate' directly to ack_state() instead of
refetching msdata->state in ack_state().

Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
 kernel/stop_machine.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index cedb17ba158a..268c2e581698 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -188,10 +188,11 @@ static void set_state(struct multi_stop_data *msdata,
 }
 
 /* Last one to ack a state moves to the next state. */
-static void ack_state(struct multi_stop_data *msdata)
+static void ack_state(struct multi_stop_data *msdata,
+		      enum multi_stop_state curstate)
 {
 	if (atomic_dec_and_test(&msdata->thread_ack))
-		set_state(msdata, msdata->state + 1);
+		set_state(msdata, curstate + 1);
 }
 
 notrace void __weak stop_machine_yield(const struct cpumask *cpumask)
@@ -242,7 +243,7 @@ static int multi_cpu_stop(void *data)
 			default:
 				break;
 			}
-			ack_state(msdata);
+			ack_state(msdata, curstate);
 		} else if (curstate > MULTI_STOP_PREPARE) {
 			/*
 			 * At this stage all other CPUs we depend on must spin
-- 
2.41.0


       reply	other threads:[~2023-10-20 14:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1697811778.git.rongtao@cestc.cn>
2023-10-20 14:43 ` Rong Tao [this message]
2023-10-24 10:46   ` [PATCH 1/2] stop_machine: Use non-atomic read multi_stop_data::state clearly Mark Rutland
2023-10-25  0:37     ` Rong Tao
2023-10-27 11:49     ` Rong Tao
2023-10-20 14:43 ` [PATCH 2/2] stop_machine: Apply smp_store_release() to multi_stop_data::state Rong Tao
2023-10-24 11:01   ` Mark Rutland
2023-10-25  0:59     ` Rong Tao

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=tencent_49AFDBA31F885906234219591097D42ABE08@qq.com \
    --to=rtoax@foxmail.com \
    --cc=elver@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=peterz@infradead.org \
    --cc=rongtao@cestc.cn \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.