Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp562931pxu; Wed, 14 Oct 2020 08:09:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8slEzNB1wtmlKhnwulOCOQBqrJDkRLoTbfemsB2GRlJATyfeAlQFBjdWlBBowsvcUdjOD X-Received: by 2002:aa7:c2d9:: with SMTP id m25mr5936329edp.226.1602688160556; Wed, 14 Oct 2020 08:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602688160; cv=none; d=google.com; s=arc-20160816; b=GT0qKsVFmZvOp791b+XflojpptJ7hJB0ZcTF0kYIjbUDUmjtJS5hz76AGfo4DSWAJC egh3agZCBRDIfB0U2xWO1UcE18GmvNh2cW0nwb9HHlPYAUfc0rfnJJresy1s0eKjbpnE LHPc+748oW7G8bgkCGi1v68e5yRBx1Rv3TJcB2WnTYFck8JGHVO2PWOUXfyE1DOkCl+6 3LT9e3JJud+RVZrGEKdOU7bn7uVw51OqAe5Mg8yqksafUQqucu2W5paPuV00mjKy0dId rP65Sh2ZMPHOZ4TmghngsbXptee5N7z0MVhvbI1BW/pyIMQjEO2xQlzNFl5gAvYowsR3 aGCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=Av0sc24i6lEFhIAnbFGzZuUEOiE1zUu95DhFP+t05mI=; b=s5yOyzrbYN21SFYrpv66Ng4Iv6gdLJHjVDvj9zwRHpC4uEsSdsNdiezxObJueyCr+O MKyuX2HuvVFtyhCGKYiNxmxKbk5II6sIVzJPl51uVIWQ1u1nxP0YIrqg6eWBrhK7GF2u 8AGiaL7+utPEQ6tpZ6MZ46LZmfuqHu4tJw6FNNtWAnQCCOdMi4DaxX0Sod+5vVZT5/a3 qsU2dvG7mjPecqQ1ULdnck6Ct3BxD0ZWntFJu/fTrDPdWKZ/HpJleYvufAM6JpxY2buR kVh+NWvY0ydDok+TYEl3eFbwi+Lt0DxE9T3P0SJP8iXkZnO5vuzZd4NJYb/sEOttIFAq sNCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="lbJSJHY/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s8si2433603edy.195.2020.10.14.08.08.52; Wed, 14 Oct 2020 08:09:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="lbJSJHY/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731034AbgJNJUn (ORCPT + 99 others); Wed, 14 Oct 2020 05:20:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731015AbgJNJUl (ORCPT ); Wed, 14 Oct 2020 05:20:41 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0BE6C0A88AB for ; Tue, 13 Oct 2020 18:11:57 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id w21so895712plq.3 for ; Tue, 13 Oct 2020 18:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=Av0sc24i6lEFhIAnbFGzZuUEOiE1zUu95DhFP+t05mI=; b=lbJSJHY/T/sf3n00RFb4Anqy7341XAb2OH1+6dgS+1b7uE+qssx0RXYhLX1nzdZ4AA i3sq37VHoJqeSJHfUIOVwbgnVd3UX87aancDK5X/JB/FXc1tbWCBPCx4udj6QnmkDDn6 TIiUvwJ0dGfSH9DLT5vsU10ZG4WPueSef65ydYWmzAXciBWYNkQ+viqcTQi9izPyp7mV Cf4orD9ionuvIiBWY0pTkYAxlHWBkm7eTbl0nGJ92weERTCrs3UPCFKWP0SIfxhfrGOU ia15GddIa+ZpOE9I0hVcFm87Lk02c8RTURGuwMpqooxblgtWTKclB96xafe9myfmUhVz e1OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=Av0sc24i6lEFhIAnbFGzZuUEOiE1zUu95DhFP+t05mI=; b=ZMNK10wbH6BCcy9WjYnERznKUBtqAHyCpCnjo93klWysJioIp/ef4l7fu57thJlTKS W7pcZoJOTP2opsvjnwg8kRlv00114QAaYzquUnjHft7tnjBTaqqx8Bub5kScpHR7gbpg YLf1lnO4E8uBWnKs7aClv0KRqLRpvuM5OhwvDfBUTVV5Gmd1TXObj5V0iKipSKz0/O9z 5YDBDHNRePzO03w5rOiP5M4nm2FSMPgoID63zlzd6tl6k0zikZ8hBNLiDTsh7J9Av2/8 snGbHpr+VQYtzx3EyHS5/GFfSz8NXJ2dBGMZrTkU46NBEi/c+b/HA065Ax4ef+zi0ZNS pjBg== X-Gm-Message-State: AOAM533LhavPzqwcOudZ7m9SnhnCwuf5YDeSeG2HBCGbbSVnnCoq3YW0 1nHr9zwLhuHi5Qcbu3+ON8Tp2w== X-Received: by 2002:a17:90b:438c:: with SMTP id in12mr1068864pjb.32.1602637917349; Tue, 13 Oct 2020 18:11:57 -0700 (PDT) Received: from ?IPv6:2600:1010:b055:a6b7:fd8a:19ca:e5b3:189e? ([2600:1010:b055:a6b7:fd8a:19ca:e5b3:189e]) by smtp.gmail.com with ESMTPSA id j11sm941451pfh.143.2020.10.13.18.11.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Oct 2020 18:11:56 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [RFC PATCH 13/22] x86/fpu/xstate: Expand dynamic user state area on first use Date: Tue, 13 Oct 2020 18:11:55 -0700 Message-Id: <78F221DB-CB61-40DB-9C6F-6C86D0F1BCDF@amacapital.net> References: Cc: "Brown, Len" , Andy Lutomirski , "Bae, Chang Seok" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , X86 ML , "Liu, Jing2" , "Shankar, Ravi V" , LKML In-Reply-To: To: Dave Hansen X-Mailer: iPhone Mail (18A393) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Oct 13, 2020, at 3:44 PM, Dave Hansen wrote: >=20 > =EF=BB=BFOn 10/13/20 3:31 PM, Brown, Len wrote: >> vmalloc() does not fail, and does not return an error, and so there is no= concept >> of returning a signal. >=20 > Well, the order-0 allocations are no-fail, as are the vmalloc kernel > structures and the page tables that might have to be allocated. But, > that's not guaranteed to be in place *forever*. I think we still need > to check for and handle allocation failures, even if they're not known > to be possible today. >=20 >> If we got to the point where vmalloc() sleeps, then the system >> has bigger OOM issues, and the OOM killer would be on the prowl. >=20 > vmalloc() can *certainly* sleep. Allocation failures mean returning > NULL from the allocator, and the very way we avoid doing that is by > sleeping to go reclaim some memory from some other allocation. >=20 > Sleeping is a normal and healthy part of handling allocation requests, > including vmalloc(). >=20 >> If we were concerned about using vmalloc for a couple of pages in the tas= k structure, >> Then we could implement a routine to harvest unused buffers and free them= -- >> but that didn't seem worth the complexity. Note that this feature is 64-= bit only. >=20 > IMNHO, vmalloc() is overkill for ~10k, which is roughly the size of the > XSAVE buffer for the first AMX implementation. But, it's not overkill > for the ~66k of space that will be needed if some CPU implementation > comes along and uses all of the architectural space AMX provides. I have no problem with vmalloc(), but I do have a problem with vfree() due t= o the IPIs that result. We need a cache or something. I have to say: this mechanism is awful. Can we get away with skipping the dy= namic XSAVES mess entirely? What if we instead allocate however much space w= e need as an array of pages and have one percpu contiguous region. To save, w= e XSAVE(S or C) just the AMX state to the percpu area and then copy it. To r= estore, we do the inverse. Or would this kill the modified optimization and= thus be horrible?=