Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753095AbcDKIiw (ORCPT ); Mon, 11 Apr 2016 04:38:52 -0400 Received: from mx2.suse.de ([195.135.220.15]:41768 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751567AbcDKIis (ORCPT ); Mon, 11 Apr 2016 04:38:48 -0400 Date: Mon, 11 Apr 2016 10:38:46 +0200 From: Petr Mladek To: Josh Poimboeuf Cc: Jiri Kosina , Jessica Yu , Miroslav Benes , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Vojtech Pavlik Subject: Re: sched: horrible way to detect whether a task has been preempted Message-ID: <20160411083846.GL5218@pathway.suse.cz> References: <24db5a6ae5b63dfcd2096a12d18e1399a351348e.1458933243.git.jpoimboe@redhat.com> <20160407211525.GB25804@packer-debian-8-amd64.digitalocean.com> <20160407231512.GA27994@packer-debian-8-amd64.digitalocean.com> <20160408080304.GE5218@pathway.suse.cz> <20160408143131.46ysnwy6c7i6uxmb@treble.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160408143131.46ysnwy6c7i6uxmb@treble.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1559 Lines: 38 On Fri 2016-04-08 09:31:31, Josh Poimboeuf wrote: > On Fri, Apr 08, 2016 at 10:03:04AM +0200, Petr Mladek wrote: > > The big advantage about checking the stack is that it does not add > > any overhead to the scheduler code, does not eat any TIF flag or > > memory. The overhead is only when we are migrating a task and it is > > charged to a separate process. > > My biggest concern about checking the stack for preempt_schedule_irq() > is that it's kind of brittle: > > - What if the preemption code changes such that it's no longer a > reliable indicator? For example, what if preempt_schedule_irq() is > only called in some places, and a new __preempt_schedule_irq() is > called elsewhere? > > - Or due to some obscure gcc optimization like partial inlining or > sibling tail calls, preempt_schedule_irq() doesn't show up on the > stack? > > - Or the code could silently break if there were another static > preempt_schedule_irq symbol somewhere (though we could prevent this by > searching all symbols to ensure there are no duplicates). > > These scenarios are unlikely, but they could conceivably happen... You are right. > Anyway, we really wouldn't have to eat a TIF flag. We could instead add > something to task_struct. I can at least propose it. If anybody > doesn't like it, maybe they'll suggest something else, or maybe then we > can go with checking the stack. Yup, we should give the extra task struct stuff a try. Another advantage is that it would be easier to port for another architectures. Best Regards, Petr