Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2021693pxb; Sun, 24 Apr 2022 02:11:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbMEfXTSuHVf8T1FBfxxgsEHWZJMh8I8I7fdiLCJagEwy63Y6wx/FgZafXrQLvjF6gF1NV X-Received: by 2002:a17:907:629a:b0:6d7:b33e:43f4 with SMTP id nd26-20020a170907629a00b006d7b33e43f4mr11698680ejc.149.1650791508060; Sun, 24 Apr 2022 02:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650791508; cv=none; d=google.com; s=arc-20160816; b=Mt0DyrATUAAYyVVyIel7ZM2cdB/7r0TniAKo0bL2+ZtmsW6whv1CMcd21c2ZNMvgBt QLHuT/MvSLjIm4yHhljrY5xqCrgGS/iJHyxCyK21rq9gw9+uKkH+SQZ2JpHHHzwhcWyD jsEkwRXj+crNzdF4emyngdpxOJ/nY1VhAWA5tl04uqdncOCtQzsZVsBwnjuBG6rNs2D+ Exwwz0SVWfIaqBVU9wiqVJNNHE2phqn55MyaqB4YWkrZ6ediqBjINU1hraU/BtHPdR1J o2NjDCXZFIAAlUnTsuVIF53FYCvSrp2L94aktaJh8q9Dr1ZOrPp80CJfAIrFurfVvh8N /MpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Pz2wBqvKVvqhZMNN06yBQT6amSad6EPu6b+iVaDWkII=; b=oQkNVwElpLnEU6uMy5eqQhHvJtEregxkF9xsSLjsiLM7k1XXzZ6Ws0ghD/d6vT6qtb V1tJfHfUFCfzdmOr94pPnNhaf9qqSyvcgbtS6OwRhmqEA+JR4mh4Rc3mxminBtOR1KDj yalmD7hKlQqZnWbgT8dQRHQKfhqQFrKthffouqYXAIN5m4fA6lhD15Qa4ZImYi8EpmHe Y80I+WWT+88mYn8qt1va9DDigsneJHo6G4Emuf72opT9ImRo7SM/aaPf9RHXK7lIRzoy gcbQ6ANFNJJHuYlZ6AXuLcmLNq+gsqJL4/bXyKyspBNd3qQpkO8CALSnLPA1HDm3F/ai Js7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z3YaV9td; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a50cbc7000000b0041d4f190912si9665361edi.168.2022.04.24.02.11.24; Sun, 24 Apr 2022 02:11:48 -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=@kernel.org header.s=k20201202 header.b=Z3YaV9td; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238505AbiDXHhM (ORCPT + 99 others); Sun, 24 Apr 2022 03:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235755AbiDXHhK (ORCPT ); Sun, 24 Apr 2022 03:37:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E507175DD7; Sun, 24 Apr 2022 00:34:11 -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 dfw.source.kernel.org (Postfix) with ESMTPS id AB12E612A0; Sun, 24 Apr 2022 07:34:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3071C385AB; Sun, 24 Apr 2022 07:34:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650785650; bh=xI1NIfvXpmPp9D3ctWwWfmXIYM7XRmpUpv+03lUnZqY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Z3YaV9tdWWy2hStE6/D5nBZ8H+tgRYDaZJuLqEMQOpdcaTA5btejAKV5nGs4FVkFw lztUtmGnYL7ij4B3m5usmfn0kp6+WDZwm3wV85W3giGmPvsaMI6qcSM6tkSYLBZuGJ F4K0ZjWW9IrtktJUZbMtT1AAO+znqc47yH1DejHSU1OHVpLM2Tfm7mP+IdGl9MBbfH r3HqJ7fsdf8SHeFANAll2AaNybVbsKpj85C9uZRc9QMSA26xvawE4saVHPevzSROBp ik352AGAWQmV7O8Ra4j8tKA8RJ+DAoNedBydzG76onwRCgpKbb1MAbN0Y+lalgPvbZ dP46StgCi9pDw== Received: by mail-ua1-f51.google.com with SMTP id o10so4588332uar.0; Sun, 24 Apr 2022 00:34:09 -0700 (PDT) X-Gm-Message-State: AOAM530iLLyzTv5TdSaT1NPAYRa8npRDvn969HJuI6pO2pijGjisYvMb 5rJ4YcytSPnp8xlWP0ubWamFuhFFC6Asq3SxQWY= X-Received: by 2002:ab0:375b:0:b0:355:c2b3:f6c with SMTP id i27-20020ab0375b000000b00355c2b30f6cmr3613271uat.84.1650785648925; Sun, 24 Apr 2022 00:34:08 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Guo Ren Date: Sun, 24 Apr 2022 15:33:57 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V3] riscv: patch_text: Fixup last cpu should be master To: Palmer Dabbelt Cc: Arnd Bergmann , linux-arch , Linux Kernel Mailing List , linux-riscv , Guo Ren , Masami Hiramatsu , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 On Sat, Apr 23, 2022 at 12:02 AM Palmer Dabbelt wrote: > > On Thu, 21 Apr 2022 15:57:32 PDT (-0700), Palmer Dabbelt wrote: > > On Wed, 06 Apr 2022 07:16:49 PDT (-0700), guoren@kernel.org wrote: > >> 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 > >> Acked-by: Palmer Dabbelt > >> Reviewed-by: Masami Hiramatsu > >> Cc: > >> --- > >> arch/riscv/kernel/patch.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c > >> index 0b552873a577..765004b60513 100644 > >> --- a/arch/riscv/kernel/patch.c > >> +++ b/arch/riscv/kernel/patch.c > >> @@ -104,7 +104,7 @@ static int patch_text_cb(void *data) > >> struct patch_insn *patch = data; > >> int ret = 0; > >> > >> - if (atomic_inc_return(&patch->cpu_count) == 1) { > >> + if (atomic_inc_return(&patch->cpu_count) == num_online_cpus()) { > >> ret = > >> patch_text_nosync(patch->addr, &patch->insn, > >> GET_INSN_LENGTH(patch->insn)); > > > > Thanks, this is on fixes. > > Sorry, I forgot to add the Fixes and stable tags. I just fixed that up, > but I'm going to hold off on this one until next week's PR to make sure > it has time to go through linux-next. https://lore.kernel.org/linux-riscv/20220407073323.743224-3-guoren@kernel.org/ -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/