Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4011979pxb; Mon, 27 Sep 2021 07:35:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEUfycAoIzX8naf3WY+cn5YAqpKzrM36CFWfBGwtlC8ok/XU/9mWPWeBDGNgKXtJjX0szR X-Received: by 2002:a17:907:2131:: with SMTP id qo17mr430108ejb.224.1632753313564; Mon, 27 Sep 2021 07:35:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632753313; cv=none; d=google.com; s=arc-20160816; b=ZK6+nbFyo/QjY8934Wa/CLqaw9jKjQ+6drSllpMXBWl63wpUOG2s4iO05n5fB2UuMj yAIyniWARo5jnCgSYgWeCGh7K6U+kC2D8NBn3c38hxvVJ+H64EpoJD3QTo7HwVhXOre/ RxH7zqkqNHlRf7CkMLWbSra1cCztY1yKBAvVYgXtr47x1QO3pK5L4g2HtpMHN9PEagYZ ckPctYQx9Ufd9i4jsJe0S41C5BtK3WoQ43oe6+MjVjkUERl48nsbZMrbOhExM1SfK6yP TZc+Op7Ao1it8OOQ4rd6j4Kx7BKZrojoecuK893fDVFy+bjpj73hxM19tIYmr9S958s6 r9GA== 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=8sRfJ93TTmGOFGZU8ki6FPLOxhHNL/86eQfL7gvj9gQ=; b=W+EMjfe5d2JinJgnzt6YJgQ6RIeY+CJTAnAGKtu6lnQF0k+Exmh7tbAcv4Xarlxk1r hT0fARwShsTSVxr7f40lMrn1JWRZ9xyd10i7TAv5f98MJp/F+W0V8WjnYx1y+JC91GYP g6wAqrLi6HG49JmzBYx0o1DXzV2OKLkv5MDVzmw+i9/aq65q1H8LuQJCkmU2OW/85TA+ K1E0zq4B0jd9ozPLPGVP724LeoahkxasClpCCVJFDYjPkzmJDPIiKhBV80nj+43oHR/H zIvp7qy2zO/EIrCONskwx0bt3MjWNPLzJkIEx0hnEl7qhYTAD5HsUqkA9s0Usd1z6Yj7 hbnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="a/WYLTWi"; 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 n11si18278195ejl.110.2021.09.27.07.34.48; Mon, 27 Sep 2021 07:35:13 -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="a/WYLTWi"; 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 S234859AbhI0Oeu (ORCPT + 99 others); Mon, 27 Sep 2021 10:34:50 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47740 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234773AbhI0Oet (ORCPT ); Mon, 27 Sep 2021 10:34:49 -0400 Received: from relay1.suse.de (relay1.suse.de [149.44.160.133]) by smtp-out2.suse.de (Postfix) with ESMTP id A996620123; Mon, 27 Sep 2021 14:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1632753190; 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=8sRfJ93TTmGOFGZU8ki6FPLOxhHNL/86eQfL7gvj9gQ=; b=a/WYLTWiEM9GJYgC5HzGv8VcH4DK/a7cGtQ/cs6cuyVDt3izc7Z6qSGi9Uf+NmYqOlRitB 8HTV0UlyNeGA3URQpOCd141qS9GEL+7lcyqV7KEcmGuHsKjRLljdPnhclSsk10jp1x2J2e nh11fNJsasqPbuSY8Obt4NyZGF139Ps= Received: from suse.cz (unknown [10.100.216.66]) (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 849F02646C; Mon, 27 Sep 2021 14:33:10 +0000 (UTC) Date: Mon, 27 Sep 2021 16:33:10 +0200 From: Petr Mladek To: Joel Savitz Cc: Peter Zijlstra , 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> <20210924185705.GA1264192@jsavitz.bos.csb> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210924185705.GA1264192@jsavitz.bos.csb> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 2021-09-24 14:57:05, Joel Savitz wrote: > On Wed, Sep 22, 2021 at 01:05:12PM +0200, Peter Zijlstra wrote: > > --- > > 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); > > + > > + if (!context_tracking_enabled() || !ct->active) > > + return CONTEXT_DISABLED; > > + > > + return ct->state; > > +} > > + > > #else > > static inline bool context_tracking_in_user(void) { return false; } > > static inline bool context_tracking_enabled(void) { return false; } > > static inline bool context_tracking_enabled_cpu(int cpu) { return false; } > > static inline bool context_tracking_enabled_this_cpu(void) { return false; } > > +static inline bool context_tracking_state_cpu(int cpu) { return CONTEXT_DISABLED; } > > #endif /* CONFIG_CONTEXT_TRACKING */ > > > > #endif > > Should context_tracking_state_cpu return an enum ctx_state rather than a > bool? It appears to be doing an implicit cast. Great catch! > I don't know if it possible to run livepatch with > CONFIG_CONTEXT_TRACKING disabled, It should work with CONFIG_CONTEXT_TRACKING. The original code migrates the task only when it is not running on any CPU and patched functions are not on the stack. The stack check covers also the user context. > modified by patch 7 will always consider the transition complete even if > the current task is in kernel mode. Also in the general case, the CPU > will consider the task complete if has ctx_state CONTEXT_GUEST though the > condition does not make it explicit. Yup, we should avoid the enum -> bool cast, definitely. Best Regards, Petr