From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756668AbdEKP2B (ORCPT ); Thu, 11 May 2017 11:28:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59278 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751705AbdEKP1U (ORCPT ); Thu, 11 May 2017 11:27:20 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 010DA3DBC4 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jpoimboe@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 010DA3DBC4 Date: Thu, 11 May 2017 10:27:18 -0500 From: Josh Poimboeuf To: Petr Mladek Cc: Steven Rostedt , Jessica Yu , Jiri Kosina , Miroslav Benes , "Paul E. McKenney" , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] livepatch/rcu: Warn when system consistency is broken in RCU code Message-ID: <20170511152718.43bcegyzdlyfztw7@treble> References: <1493895316-19165-1-git-send-email-pmladek@suse.com> <1493895316-19165-3-git-send-email-pmladek@suse.com> <20170508165108.d3vd4h6ffa25bfui@treble> <20170508151322.76e8e9db@gandalf.local.home> <20170511135246.GN3452@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170511135246.GN3452@pathway.suse.cz> User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 11 May 2017 15:27:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 11, 2017 at 03:52:46PM +0200, Petr Mladek wrote: > Anyway, a crazy idea is to use the livepatch consistency model instead > of RCU to protect the function stack. The model makes sure that all > tasks, including the idle ones, were not running any patched function > (and their ftrace handlers) at some point. It should be safe > but I am not sure if it is worth it. http://i3.kym-cdn.com/photos/images/original/000/173/580/Wat.jpg > Alternatively, it might be enough to use the probably more lightwight > solution that is used when ftrace handlers are deregistered, I mean: > > /* > * We need to do a hard force of sched synchronization. > * This is because we use preempt_disable() to do RCU, but > * the function tracers can be called where RCU is not watching > * (like before user_exit()). We can not rely on the RCU > * infrastructure to do the synchronization, thus we must do it > * ourselves. > */ > schedule_on_each_cpu(ftrace_sync); > > /* > * When the kernel is preeptive, tasks can be preempted > * while on a ftrace trampoline. Just scheduling a task on > * a CPU is not good enough to flush them. Calling > * synchornize_rcu_tasks() will wait for those tasks to > * execute and either schedule voluntarily or enter user space. > */ > if (IS_ENABLED(CONFIG_PREEMPT)) > synchronize_rcu_tasks(); I couldn't grok the first idea, but this one sounds promising... -- Josh