Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1162302pxb; Wed, 6 Apr 2022 10:10:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfdY02Mo4iDvIWurkfk4BcNVwDKrCaHjHOxoepe9g3znGd9O0WxhajmnzCroqVcn+SC7W2 X-Received: by 2002:a63:6849:0:b0:398:a546:1c46 with SMTP id d70-20020a636849000000b00398a5461c46mr7966149pgc.100.1649265044073; Wed, 06 Apr 2022 10:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649265044; cv=none; d=google.com; s=arc-20160816; b=yiRuymbV7Rultek0MurUg/BRl6M8AEke60V+iQ2LBI/285n+by7IMsWLr468Eor6HF w+vm4uq8CMFe6pF0pDRLYFZHElP3f1dH+iDL7b3K0JysxaaPgnejvVKqrlH4lLdYFy1D gSFl4yrTPNRei/rLccRQczyOsnpmX3UDUsMYMHau2nuAvYS+TK+xrHAfT06aKq/WYlm0 0FQmzKQC3N+aNuEhMf98duoP1an+5eI4UweWrY7h3kk/8BMHwpbQlqVp+u9wssAfcK/o yZhA1gE2eefJE7rj/bGDLwuIix11Vsgh10Dq01LhwP99Te+y4zdO+rBRxvqYgw04XEQT JX3Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=HDNaKsrsKqpSC0Ouz2ag1pp4uzdLQmZ9HPR4hDZdDFg=; b=05XzEJMOnaN8QLRhMQmuBNZC310AN63TTe/g3qVPN2pNipsoQRLI42DHtqg0MABrYU VTISZ9pBNWFBgIfvuuPZ8ZluH8rUVnPOkby5Ttzzu1Oh+VKoHNSCoP0APqrIwdtpiF/v PLwOgSsG8TTkSyRHdUe9KEaLA2Tz2JS2uu563EXYDauGwDzj/77Nyj09tNccd/5UgBM/ 6S+i5cff9BqZ86jE97Wjn0H2+/dfY39LcLbo9AmIS3OR64tEh+lOPZDogFmzzALiwuFR 5CNWotvPyMja7puyqUbZm8y3IFxVk75IeUb1GV3zmxl6jq2kVRiyyaWAhr0fWR+9sUgK AQOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hgjDMg8X; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c19-20020a056a000ad300b004fa831f601csi17990812pfl.231.2022.04.06.10.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 10:10:44 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hgjDMg8X; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2A177E43B7; Wed, 6 Apr 2022 10:03:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238513AbiDFRFv (ORCPT + 99 others); Wed, 6 Apr 2022 13:05:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238255AbiDFRFh (ORCPT ); Wed, 6 Apr 2022 13:05:37 -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 151C34961FB; Wed, 6 Apr 2022 07:28:39 -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 9EA4EB82353; Wed, 6 Apr 2022 14:28:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9470DC385A3; Wed, 6 Apr 2022 14:28:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649255316; bh=6ilL6lDyJxwwFSqe1lKQGv1TTtCGzwxuY6CWzqW3O/c=; h=From:To:Cc:Subject:Date:From; b=hgjDMg8XINxqdmkR9f8AdMKEfhxzsrPumb8XbUGwhvsXdS8enBomrRCBxL1/fdeo5 HJXRIG5UrwQhajTiMS5314t15cGqDyjEvjRWm5qzPCBqqZ1f+lT9+TrWA0HWOjVclP IA4bL8acXWbzqz2lbWLWN1OcqKnUVTpACzoQ8UL0ZJwB7KH9REsfITVpxRtYvIXmsJ +okbrVHjHzaBSkbpT5+heKmhrQQfLxLFCFQVuj8mWVe7GC1QISj6XJhMA98RzCrJAq atD8tYueuk2mvgnMMjuCNWsuJ3Ze9nxiNIZytrDh035g383swaQ/RKiqxAtRqvp9nQ JkjUqGSadJQTA== From: guoren@kernel.org To: guoren@kernel.org, arnd@arndb.de, jcmvbkbc@gmail.com, chris@zankel.net Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xtensa@linux-xtensa.org, Guo Ren , Masami Hiramatsu , stable@vger.kernel.org Subject: [PATCH V3] xtensa: patch_text: Fixup last cpu should be master Date: Wed, 6 Apr 2022 22:28:19 +0800 Message-Id: <20220406142819.730238-1-guoren@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 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. 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 { -- 2.25.1