Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4331788ioa; Wed, 27 Apr 2022 01:01:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlY8nAAUREBn7isuASrZ8uMXPgRpfjzMw19quh1nwq8wuEZSS8wXmwE1aLI1+JS8sPSNyC X-Received: by 2002:a63:8243:0:b0:3ab:1108:5b72 with SMTP id w64-20020a638243000000b003ab11085b72mr15313791pgd.525.1651046477473; Wed, 27 Apr 2022 01:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651046477; cv=none; d=google.com; s=arc-20160816; b=kR9HpcguplkZGrO8l9hI/OB3dHHsVUhIsRMBsp4+0pHO7GlhpmdohL0bd7SvEB/0+x aL5zRHFpGSxsb4D1kHGrQKe2QMPQ7ZmzLyIkK6maOXM4cjh12EU8LD2VH5UYeIoILhx4 q1ZlJwQyKEIJbmBZ5gvlFGmLS7lAAz7YLWF+++/BGygwDl6ccTLsVpJNSqUNcqLiYy2n Jy7sFr3nmxZb7vjiBNT1c7TlvIHZ3E30xviqsSLOUBXuQf+UHkAPnHIWAuz8lu5cgxuc dGAsy5i6hIzc7pVcPUsJUfgWgTpTcVoYboR/g7qiCAsVB/eFLSPO5AOHlbFqwdr0y/GX aMqQ== 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=GJpEczR0gUjj92fpWJyV119LGZtD/whxhPDHsNTXDocKnTk5FFFyMPl0mcPrp+yGpu lBh9WFHxBdpJd9WoA6xBWO75ce9E1scR0TStCDIfKFRjmgQhj0NZTxlSlAP0XVVkISrT MFSxIUquQeh2ZfAJ+gLkRyhBJ9ho/GZSFvUnpnOKlfXPIyUVoCnxbsn0+wQs2zzfEbxn j3r49oVRNhOSZI0d0NYwecFUokywS1+F0GG8N8qOK0NQAKkuwiXu491C1oGtgaKNx2KS Yu1HVMAJUNOgMai6IwuhPWitPfRHYhoPe0MVDd4HpIx+zAk7UDIsfnG6+hhBljpWQeP5 Mp2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zTIhCndv; 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 c30-20020a63725e000000b003ab5908dc1csi1006214pgn.22.2022.04.27.01.01.03; Wed, 27 Apr 2022 01:01:17 -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=zTIhCndv; 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 S1346964AbiDZIu5 (ORCPT + 99 others); Tue, 26 Apr 2022 04:50:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345804AbiDZIjd (ORCPT ); Tue, 26 Apr 2022 04:39:33 -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 23AD770911; Tue, 26 Apr 2022 01:31:25 -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 DA40DB81CF9; Tue, 26 Apr 2022 08:31:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 342C0C385A0; Tue, 26 Apr 2022 08:31:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650961882; bh=wa6DKY7ihCAiI4ORJ4Lemo2W/kJEgxqyoapglfQxiiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zTIhCndvvQ9lFjQdYDx/ZcDCTWzJZ93lSng+ASgD7p7SwgN/5Oh6e4Lqjsy+Mkhh9 lTHsT/Y5yjfo+mAp8uKljrTzjGiGK9DyYUxFKXc+kKU2FwK9FefzAvx4gjRIodGec6 bTogZk3jJD1BRAHOYZgPC8Ny7lld+LbMSauww53o= 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.4 45/62] xtensa: patch_text: Fixup last cpu should be master Date: Tue, 26 Apr 2022 10:21:25 +0200 Message-Id: <20220426081738.514474363@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081737.209637816@linuxfoundation.org> References: <20220426081737.209637816@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 {