Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4434851ioa; Wed, 27 Apr 2022 03:56:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5gmlUjL59JuH1sZrqgFXaAcScY7/mwMTqdDWg/375HJ1q0QFofMv9GkqfxccmOGtLnfpK X-Received: by 2002:a17:902:bd4a:b0:158:9eb3:2ce3 with SMTP id b10-20020a170902bd4a00b001589eb32ce3mr28038663plx.55.1651056991016; Wed, 27 Apr 2022 03:56:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651056991; cv=none; d=google.com; s=arc-20160816; b=NHiDcoU3TqlPl6oFbIcMvXax8fzXO7rf2DJ6ZPvpDsm5FOs3x9nNFmeSPX9668WUbV N4TYH+F56b9OxSTNaSUfyWFsjcFuPymbTcng4KiPOXN7f3Y9jnuTblUnLfbi2u/GjAQE k8cQXy47U+0IcG221Il7L5iK5xYCTSPCBbN6t/2wvyvbvwd3rp1BdTk4hJOxkD0AFnnO UD4rSUh9IAqtZxlVGTPiy9FAobhdM4eLBHZTlgVPeoxjU3ycU8rXlB0CkFXu0LV+fyOd OEHQ9snPvUOdwsOQpTTKzaUEOwA7b+716nliO25UvQMk2KYBTKNYquBIKsj1nJI8/x0O PIbQ== 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=hmOaAFT9+A1JD4bKe+mRoNM0Uyks26wiPBgfo9AQUJVOm8xzXbU6M94sRvX9oNvzBd na8fq17GHooEcCGiYa0a4brX0z0zDO7kZQz4qzJug8YBRzqbaMUHg7BISGZqEvr9z0jA wP8kk/muiq6hH+BBsUBZgCfsuOjYOvaI3sCurApoZeB9fryrPyDDiY1rPiChecxPY/WW 35+3ADIOqr81G+cA5ppcfmPZyVODhUJZyGhR/aREBKonYDIngzRSI3CVkyMirqGMAp9B nUbXLdPMoi0+d5pEw40c1DmInWvDGEjqU1c+bhfS3HX6upK5QUWFos8hHtKk9qWrCqkQ 7Kmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fvr2dVtO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bd8-20020a656e08000000b003aa90e6d50bsi1228735pgb.45.2022.04.27.03.56.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:56:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fvr2dVtO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AD0985713A; Wed, 27 Apr 2022 03:02:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347691AbiDZJg3 (ORCPT + 99 others); Tue, 26 Apr 2022 05:36:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345975AbiDZJG3 (ORCPT ); Tue, 26 Apr 2022 05:06:29 -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 B3F0013C285; Tue, 26 Apr 2022 01:47:52 -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 6D88AB81A2F; Tue, 26 Apr 2022 08:47:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADDA3C385A4; Tue, 26 Apr 2022 08:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962870; bh=wa6DKY7ihCAiI4ORJ4Lemo2W/kJEgxqyoapglfQxiiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fvr2dVtONJ4d3hKOoE34bkvBT2yLepHnQE4/dOVE0tgiSs9DLRO8BpGGj6UOpvevn 1efBlLdpTpkukBmhLtSJOmxnhaENb8scq+hf4GgEVrWHVIlvTpVrcR/w0k/pLqOp79 tbDj77BbEys31oK0vLFnB4iVlBXK24LYzSWydXlI= 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.17 117/146] xtensa: patch_text: Fixup last cpu should be master Date: Tue, 26 Apr 2022 10:21:52 +0200 Message-Id: <20220426081753.345440056@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081750.051179617@linuxfoundation.org> References: <20220426081750.051179617@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=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 {