From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933362AbbDUVGL (ORCPT ); Tue, 21 Apr 2015 17:06:11 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:34619 "EHLO mail-wg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932096AbbDUVGI (ORCPT ); Tue, 21 Apr 2015 17:06:08 -0400 Date: Tue, 21 Apr 2015 23:06:04 +0200 From: Frederic Weisbecker To: Peter Zijlstra Cc: LKML , Mike Galbraith , Chris Metcalf , Ingo Molnar , Dave Jones , Thomas Gleixner , Oleg Nesterov , "Rafael J . Wysocki" , "Paul E . McKenney" , Ingo Molnar , Rik van Riel , Martin Schwidefsky Subject: Re: [PATCH 2/4] context_tracking: Inherit TIF_NOHZ through forks instead of context switches Message-ID: <20150421210603.GB10289@lerouge> References: <1429618989-11104-1-git-send-email-fweisbec@gmail.com> <1429618989-11104-3-git-send-email-fweisbec@gmail.com> <20150421152600.GE3182@worktop.meeting.verilan.com> <20150421165152.GA10289@lerouge> <20150421205218.GB2898@worktop.Skamania.guest> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150421205218.GB2898@worktop.Skamania.guest> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 21, 2015 at 10:52:18PM +0200, Peter Zijlstra wrote: > On Tue, Apr 21, 2015 at 06:51:54PM +0200, Frederic Weisbecker wrote: > > On Tue, Apr 21, 2015 at 05:26:00PM +0200, Peter Zijlstra wrote: > > > On Tue, Apr 21, 2015 at 02:23:07PM +0200, Frederic Weisbecker wrote: > > > > +void __init context_tracking_cpu_set(int cpu) > > > > { > > > > + static __initdata bool initialized = false; > > > > + struct task_struct *p, *t; > > > > + > > > > + if (!per_cpu(context_tracking.active, cpu)) { > > > > + per_cpu(context_tracking.active, cpu) = true; > > > > + static_key_slow_inc(&context_tracking_enabled); > > > > + } > > > > + > > > > + if (initialized) > > > > + return; > > > > + > > > > + set_tsk_thread_flag(&init_task, TIF_NOHZ); > > > > + > > > > + /* > > > > + * There shouldn't be any thread at this early boot stage > > > > + * but the scheduler is ready to host any. So lets walk > > > > + * the tasklist just in case. tasklist_lock isn't necessary > > > > + * either that early but take it for correctness checkers. > > > > + */ > > > > + read_lock(&tasklist_lock); > > > > + for_each_process_thread(p, t) > > > > + set_tsk_thread_flag(t, TIF_NOHZ); > > > > > > If there should not be any task, should there not be a WARN_ON_ONCE() > > > here? > > > > Well, it's legal to have a task at that time because sched_init() was called. > > I just haven't observed any task other than init/0. But future code (or alternate > > configs than mine) might create a task between sched_init() and tick_init(). And > > the above code takes care of such a possibility. > > So why not do it sooner? Because I need the tick nohz intialization to be after irq initialization (init_IRQ()), which it depends on.