Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3540606ioa; Tue, 26 Apr 2022 05:44:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpkP9cKK/MOV6lSMH1uoimnA0VVv35b+Di9bdKF8/8D3UtifJRtKzGoWayTxgypwcFrZ9D X-Received: by 2002:a05:6402:4395:b0:423:eeac:2e17 with SMTP id o21-20020a056402439500b00423eeac2e17mr24775229edc.127.1650977080763; Tue, 26 Apr 2022 05:44:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650977080; cv=none; d=google.com; s=arc-20160816; b=VlkPn4z9RReg5hj7v5vymAMx5g0lLEgtLaZntgUhKUQHlHQv3Y9+SP6ItkxzB6snYd 6euAx7lhcKXXHbUS4SAKDyE1wwJgsdNKsr1OGor5ZB1IfTaoq7BkZ9ZLSkjcwwGDPpEq Z29/MllwKbPGYxrvbtsa5CHNtarMX1ZhXlYIiSlZx8LJ0t1VfNq7EFrPMHSi0OZq39Zu DWIW6mzxBQYrGoDf9C6OLEeGv2jEs8NJ81HiajQHM8M/JN9CmpPZ60UqxarSEPNrePtI KaJIk47Np4dSEklnI3jRXklDZPSRbGI6TxMiUZ7j2g32qZCEbE5vTEXcXPCyWNJs6cQY 1sIA== 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=gLNe79EkomQApFWWyLovrK21naraGFIGp8krxge2lt9XdorDV3KQ6H3PmN+v2FgDK3 W17CUyl+KcGVS05aoxHviOu+UwsqmE/Z6kyuBQY3Dk40NTxPetxrdJqOQznKNYpsJUOK AxRLFAbUEO2VJS98Gmg5YFJTafvoPCWUJQfDktDH7waXfSRFDATP8tnLAOMD+C09KN+5 HAZ9sSi7o3T3MsQih8GLlztwEX+uM/Iz0kVD+tNNbwRhGgnPIE1kU0Q+TUa6WnwpXk2I /7KUZh7HMk3nKiu1jC9U88VlOezFy0TTWzOjceje+fJ3UGqY2Sr3PwSaKPtTLvxIsBhP Gi8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ajQpFr4Q; 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 oy7-20020a170907104700b006f39b748c48si4527507ejb.229.2022.04.26.05.44.15; Tue, 26 Apr 2022 05:44:40 -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=ajQpFr4Q; 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 S1347096AbiDZJNx (ORCPT + 99 others); Tue, 26 Apr 2022 05:13:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347684AbiDZIvv (ORCPT ); Tue, 26 Apr 2022 04:51:51 -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 005FCD399F; Tue, 26 Apr 2022 01:40:48 -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 C2617B81CFA; Tue, 26 Apr 2022 08:40:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29CEBC385A0; Tue, 26 Apr 2022 08:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962445; bh=wa6DKY7ihCAiI4ORJ4Lemo2W/kJEgxqyoapglfQxiiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ajQpFr4QiCMxUyQLMdVrQtgkaYRX/UQZN2Oz2Yf2e/gC1rkxB4Vcmula6ZgGIponB yLf0EI83n0KI2cR6gBE+Bv+hAM9CNztAbkx/5YtxaqFeEUMDwSMfTSXizlRSUDVqWX lLKVVuf0JxE47VS+yF9WcNSz7PYrTsocxQUfv2Wk= 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.15 099/124] xtensa: patch_text: Fixup last cpu should be master Date: Tue, 26 Apr 2022 10:21:40 +0200 Message-Id: <20220426081750.114127201@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@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 {