[{"id":1768425,"web_url":"http://patchwork.ozlabs.org/comment/1768425/","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":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"j5BTOtJA\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"UzX/PFSB\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\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 3xtBxQ5d3cz9t1t\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 18:47:38 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dsPo6-0000OC-TX; Thu, 14 Sep 2017 08:47:34 +0000","from mail-wr0-x230.google.com ([2a00:1450:400c:c0c::230])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dsPo1-0000Ge-Rg for linux-arm-kernel@lists.infradead.org;\n\tThu, 14 Sep 2017 08:47:32 +0000","by mail-wr0-x230.google.com with SMTP id a43so4895064wrc.0\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tThu, 14 Sep 2017 01:47:08 -0700 (PDT)","from zen.linaro.local ([81.128.185.34])\n\tby smtp.gmail.com with ESMTPSA id\n\tc126sm1240689wmh.38.2017.09.14.01.47.05\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tThu, 14 Sep 2017 01:47:06 -0700 (PDT)","from zen (localhost [127.0.0.1])\n\tby zen.linaro.local (Postfix) with ESMTPS id 75F703E0132;\n\tThu, 14 Sep 2017 09:47:05 +0100 (BST)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:\n\tIn-reply-to:Subject:To:From:References:Reply-To:Content-ID:\n\tContent-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n\t:Resent-Message-ID:List-Owner;\n\tbh=gDLVkaU71lHk60+KST2Al6TW1bu2gAyg36Sojl4tX0o=;\n\tb=j5BTOtJArumjF4+aHmpJ03cm3T\n\tPJDcPmOMMvRtojHgrumDM6WysUsvT0ylYd6XJS1MsfXR1gBYfK3OGjKdhiH3rCJszzLFruC0o1aT+\n\tL/r/E51CasqHrAHdKKrs7Q8cQ0HmClzUOpLCZgfG7/EiTwPWmQ11vvHIskaf1tA7K02E+Qvpz5XR4\n\tc6FHYPntQtuwECPN4GH4oBYW23iE0+MVMRsz4nAk8v6y5J/SWfHwKmKktoIrrzANm/N1jaHLUsaoT\n\t4ZKXQtH949hV2zP/WNcxCyEooDhw5r8vftAdbLIFbi3TV3EVxaYiCv4Y8yvRL6tlHwRdQ0qGVfbU7\n\tEX9+vwBQ==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=references:user-agent:from:to:cc:subject:in-reply-to:date\n\t:message-id:mime-version:content-transfer-encoding;\n\tbh=K1qBokwOv8PEMIMbp4Uu9EDPFp+Oj6h+y2N2wJEERVE=;\n\tb=UzX/PFSBbi4p4f+ca8cnE1RoCx3ztjx7YeB17LJ+8qv2gJ+lo8YQfLKhPsFNtoT5TQ\n\tdM1U6tjnWCJcG4DcR00/upfRpyxukW7XPxcSSz6uQVchUNRc1+KSBPRimwBNZSAJInuO\n\tcMhlCw6ZhVTHUcze2MsBsyz+J6MPbhUpu7u9o="],"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=ZkfRM+sStjlc0YN009W3qtLjYWe0Fut+Zzuz9xkHj7D4W7KqTwgo2hqfffS9sExMDI\n\taPAeEo8wS4BsNzQMtBtyDDEhx5ENuDfxic2qzR+NYLPZBi3tADNCFsOAwtrHhSN/vsAT\n\tAkjFCT5QLgt8trYJXIjm09LoSNbsGTC8v7VTCbAIcCzEEk4RjnRpeYnzS2sSSyEigLBG\n\tZTiW2P49bi4YH1JPtP7sGYlMn+BPhj9c24CCtr6tJRZ0/rKsoYk/jVYjPCQanzuFTJ/5\n\t5cCO8YHYo3n5S8tIWV649h3FyQrd8xz4M007A/lICKUrW1ePF+aLnBKAiOggYVMepkbU\n\tFfhg==","X-Gm-Message-State":"AHPjjUiYMzxLBgF+qnLXiVUhi9IdgdGpZQ2DzGSl6G6zQ54cVoG05Pph\n\tMlnD4d+v9xaGaNxU","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>","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","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170914_014730_101162_C5AE02A6 ","X-CRM114-Status":"GOOD (  22.00  )","X-Spam-Score":"-2.0 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.0 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,\n\tno\n\ttrust [2a00:1450:400c:c0c:0:0:0:230 listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"linux-arch@vger.kernel.org, libc-alpha@sourceware.org,\n\tArd Biesheuvel <ard.biesheuvel@linaro.org>,\n\tSzabolcs Nagy <szabolcs.nagy@arm.com>,\n\tCatalin Marinas <catalin.marinas@arm.com>,\n\tWill Deacon <will.deacon@arm.com>, \n\tRichard Sandiford <richard.sandiford@arm.com>,\n\tkvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}}]