Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752468Ab2BTHvb (ORCPT ); Mon, 20 Feb 2012 02:51:31 -0500 Received: from mx2.mail.elte.hu ([157.181.151.9]:37514 "EHLO mx2.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752285Ab2BTHva (ORCPT ); Mon, 20 Feb 2012 02:51:30 -0500 Date: Mon, 20 Feb 2012 08:51:01 +0100 From: Ingo Molnar To: Linus Torvalds Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Linux Kernel Mailing List Subject: Re: [PATCH 2/2] i387: support lazy restore of FPU state Message-ID: <20120220075101.GB30810@elte.hu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-ELTE-SpamScore: -2.0 X-ELTE-SpamLevel: X-ELTE-SpamCheck: no X-ELTE-SpamVersion: ELTE 2.0 X-ELTE-SpamCheck-Details: score=-2.0 required=5.9 tests=AWL,BAYES_00 autolearn=no SpamAssassin version=3.3.1 -2.0 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 AWL AWL: From: address is in the auto white-list Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 968 Lines: 28 * Linus Torvalds wrote: > +DECLARE_PER_CPU(struct task_struct *, fpu_owner_task); > +static inline int fpu_lazy_restore(struct task_struct *new, unsigned int cpu) > +{ > + return new == percpu_read_stable(fpu_owner_task) && > + cpu == new->thread.fpu.last_cpu; > +} I guess the CPU hotplug case deserves a comment in the code: CPU hotplug + replug of the same (but meanwhile reset) CPU is safe because fpu_owner_task[cpu] gets reset to NULL. Likewise, if we hot-unplug two CPUs and then insert the second one, it's the same CPU index but not the same FPU state anymore. There too the CPU hotplug code resetting fpu_owner_task to NULL makes this optimization safe. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/