Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp509576pxb; Thu, 23 Sep 2021 05:11:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3sZE7+aQL9lDwM5lvo18nAJso/btOIFBQxPSc1Ya+PvxYB1CCJKWlDx4w2x/yubfy6prE X-Received: by 2002:a05:600c:a4b:: with SMTP id c11mr4124044wmq.97.1632399117131; Thu, 23 Sep 2021 05:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632399117; cv=none; d=google.com; s=arc-20160816; b=VwOpqqkKW5df8S5V0k7fkBcxyWc5SSAB5Dl3H45Kb7ydBTb/MM7OI9xOWaQNquOKHc XsOGoLkQdm3mCxsaz82SpxfJEO0o4cPQnDpsN4vJTzQOhTMFXl3HC6hEeFVtKyXqbE8a XgUvbPlELmVrtWZTcthywng1TJw73CPBitVL2KOzPEbAw2G74CXOHEYVgJfFNkzheul0 sEtg3qpas9aldl4RvQ0spzu2KN4r0liNUXrk2HbVdwogrzEgM3DGwLOMFVbTqhvTaOKz HfcVXtwKx60tYCfvv7GFQEYShJANuKEmKoHt6x2czrR2PyrsJEmTyd3AKoxC0Dm9xCKQ davQ== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=60zH4HmS78UD32XiMlZJRxsSTbMfO5jzidDMFH51zO0=; b=c4leMqdq82SPo5UY+TAUj6eXnuAm5m626PPt3zBYJ1DSHxl63YSmXyWYSJZfljQlyw xaIxClsg0Cwy45RUp+uFPo7t8NTzKq0kAHOP4EHJqIaxFCCPU4AWFd3r/u5SMCdmeEb9 UWHsO5QCRUTVxc5MLCJGiqsZyxlXxnsrqLIBgzz4cTL/OCzmSCykyLbieQuaP53H3uJL nK7Oo7XBTs/Z3Hovl0WzoBG/HgzjlxodxXkdQPh1CpZTuPqH2ZicHmVBuxdiT7Kv5n2O 7L3aPOHjQjI8rrqxoslQ7C8vqBo8nyZKT2dYZtH0SMDmbVanOHnsoU4Vr4XguqmWISGL vs9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=EVhZdPg3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gv43si5750138ejc.88.2021.09.23.05.11.31; Thu, 23 Sep 2021 05:11:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=EVhZdPg3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240761AbhIWMLf (ORCPT + 99 others); Thu, 23 Sep 2021 08:11:35 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:55710 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240619AbhIWMLe (ORCPT ); Thu, 23 Sep 2021 08:11:34 -0400 Received: from relay1.suse.de (relay1.suse.de [149.44.160.133]) by smtp-out1.suse.de (Postfix) with ESMTP id 6B22B2233D; Thu, 23 Sep 2021 12:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1632399001; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=60zH4HmS78UD32XiMlZJRxsSTbMfO5jzidDMFH51zO0=; b=EVhZdPg3tgzeEk5QeMdxzIAwT5d39uoswBpNhZPxw2DcRHXrQaYNM1TM+NfmPrNkiNPREU +mImKKSj56DQQxeAL2g8dMprHVjJiVrgcbsKYxd525lG6JMssJjx9uCTCDLq50PF5P+1rn oXL+iN+PpAMCXvHrk/1TEtTo6AdO8do= Received: from suse.cz (unknown [10.100.224.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay1.suse.de (Postfix) with ESMTPS id 47CC225D3C; Thu, 23 Sep 2021 12:10:01 +0000 (UTC) Date: Thu, 23 Sep 2021 14:10:01 +0200 From: Petr Mladek To: Peter Zijlstra Cc: gor@linux.ibm.com, jpoimboe@redhat.com, jikos@kernel.org, mbenes@suse.cz, mingo@kernel.org, linux-kernel@vger.kernel.org, joe.lawrence@redhat.com, fweisbec@gmail.com, tglx@linutronix.de, hca@linux.ibm.com, svens@linux.ibm.com, sumanthk@linux.ibm.com, live-patching@vger.kernel.org, paulmck@kernel.org Subject: Re: [RFC][PATCH 6/7] context_tracking: Provide SMP ordering using RCU Message-ID: References: <20210922110506.703075504@infradead.org> <20210922110836.244770922@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210922110836.244770922@infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2021-09-22 13:05:12, Peter Zijlstra wrote: > Use rcu_user_{enter,exit}() calls to provide SMP ordering on context > tracking state stores: > > __context_tracking_exit() > __this_cpu_write(context_tracking.state, CONTEXT_KERNEL) > rcu_user_exit() > rcu_eqs_exit() > rcu_dynticks_eqs_eit() > rcu_dynticks_inc() > atomic_add_return() /* smp_mb */ > > __context_tracking_enter() > rcu_user_enter() > rcu_eqs_enter() > rcu_dynticks_eqs_enter() > rcu_dynticks_inc() > atomic_add_return() /* smp_mb */ > __this_cpu_write(context_tracking.state, state) > > This separates USER/KERNEL state with an smp_mb() on each side, > therefore, a user of context_tracking_state_cpu() can say the CPU must > pass through an smp_mb() before changing. > > Signed-off-by: Peter Zijlstra (Intel) > --- > include/linux/context_tracking_state.h | 12 ++++++++++++ > kernel/context_tracking.c | 7 ++++--- > 2 files changed, 16 insertions(+), 3 deletions(-) > > --- a/include/linux/context_tracking_state.h > +++ b/include/linux/context_tracking_state.h > @@ -45,11 +45,23 @@ static __always_inline bool context_trac > { > return __this_cpu_read(context_tracking.state) == CONTEXT_USER; > } > + > +static __always_inline bool context_tracking_state_cpu(int cpu) > +{ > + struct context_tracking *ct = per_cpu_ptr(&context_tracking); Missing cpu parameter: struct context_tracking *ct = per_cpu_ptr(&context_tracking, cpu); > + > + if (!context_tracking_enabled() || !ct->active) > + return CONTEXT_DISABLED; > + > + return ct->state; > +} Best Regards, Petr