From patchwork Thu Apr 7 07:33:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 12804563 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94719C433FE for ; Thu, 7 Apr 2022 07:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0rwtt1RhhIyX2fo1HT/ocTtay2F8UbcagSsVCsdo9DU=; b=og7UkzYPUS2Nys InxwEBJvn0Y2vrdfv0Bux/0qfuHzxtGSNZShw4nEGL5BW0ZZE3fC4Sq9nwdwqL2dvCblpjvrVU3Fe zffoRdF2llXnHJrlyf0FiAkGwHUkUPzD+Y1ay2ucTdO43wcH1EKTTqEwXZzptmTwxQRRo+Q4hANLx 2B7jsjx/kJFuhP/BW/lhykXFXIltR4NnQpVpiuUL3sCJ3JEpkVg6tezhr8DQnW2b2zFcSiMYhGD8B WSoNLHgE+0hXdUzZ0vJeZtlByltY5/WC8f09N/n422nnHJTgL8IXQ6QukAJeKAqlTJeVAeC+czM1Y wJR+07DbueXwzii2vAaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncMfb-00A0jp-Fx; Thu, 07 Apr 2022 07:35:08 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncMem-00A0Lt-Ly; Thu, 07 Apr 2022 07:34:18 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1B1AF61DC9; Thu, 7 Apr 2022 07:34:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A285C385A4; Thu, 7 Apr 2022 07:34:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649316855; bh=R2FPA9lWSXRgAzEvdehN22kFHU9pjAW3rQXXGDs7cDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OJlKMZ2aKAzw5+LeIolJB5pwRD23zC0v1DrROL+aQ2kRGcMIIsMaieRXUWJ7LPfML nyQDGC2U5D8LolVa+curnmQgS1G1eTqJU6hy8o/PK6TXWuqokCFmrNHffffMrLMcA6 eoih0F/3+r8HL51n2Y7mCAaPGw3hQ8FZazxhD6WzjaSFyku4Tu+I6JekSksdCexMLf 9i77RxagVWEuZ+JIeMVfyempj2xEj4HBmmTL0UVXgD1ZAMhk1YTlOJcfiQVibNXquT I877fj9qjzdWkWW46gJ59BkzmgKvL4eg2L9Nj5v0EgdHTWjw9L4HN2Dni12GE86edn Y8htB1f4ONb3Q== From: guoren@kernel.org To: guoren@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Guo Ren , Max Filippov , Masami Hiramatsu , stable@vger.kernel.org Subject: [PATCH V4 3/4] xtensa: patch_text: Fixup last cpu should be master Date: Thu, 7 Apr 2022 15:33:22 +0800 Message-Id: <20220407073323.743224-4-guoren@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220407073323.743224-1-guoren@kernel.org> References: <20220407073323.743224-1-guoren@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_003416_805263_814D53C4 X-CRM114-Status: GOOD ( 13.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Guo Ren These patch_text implementations are using stop_machine_cpuslocked infrastructure with atomic cpu_count. The original idea: When the master CPU patch_text, the others should wait for it. But current implementation is using the first CPU as master, which couldn't guarantee the remaining CPUs are waiting. This patch changes the last CPU as the master to solve the potential risk. Fixes: 64711f9a47d4 ("xtensa: implement jump_label support") Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Max Filippov Reviewed-by: Masami Hiramatsu Cc: --- arch/xtensa/kernel/jump_label.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/xtensa/kernel/jump_label.c b/arch/xtensa/kernel/jump_label.c index 0dde21e0d3de..ad1841cecdfb 100644 --- a/arch/xtensa/kernel/jump_label.c +++ b/arch/xtensa/kernel/jump_label.c @@ -40,7 +40,7 @@ static int patch_text_stop_machine(void *data) { struct patch *patch = data; - if (atomic_inc_return(&patch->cpu_count) == 1) { + if (atomic_inc_return(&patch->cpu_count) == num_online_cpus()) { local_patch_text(patch->addr, patch->data, patch->sz); atomic_inc(&patch->cpu_count); } else {