Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp962543pxb; Fri, 22 Apr 2022 15:25:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbJ/CwddVS1grJisxWDXrQU9J5OOgk9tZpc49ebN1nd+lRjMLOjpQJSKpflb1WxVQo0n14 X-Received: by 2002:a63:3f0e:0:b0:386:1d94:312a with SMTP id m14-20020a633f0e000000b003861d94312amr5704711pga.317.1650666330078; Fri, 22 Apr 2022 15:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650666330; cv=none; d=google.com; s=arc-20160816; b=gtJqblvXBR6pKyCP8Z8f4nWSbqTqlDBfZiTThwRNq2PdAwmdczbqyyKcP0nwD8tW1p 8xAI0MXL3uhxjjbI1zBw7OT0xA2diDKsuMrRi93Ba6njIjm7Hr1yrLmNJhHQiASYudFF y8Ps9wJ8NuSmO8+4VoLCebT1rjbXSbEZc9Ei2mdxYcKOb0qnlE6lvu2xiJPIAG00TAFL zomT7901Y1gBJRtXSNZUQ86RAScbTVL9hSVehrjX7Hgf8l+rSNmIc4STvgQEPJ1PLLNQ VVfTxMKItaxpWpZycwrUc/Jo5v7OfIxuKJWa0DlhKys3FFi9VfsJANVkVY0jfmZHgo2p In6g== 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:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=j/DRPoony39xAyuEQEwrygpJFCr5xS/J71HzZSlHAsc=; b=Ymid3mJDQCJGOvvDz/sAtaCb1A/yX0TJ4BcucMsB2M4l2f08LbFVEgpkfx9ALuiJ4W ILVNkktLE5KKpMlXWhoOi/kksv+XoDtd15ufuOQeTfEDjUpIZw8xXK3+oxOLbosuNN/P 65aMMuJjsble5Hwkuz9uUkqIm568LfbDkANrIg31FIc8O33tSPSYRyITf4Q+dbC0tNZb 09vnfmhgjOxkIGG/9vqJgWyisspNYFAsYox0SZu7ml4Sk5680L4c/gFzfil14hIi4S3D wyqzfC+0Ps9U8Kmp8nwByyxkUOrcYLN4n+93AQHNXVzZU/ZIDhaps/KOP93yomfGdtL8 z+Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=1y65yY7v; 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 Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r80-20020a632b53000000b0039d2ffc2de2si9631423pgr.789.2022.04.22.15.25.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 15:25:30 -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=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=1y65yY7v; 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E60763DA28E; Fri, 22 Apr 2022 13:30:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377826AbiDVQFA (ORCPT + 99 others); Fri, 22 Apr 2022 12:05:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357434AbiDVQEz (ORCPT ); Fri, 22 Apr 2022 12:04:55 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4FE25BE68 for ; Fri, 22 Apr 2022 09:02:01 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id s137so7663408pgs.5 for ; Fri, 22 Apr 2022 09:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=j/DRPoony39xAyuEQEwrygpJFCr5xS/J71HzZSlHAsc=; b=1y65yY7vuM94Cb2DFLSypSKF3EfFIP9EEDZRMMYc7BNAIb8kyV8SH6oP88tqWE12cT bce6V1dKCmTJjTmD4azRKGLTHybtP3QUiTBhPBKFR+yxwV4ExgYQEJk251glzy/kuPaN lkE9bNd+T3DehLal6fE7fziEnzYMuRh3+ayZRXciw3BXIu2uGLYqzUR7onwoWDHOm5Yl cd4g/julRzttzHSCmCBNZBZVI/ZY2alBNtfN1TfkY2tnhSVZsE6s9iKOktgVsYTG24zW TSvQdnMRVkjx4q5I6E6A8k6PJULytKbVh4wG8f6qdBporN3yw+5oPZNNMRBNY2hkTCkC PaKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=j/DRPoony39xAyuEQEwrygpJFCr5xS/J71HzZSlHAsc=; b=yZFX+Hal1WaNyQ8a7Zz8LVc4iduWm31En6QEso8ch7QPF3UQsJ4MNxz78/zbgaxGeR Jr0IcQYbjvrPEQKKI3a7OFeQZgP+FM1kCmmI12hzDnunYSxVp3evqLiACFFCT8lOJCgC kJ9pJ5edhCIr+CXc81PPv4HcHjBGDGM2z+MlxK1tuTIJKmybHYGtpJgSYPMERXnB2n0q K5LbOdoO+vebM+BXJjAVx/S/K1JVlIVB933rWam2IKJVcbAIK8LWELLT7MBLAbcwV3B6 VN9JidCejHhSse7nxPDlCqiopWCR5PwAKaB+jvH0ixysdTwaMbg4hOPVBAokU74IlzNw WYeg== X-Gm-Message-State: AOAM531+4eLPqtrY75Pn/T0gwy4+KmNJWEiDHE9P2G6QXKYKj4Ra7UWr RUFsCdG4wOdEcHCGpf69Ol2OoA== X-Received: by 2002:a63:5421:0:b0:3aa:5717:fadb with SMTP id i33-20020a635421000000b003aa5717fadbmr4478084pgb.422.1650643320884; Fri, 22 Apr 2022 09:02:00 -0700 (PDT) Received: from localhost ([12.3.194.138]) by smtp.gmail.com with ESMTPSA id e6-20020a17090a77c600b001cd4989fedcsm6512927pjs.40.2022.04.22.09.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 09:02:00 -0700 (PDT) Date: Fri, 22 Apr 2022 09:02:00 -0700 (PDT) X-Google-Original-Date: Fri, 22 Apr 2022 08:35:09 PDT (-0700) Subject: Re: [PATCH V3] riscv: patch_text: Fixup last cpu should be master In-Reply-To: CC: guoren@kernel.org, Arnd Bergmann , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, guoren@linux.alibaba.com, mhiramat@kernel.org, stable@vger.kernel.org From: Palmer Dabbelt To: guoren@kernel.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no 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 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.