Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3514453ioa; Tue, 26 Apr 2022 05:14:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytdwr8z+Cx2zRY1weQkyUZUo82bn62h+cxz0xuf95bmuWF17gdwgqmUT3KH9pFD5oaGT6E X-Received: by 2002:a63:8ac7:0:b0:3aa:fa62:5a28 with SMTP id y190-20020a638ac7000000b003aafa625a28mr13725055pgd.400.1650975260557; Tue, 26 Apr 2022 05:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650975260; cv=none; d=google.com; s=arc-20160816; b=j94krjGH1mFSkkedrfVar1jjEDnXTvUF0oGG6XPo6mC9BsCviw7/BqEw9exUXKFsVs yVbdYI7ktPAaahg+xXlbEioCCGOB0kwjXJSpjm849Ale/M1WU86ysBpfuPqo1ETvGidP +a/HdceeOKSMsIKD3nPqZV1eP9AAFD3DEKeeeqdlW/1h71qF2gZmRWbarisas4Oo4pka Hn0G1tZ9kgbSivRPiTeRkJSk/Is3qvUXva29Q0nON3kQxFGTOrGhE86lCsem5eKjgzyJ Yr/jL33ocq9gr0mYf9v0mMm9gllT5V4TdC8LkGyiOEcRYxf5GX5SeS5gWbfA7K8taMKA 6i7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FZS+hYxxaX2wojfJtGQqSge1tSnmHkDolwmUlcusEeg=; b=H51O8sYm3wsQAFHdTnBJBY7zhur775tdRogdJyTyrOwaMepy1K3jZztZpLzR9CcGdK K59NtDWrqStTq8IIRXEy559EY4dvSWYuRoZL0Mc/odTG/76eZQUe4RXH6JwjT4PP1XlS VvhxoYCD3mhcjtAI9aeyKvnyiTQ9Rm/wdABzjOk9SkEr3HcFrwa/PoeRqJ9XhgKmZikv E9dOBXLbu7QdVzL0lyxhUu1twcZ2byZXChfQ18492ZMm4PY5mjQiOOGsINk0r5qh2qrb ovwYq5W16BRB0MTqEQTIa3ID/KuPx5hWk2xkVYBzXnTNlaRt7Pm8ns5FRyctWhrYSWsS GyHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zPfH6T0Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ck8-20020a056a00328800b0050d3c158c04si5938927pfb.178.2022.04.26.05.13.50; Tue, 26 Apr 2022 05:14:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zPfH6T0Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343868AbiDZI5j (ORCPT + 99 others); Tue, 26 Apr 2022 04:57:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346193AbiDZIol (ORCPT ); Tue, 26 Apr 2022 04:44:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F73E83B24; Tue, 26 Apr 2022 01:34:22 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 03D4FB81CF2; Tue, 26 Apr 2022 08:34:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6044BC385A0; Tue, 26 Apr 2022 08:34:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962059; bh=wa6DKY7ihCAiI4ORJ4Lemo2W/kJEgxqyoapglfQxiiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zPfH6T0YdR+9AWPXnQCYPShqt4OaIfhk4E3WB8tfrTJof21OBgV9+av/jevnj9oN9 s/92BF2eptJmdYnSjphk8XzSIHkBiCjjkoo1zEVWjvtecct16DbGTkqPBjEiqQJGGe NYzpOKVCTq2chSiTWdiABrXO7TUP31roXjWvDxgo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guo Ren , Guo Ren , Max Filippov , Masami Hiramatsu Subject: [PATCH 5.10 58/86] xtensa: patch_text: Fixup last cpu should be master Date: Tue, 26 Apr 2022 10:21:26 +0200 Message-Id: <20220426081742.879470986@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081741.202366502@linuxfoundation.org> References: <20220426081741.202366502@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guo Ren commit ee69d4be8fd064cd08270b4808d2dfece3614ee0 upstream. 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: Message-Id: <20220407073323.743224-4-guoren@kernel.org> Signed-off-by: Max Filippov Signed-off-by: Greg Kroah-Hartman --- arch/xtensa/kernel/jump_label.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- 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 { 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 {