Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6370397rwl; Mon, 9 Jan 2023 07:33:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXsYBPt/4UP8MRjLDDFf4TjR02fAuD9byaIvhFhAJviZNtLZ2vX8KrbIBlqoJpgHr5+4qCpP X-Received: by 2002:a17:902:b08e:b0:192:6195:44b6 with SMTP id p14-20020a170902b08e00b00192619544b6mr55173804plr.58.1673278430053; Mon, 09 Jan 2023 07:33:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673278430; cv=none; d=google.com; s=arc-20160816; b=EVtvHoY5PWNkqDRHQrrYGl+jhVKqJ7+6uIv0aoXyuePcTqEywxdgAOwTJfzsoRRTnO nqZ5dYIzVRlfoAf4QpyANiWREsnO5iqI0VYLlxzMagLsTODgCNt+Rw2V7bWr+PMyn5FQ CZ0LRrwMWX0lA1jz8s1EoadP4lvNo3lqRylhfPQTKFssTztnWUlMVjWU347PnsOd0bnp t5ZK4AwAXk+bXqLcQ1uitr5Vs1wKAY/klwBj3SIB5VWszOcJlA/T+qrTHgxg18OyHcuS fM9d7KOFSNRIRRweb8JuYdA1vxaB1RvX4Lku4AJKS+AtaNp7drRvavCbx0pQag4UQLv+ IjrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=xZeFuOfjXZyvGUkshfuWwhEteQ+VOGfNZTTsbiEi3PE=; b=fwcPXowkPnR3hXVxrJVsgL4y/xK8qWuG3HM1M/hWPNluNBMVQ0kDjWRb48rdQJEhcA J312DLM95oVqVklkMGxB2w8siErgj7jL6paV9MMPtn1bxgGNYJGZXYJO84kPVBVkZ5oP hy3NIg6amO2NTkaZ5Tjr7cU/CeEI9qUtsjv87TCWCWwJEUDnV42MaOz/RFJKT9Fxidzb ADq17MJnJ6NdU8mRdCdOtQDS2MLPAba+4czoIFhBLj9wkUkJ5LbkgrYG+99hObDhkWfP km6qDCxVjKxUJtPQfhROF3tXgXhfcA6gsDBcmpzglseC18dIWfaynYyFdb4Qw4lrm/IW MlLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WjeM3Fof; 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 s199-20020a632cd0000000b0047839aeb6e4si10169178pgs.363.2023.01.09.07.33.42; Mon, 09 Jan 2023 07:33:50 -0800 (PST) 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=WjeM3Fof; 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 S236723AbjAIPMF (ORCPT + 55 others); Mon, 9 Jan 2023 10:12:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236528AbjAIPL1 (ORCPT ); Mon, 9 Jan 2023 10:11:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C342B4C for ; Mon, 9 Jan 2023 07:10:57 -0800 (PST) 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 06C2E61165 for ; Mon, 9 Jan 2023 15:10:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6579BC433D2; Mon, 9 Jan 2023 15:10:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673277056; bh=TaOwVQU3EAOSREHAnbAbF/A5VmxCdhADQnlkx3EE8ys=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=WjeM3FofUHC0LPUyUEyUiQRfwX1XHfFCLLqAGJFezhHkUmMTlUt9NTmqbO4pQbXza JCDxyZ4KeZkyJ78LWv8tdCu3a0k7u0o3vctVlLOyjmzP4SgZrKy6+PEGTPyf9QGCFV aaoAPsHlqXnlBpOaZa+9xp1eJgwG2CWZIqDsZiNxx/B1ykRJ8xQfQsoYtx6n03fkfL YLcsY8XrDVJ6K+N1on68bQQTUoNhbmasu/gXF0L67oNSXixxWyE0EsD6f5jck8klfr yIrKj4drF8pIEZUwAKpu4WoJdBUMnXo1AIPxIk9LFETcDPDn1JY2xjOeXN23mSj4c7 J4XWjEnV+drCA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id F33F35C03F3; Mon, 9 Jan 2023 07:10:55 -0800 (PST) Date: Mon, 9 Jan 2023 07:10:55 -0800 From: "Paul E. McKenney" To: genjian zhang Cc: frederic@kernel.org, linux-kernel@vger.kernel.org, Genjian Zhang , k2ci , kernel test robot Subject: Re: [PATCH] context_tracking: Use arch_atomic_*() in __ct_user_enter and __ct_user_exit Message-ID: <20230109151055.GN4028633@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20221110082443.4069161-1-zhanggenjian@kylinos.cn> <20230106145331.GS4028633@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 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 Mon, Jan 09, 2023 at 03:13:06PM +0800, genjian zhang wrote: > On Fri, Jan 6, 2023 at 10:53 PM Paul E. McKenney wrote: > > > > On Thu, Nov 10, 2022 at 04:24:43PM +0800, Genjian wrote: > > > From: Genjian Zhang > > > > > > vmlinux.o: warning: objtool: __ct_user_enter+0x45: call to > > > __kasan_check_write() leaves .noinstr.text section > > > vmlinux.o: warning: objtool: __ct_user_exit+0x3f: call to > > > __kasan_check_write() leaves .noinstr.text section > > > > > > noinstr cannot have atomic_*() functions.because they have explicit > > > instrumentation.Switch to arch_ prefixed atomic operation functions to > > > avoid the explicit instrumentation. > > > > > > Reported-by: k2ci > > > Reported-by: kernel test robot > > > Signed-off-by: Genjian Zhang > > > > Apologies for the delay, but finally queued, thank you! Frederic gave > > his ack off-list, which I have included in the wordsmithed version below. > > Could you please check to make sure that I did not mess anything up? > > > > Thanx, Paul > > > > ------------------------------------------------------------------------ > > > > commit 936acd859f4a7b2b0f9900e26bc972385286df6e > > Author: Genjian Zhang > > Date: Thu Nov 10 16:24:43 2022 +0800 > > > > context_tracking: Use arch_atomic_*() in __ct_user_enter and __ct_user_exit > > > > The following diagnostics are issued by objtool: > > > > vmlinux.o: warning: objtool: __ct_user_enter+0x45: call to > > __kasan_check_write() leaves .noinstr.text section > > vmlinux.o: warning: objtool: __ct_user_exit+0x3f: call to > > __kasan_check_write() leaves .noinstr.text section > > > > The reason for these diagnostics is that code marked noinstr if prohibited > > from using atomic_*() functions, which have explicit instrumentation. > > Therefore, switch to arch_ prefixed atomic operation functions to avoid > > the explicit instrumentation. > > > > Reported-by: k2ci > > Reported-by: kernel test robot > > Signed-off-by: Genjian Zhang > > Acked-by: Frederic Weisbecker > > Signed-off-by: Paul E. McKenney > > > > diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c > > index 77978e3723771..a09f1c19336ae 100644 > > --- a/kernel/context_tracking.c > > +++ b/kernel/context_tracking.c > > @@ -510,7 +510,7 @@ void noinstr __ct_user_enter(enum ctx_state state) > > * In this we case we don't care about any concurrency/ordering. > > */ > > if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) > > - atomic_set(&ct->state, state); > > + arch_atomic_set(&ct->state, state); > > } else { > > /* > > * Even if context tracking is disabled on this CPU, because it's outside > > @@ -527,7 +527,7 @@ void noinstr __ct_user_enter(enum ctx_state state) > > */ > > if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) { > > /* Tracking for vtime only, no concurrent RCU EQS accounting */ > > - atomic_set(&ct->state, state); > > + arch_atomic_set(&ct->state, state); > > } else { > > /* > > * Tracking for vtime and RCU EQS. Make sure we don't race > > @@ -535,7 +535,7 @@ void noinstr __ct_user_enter(enum ctx_state state) > > * RCU only requires RCU_DYNTICKS_IDX increments to be fully > > * ordered. > > */ > > - atomic_add(state, &ct->state); > > + arch_atomic_add(state, &ct->state); > > } > > } > > } > > @@ -630,12 +630,12 @@ void noinstr __ct_user_exit(enum ctx_state state) > > * In this we case we don't care about any concurrency/ordering. > > */ > > if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) > > - atomic_set(&ct->state, CONTEXT_KERNEL); > > + arch_atomic_set(&ct->state, CONTEXT_KERNEL); > > > > } else { > > if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) { > > /* Tracking for vtime only, no concurrent RCU EQS accounting */ > > - atomic_set(&ct->state, CONTEXT_KERNEL); > > + arch_atomic_set(&ct->state, CONTEXT_KERNEL); > > } else { > > /* > > * Tracking for vtime and RCU EQS. Make sure we don't race > > @@ -643,7 +643,7 @@ void noinstr __ct_user_exit(enum ctx_state state) > > * RCU only requires RCU_DYNTICKS_IDX increments to be fully > > * ordered. > > */ > > - atomic_sub(state, &ct->state); > > + arch_atomic_sub(state, &ct->state); > > } > > } > > } > > Seems good to me. Thank you for checking! Thanx, Paul