[{"id":1768423,"web_url":"http://patchwork.ozlabs.org/comment/1768423/","msgid":"<87k211acqe.fsf@linaro.org>","list_archive_url":null,"date":"2017-09-14T08:47:05","subject":"Re: [PATCH v2 12/28] arm64/sve: Support vector length resetting for\n\tnew processes","submitter":{"id":39532,"url":"http://patchwork.ozlabs.org/api/people/39532/","name":"Alex Bennée","email":"alex.bennee@linaro.org"},"content":"Dave Martin <Dave.Martin@arm.com> writes:\n\n> It's desirable to be able to reset the vector length to some sane\n> default for new processes, since the new binary and its libraries\n> processes may or may not be SVE-aware.\n>\n> This patch tracks the desired post-exec vector length (if any) in a\n> new thread member sve_vl_onexec, and adds a new thread flag\n> TIF_SVE_VL_INHERIT to control whether to inherit or reset the\n> vector length.  Currently these are inactive.  Subsequent patches\n> will provide the capability to configure them.\n>\n> Signed-off-by: Dave Martin <Dave.Martin@arm.com>\n> Cc: Alex Bennée <alex.bennee@linaro.org>\n\nReviewed-by: Alex Bennée <alex.bennee@linaro.org>\n\n>\n> ---\n>\n> Changes since v1\n> ----------------\n>\n> Requested by Alex Bennée:\n>\n> * Make sve_vl_onexec an unsigned int: that's the type used virtually\n> everywhere else, and the memory saving is too minor to be interesting.\n> ---\n>  arch/arm64/include/asm/processor.h   |  1 +\n>  arch/arm64/include/asm/thread_info.h |  1 +\n>  arch/arm64/kernel/fpsimd.c           | 16 ++++++++++++----\n>  3 files changed, 14 insertions(+), 4 deletions(-)\n>\n> diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h\n> index 4831d28..3faceac 100644\n> --- a/arch/arm64/include/asm/processor.h\n> +++ b/arch/arm64/include/asm/processor.h\n> @@ -87,6 +87,7 @@ struct thread_struct {\n>  \tstruct fpsimd_state\tfpsimd_state;\n>  \tvoid\t\t\t*sve_state;\t/* SVE registers, if any */\n>  \tunsigned int\t\tsve_vl;\t\t/* SVE vector length */\n> +\tunsigned int\t\tsve_vl_onexec;\t/* SVE vl after next exec */\n>  \tunsigned long\t\tfault_address;\t/* fault info */\n>  \tunsigned long\t\tfault_code;\t/* ESR_EL1 value */\n>  \tstruct debug_info\tdebug;\t\t/* debugging */\n> diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h\n> index f0880fc..d3568ab 100644\n> --- a/arch/arm64/include/asm/thread_info.h\n> +++ b/arch/arm64/include/asm/thread_info.h\n> @@ -92,6 +92,7 @@ void arch_setup_new_exec(void);\n>  #define TIF_SINGLESTEP\t\t21\n>  #define TIF_32BIT\t\t22\t/* 32bit process */\n>  #define TIF_SVE\t\t\t23\t/* Scalable Vector Extension in use */\n> +#define TIF_SVE_VL_INHERIT\t24\t/* Inherit sve_vl_onexec across exec */\n>\n>  #define _TIF_SIGPENDING\t\t(1 << TIF_SIGPENDING)\n>  #define _TIF_NEED_RESCHED\t(1 << TIF_NEED_RESCHED)\n> diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c\n> index 9b1ebd7..e20b44d 100644\n> --- a/arch/arm64/kernel/fpsimd.c\n> +++ b/arch/arm64/kernel/fpsimd.c\n> @@ -106,6 +106,9 @@\n>   */\n>  static DEFINE_PER_CPU(struct fpsimd_state *, fpsimd_last_state);\n>\n> +/* Default VL for tasks that don't set it explicitly: */\n> +static int sve_default_vl = SVE_VL_MIN;\n> +\n>  static void sve_free(struct task_struct *task)\n>  {\n>  \tkfree(task->thread.sve_state);\n> @@ -380,15 +383,20 @@ void fpsimd_flush_thread(void)\n>  \t\t * If a bug causes this to go wrong, we make some noise and\n>  \t\t * try to fudge thread.sve_vl to a safe value here.\n>  \t\t */\n> -\t\tvl = current->thread.sve_vl;\n> -\n> -\t\tif (vl == 0)\n> -\t\t\tvl = SVE_VL_MIN;\n> +\t\tvl = current->thread.sve_vl_onexec ?\n> +\t\t\tcurrent->thread.sve_vl_onexec : sve_default_vl;\n>\n>  \t\tif (WARN_ON(!sve_vl_valid(vl)))\n>  \t\t\tvl = SVE_VL_MIN;\n>\n>  \t\tcurrent->thread.sve_vl = vl;\n> +\n> +\t\t/*\n> +\t\t * If the task is not set to inherit, ensure that the vector\n> +\t\t * length will be reset by a subsequent exec:\n> +\t\t */\n> +\t\tif (!test_thread_flag(TIF_SVE_VL_INHERIT))\n> +\t\t\tcurrent->thread.sve_vl_onexec = 0;\n>  \t}\n>\n>  \tset_thread_flag(TIF_FOREIGN_FPSTATE);\n\n\n--\nAlex Bennée","headers":{"Return-Path":"<libc-alpha-return-84595-incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list libc-alpha@sourceware.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-84595-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"Lj+qmZxW\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xtBx45Wnxz9t1t\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 18:47:20 +1000 (AEST)","(qmail 114816 invoked by alias); 14 Sep 2017 08:47:13 -0000","(qmail 114793 invoked by uid 89); 14 Sep 2017 08:47:11 -0000"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:references:from:to:cc:subject:in-reply-to:date\n\t:message-id:mime-version:content-type:content-transfer-encoding;\n\tq=dns; s=default; b=ebnBWwas7ZQ1qq/eptzbWTp05JHGAteOUR9sKVBhksJ\n\tINYSWRCmu7xedpyvZlRNW5Owpnwfd6kK3JF+WcUPDxyKNHIe14nKp0YhAOTAcRy7\n\ttRN/nDAI/bw5+HUsHFjcPGlnPq6cJCeqE/UDr6OxlAVFhO+6brXMvGO9SggVPSKw\n\t=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:references:from:to:cc:subject:in-reply-to:date\n\t:message-id:mime-version:content-type:content-transfer-encoding;\n\ts=default; bh=i1f52WyxpHTEXofairxgCcK7ePw=; b=Lj+qmZxWyZq95H7C2\n\tsSCZaLRa3YYAqze4ZoqLdSirD2nMGP7fd4w7OQtX5GQ0jOWxP7PnglN0sA1XRzeJ\n\teNFGCAWwe6y+EPdul5wDLrWHi5Xud3Y6qTiRyPJI0BI2qw71TRBdNEDZcfxzAsXF\n\tcZADzL3rqxguEBtSqYtj2jkDCY=","Mailing-List":"contact libc-alpha-help@sourceware.org; run by ezmlm","Precedence":"bulk","List-Id":"<libc-alpha.sourceware.org>","List-Unsubscribe":"<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>","List-Subscribe":"<mailto:libc-alpha-subscribe@sourceware.org>","List-Archive":"<http://sourceware.org/ml/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>","Sender":"libc-alpha-owner@sourceware.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-26.0 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=virtually,\n\tSubsequent","X-HELO":"mail-wr0-f170.google.com","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:references:user-agent:from:to:cc:subject\n\t:in-reply-to:date:message-id:mime-version:content-transfer-encoding; \n\tbh=K1qBokwOv8PEMIMbp4Uu9EDPFp+Oj6h+y2N2wJEERVE=;\n\tb=TQ2PsHIE8986fAgarjVEPUqornHLww6ItGi8gKgl3JDlUpcku7lZ4MUG2c12rVR6HZ\n\tXjW8qQ5e2sQsv1sVdK/qr00HvBjz4+MNrDE9pNYCuLzLchNOK2s1crar0Ilgk4wuK/Pt\n\t6IERl1VWPRNMK7gzGZI4Bj0XzrDJFu5rDc3mk/ao8JVV56k+tOpiClIjaOpZjZiLg1V8\n\tefTS6NPaEcLfUtN5kBoyTkiRYgSvDK6l4J0a4iDnnGEE/1a/J0tsxdt8G57O2/XySA0x\n\tNFfWjQMT6b2eJJQw1MAuuwX8hPxYvmTbV0fDup0jrV9zYllPF85Yc/ZHCr21iRKFV7fB\n\tc1Yg==","X-Gm-Message-State":"AHPjjUhzQ8Djt50XPJptP1mnzu1ejDzjks0mNgdXYLbGmA5wva6+iAv+\n\tvAlI9EK2JlbC+viL","X-Google-Smtp-Source":"ADKCNb5tNImDkQ5KsfDJLIDzD+KsjYZexwNJlv5qr+dlqMtNcrAgPia7CRY/1oIS8l5244kKZmmZcQ==","X-Received":"by 10.223.187.80 with SMTP id x16mr17295270wrg.33.1505378826997; \n\tThu, 14 Sep 2017 01:47:06 -0700 (PDT)","References":"<1504198860-12951-1-git-send-email-Dave.Martin@arm.com>\n\t<1504198860-12951-13-git-send-email-Dave.Martin@arm.com>","User-agent":"mu4e 0.9.19; emacs 25.2.50.3","From":"Alex =?utf-8?q?Benn=C3=A9e?= <alex.bennee@linaro.org>","To":"Dave Martin <Dave.Martin@arm.com>","Cc":"linux-arm-kernel@lists.infradead.org,\n\tCatalin Marinas <catalin.marinas@arm.com>,\n\tWill Deacon <will.deacon@arm.com>,\n\tArd Biesheuvel <ard.biesheuvel@linaro.org>,\n\tSzabolcs Nagy <szabolcs.nagy@arm.com>,\n\tRichard Sandiford <richard.sandiford@arm.com>,\n\tkvmarm@lists.cs.columbia.edu, libc-alpha@sourceware.org,\n\tlinux-arch@vger.kernel.org","Subject":"Re: [PATCH v2 12/28] arm64/sve: Support vector length resetting for\n\tnew processes","In-reply-to":"<1504198860-12951-13-git-send-email-Dave.Martin@arm.com>","Date":"Thu, 14 Sep 2017 09:47:05 +0100","Message-ID":"<87k211acqe.fsf@linaro.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"8bit"}}]