Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1854500ioo; Mon, 23 May 2022 05:00:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+vKNeXwEQMsP20j5IyaGVW9Nhz/JOG94d+PBBesHg2yL1OZN6fk79BH/5pf9/484+OHlR X-Received: by 2002:a05:6a00:24c1:b0:50d:33cf:811f with SMTP id d1-20020a056a0024c100b0050d33cf811fmr23355084pfv.78.1653307216840; Mon, 23 May 2022 05:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653307216; cv=none; d=google.com; s=arc-20160816; b=DNJfnZvYOjHVYPH6yVLnpx/78eiij8op+E2bgrrABZgNmCqGp/5bkHIrOLTI27KxBU qdqh/je+JQfHadV1Pvu/9fGJX5m9tfkQ68QxHiJFRxwR8Qlar2oFEojyrrAfpu0bkXGz sAMRjUCR04qXtYoe/PVBaw/3N4KwpHxEITN6a83JrD8FWnWSeJ/BaM8l6bUgavhjRUz0 RlmYgZ4HNaH0pp01BynhIw5CCWWT5ydz4s/4uEjsTVX4FF5iiH+Y33S1+8ekt3zQXNhx nYmaIAamJ4wzegRb4YAH8p/3TOMQOrzY9IFOiqeUq350hMg1Ff4OQTzzAuoXtnzFJdAr wrtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=QOajmYKhdw7FboyVED+jQRD4AGpTwiT0CbG9JfF1Sks=; b=PvdB8ixBAO0QWCH/VoW6voXFsD4dYBtu0JDzT85vRiK4sMCDu68RWNPmtx9s48ZpBC CyIwmM8mXU/arIJZyyGmHBw7OYsWDILsrQz2uQaPJXCOetWE5kCOgXbkSojzR87uJe02 90JJ3B6CP8F+xORwsVjnWK5OZyk2XdQmUmlZOuYWXOC2kM0LSvZWXXeYmFT7HJqLeP9l 9yEJbqwXAGNNhnj7rXe6WcqMX0YOOCxPRA8wz4HhaFmvLJQ4pLqlyLqShNBhcloZ/rLH jAwVlLtfKuXSJdxjBVMU0IFKU1RSqrvscp80DiZeLgXArHkG1IWOj2dyrfuPmjJl0xP5 wjrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ivi36bA6; 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=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h63-20020a638342000000b003fa3eb69da4si4611356pge.287.2022.05.23.05.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 05:00:16 -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=@kernel.org header.s=k20201202 header.b=Ivi36bA6; 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=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 323D2527C0; Mon, 23 May 2022 05:00:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235208AbiEWMAI (ORCPT + 99 others); Mon, 23 May 2022 08:00:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235029AbiEWMAB (ORCPT ); Mon, 23 May 2022 08:00:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 378ED522C4 for ; Mon, 23 May 2022 05:00:00 -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 DA7F1B810A0 for ; Mon, 23 May 2022 11:59:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51336C385A9; Mon, 23 May 2022 11:59:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653307197; bh=XMM+gZxt/O8CGFXGNvsrf7e/cybuiv+KJKYDEiG8+bU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Ivi36bA6eYIXk7PRoQIyV7k2sQj0d/c8m1HvZvXjQmaPG8j5yQmHyhsEmwtpPvoqZ Rjenqc4aQeLtsZsBc+UWWwtA5h+iPa9LwA0FZ0VnG2Ie32HA43t44BDF8OP7jUeRCn /eeLxvG/YQUUIj+CAIsxDpTmQbR6553z3PVPP0+4hu/I9VP1tS0W95D66uBUopMy2D 695MZJ59Q3qFswE7QX4/3jx7ioKS8Oth52z8vIi4q3rjWWQqAmcSP193NEZgHEI3dI kRHdebof/rNsl6nzR06sCCOJRGrifemy9xpvSQJJj0WI+Ss7bhtsysdMZy6QzikxLD Rr8qOL/6C2a9A== Message-ID: <3dd156e4de15693f76cbad1cd8980aee827b2f20.camel@kernel.org> Subject: Re: [PATCH 20/21] context_tracking: Convert state to atomic_t From: nicolas saenz julienne To: Frederic Weisbecker Cc: LKML , Peter Zijlstra , Phil Auld , Alex Belits , Xiongfeng Wang , Neeraj Upadhyay , Thomas Gleixner , Yu Liao , Boqun Feng , "Paul E . McKenney" , Marcelo Tosatti , Paul Gortmaker , Uladzislau Rezki , Joel Fernandes Date: Mon, 23 May 2022 13:59:48 +0200 In-Reply-To: <20220519143738.GA612967@lothringen> References: <20220503100051.2799723-1-frederic@kernel.org> <20220503100051.2799723-21-frederic@kernel.org> <372364b33b8d4b93908c3822e18f7d295de2ede9.camel@kernel.org> <20220519143738.GA612967@lothringen> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.1 (3.44.1-1.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-3.0 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 On Thu, 2022-05-19 at 16:37 +0200, Frederic Weisbecker wrote: > On Wed, May 18, 2022 at 05:09:55PM +0200, nicolas saenz julienne wrote: > > On Tue, 2022-05-03 at 12:00 +0200, Frederic Weisbecker wrote: > >=20 > > [...] > >=20 > > > +/** > > > + * ct_state() - return the current context tracking state if known > > > + * > > > + * Returns the current cpu's context tracking state if context track= ing > > > + * is enabled. If context tracking is disabled, returns > > > + * CONTEXT_DISABLED. This should be used primarily for debugging. > > > + */ > > > +static __always_inline int ct_state(void) > > > +{ > > > + int ret; > > > + > > > + if (!context_tracking_enabled()) > > > + return CONTEXT_DISABLED; > > > + > > > + preempt_disable(); > > > + ret =3D __ct_state(); > > > + preempt_enable(); > > > + > > > + return ret; > > > +} > > > + > >=20 > > I can't see any use for this function with preemption enabled. You can'= t trust > > the data due to CPU migration and it could be a source of bugs in the f= uture. > > Wouldn't it make more sense to move the burden into the callers? They a= ll DTRT, > > plus, this_cpu_ptr() will spew warnings if someone shows up and doesn't= comply. >=20 > I believe syscall_exit_to_user_mode_prepare() has preemption enabled. > Then it's ok if we are scheduled away right before the check, it still ap= plies > on any CPU. Fair enough. --=20 Nicol=C3=A1s S=C3=A1enz