Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752595AbcD2WmR (ORCPT ); Fri, 29 Apr 2016 18:42:17 -0400 Received: from mga14.intel.com ([192.55.52.115]:23792 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750800AbcD2WmQ (ORCPT ); Fri, 29 Apr 2016 18:42:16 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,553,1455004800"; d="scan'208";a="965691890" Subject: Re: [PATCH v4 0/10] x86/xsaves: Fix XSAVES known issues To: Andy Lutomirski References: <5723A353.7060209@linux.intel.com> <20160429195741.GA15402@test-lenovo> <5723BE1F.7040300@linux.intel.com> <20160429200709.GA15412@test-lenovo> <5723C6A7.4020704@linux.intel.com> Cc: Yu-cheng Yu , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , "linux-kernel@vger.kernel.org" , Andy Lutomirski , Borislav Petkov , Sai Praneeth Prakhya , "Ravi V. Shankar" , Fenghua Yu From: Dave Hansen Message-ID: <5723E347.2020700@linux.intel.com> Date: Fri, 29 Apr 2016 15:42:15 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1151 Lines: 25 On 04/29/2016 01:49 PM, Andy Lutomirski wrote: >> > >> > But I also think it would be pretty nice if 'ls' didn't pay the 2k cost >> > to have AVX-512 state if it's not using AVX-512. We also don't have to >> > do this with CR0.TS. We'd actually use a combination of out-of-line >> > (not appended to task_struct) XSAVE buffers and XGETBV1 to check the >> > size of our XSAVE buffer before we call XSAVE* and resize it when needed. >> > >> > Maybe nobody will ever care enough about 2kbytes/thread, though. > I suspect we're so far about 2k/thread that no one cares. > ... > However, what do we do if we run out when memory when trying to reallocate? The thread has to die a horrible death. We can switch away from it, but can never switch back to it. Well we can switch to it, we just can't return to userspace. Actually, though... On my laptop 1/3 of the task_struct is XSAVE state (it's ~3k). With AVX-512, ~3/5 of it will be XSAVE, and it will be ~5k (>1 page). Breaking it in to two pieces makes it overall less likely that we'd have to fail an allocation. We'd be in a situation where we probably can't fork *anyway* if that happened.