Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4950151imm; Sun, 26 Aug 2018 07:20:59 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYN9Z04qFtMHKQaPXq88WDYQ06ux4/ixOXG8MbOG5un6DHO12NSea+RX3UeaoZkbqeQZ4FH X-Received: by 2002:a17:902:1001:: with SMTP id b1-v6mr9387496pla.155.1535293259346; Sun, 26 Aug 2018 07:20:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535293259; cv=none; d=google.com; s=arc-20160816; b=sQ306RmAQpQiAY2aMIJ4H/Y6hkoao7oBVYOZdCmG2gsj1wjtec3Owp4S2EJtQBlOeq 0Au4fenw73NfjsI61wXhBR/Zl1m1y7IpCpd/f6HcHX3hDkxfWgUP7NM5rvedaq9Q1HYd 1z9qLbWcoeNzgtYaRFqsqhEVRmws8hkIUVsqXSzWRD8woqSnGmC30fVqBd8a1VW5pqzM s8X+nAffu2t02e/b4+0YsvNHNNKhu2Luy4p2+2JmzuauNjrYem9IXr+IxEaEFzGRuvSR POe1TfJF8HrtO9SReCmdCFHuvGMfsASiBabQoLLtnPNoFUDN4y1ujELAVbv5+dhUT9jq q0KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=5sB4iSGbb7SO4LzrRMXqIilmS7C2SDyyB5RiZu5F2mc=; b=x9orkzk+NWPFjvZXkGdJezQv2dn8eViycHX/zXbp+qyd0XOnB3dbVSLrH+1z2piAx2 iaDRRUUzwQPi8ES4/FM6s8TDIc6wTnIwpR6t/AGjGH4tI+MwSINTgwLuoxcn9KjmBuup 1EmIoR8dcLqL7ePEOykCSgD1ptv6j+OuMa7h4g4owDdtdREJiABMcqJ8E0SgPGc54fcR Fuqt+EpyfTaVtk2w0J/6ieqGLUVJwDpPtTcS251Ph7xGxDwN4OQ5oc60T65MoyTvHcuk KQeYsfWFCvg4DsTHstCp4RLib6Tt6r0y+DalaeGJA2S9ceRfWYQOJL/5x3EjXyXPBcv6 urXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b="TrL2V/Lt"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7-v6si11185640pgp.411.2018.08.26.07.20.44; Sun, 26 Aug 2018 07:20:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b="TrL2V/Lt"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726911AbeHZSBL (ORCPT + 99 others); Sun, 26 Aug 2018 14:01:11 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:45681 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726685AbeHZSBL (ORCPT ); Sun, 26 Aug 2018 14:01:11 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 277309f0; Sun, 26 Aug 2018 14:03:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=5DWFA2ZhRLp6zw9sspG0okQGiBk=; b=TrL2V/ Ltov1YVbUcmNP2fnQzHyUs/mgtx5AFPqMzYZtn7Q+Xz7kRdMjCqAFlnNSmyHm0fX BZVvgG6aFI/ZDhvZK6tPqJI7tsWUh2rO2SCL2Vd2HSakF5ab5qwMyDsAo+u2qIEj /EXbV1Q8FBYNYA0OtLwwXY9T2w8/LH0hmXhBjegqhW4GBB2PgkFfdHddCGNARyNA YfE+w5PKQQyFrsU9bystH0Km2CHRCJq/8FyjLOVu6esLSQa3zqROozXekkH58ghk iWXLk9oOG2RKT8+vO0JoGwaluY+aUoikOHwXFNhAQ/BqYdaNGP/FOD48wIv4AjqP c24Q+K4po2EFE8Aw== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 114cadd1 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO); Sun, 26 Aug 2018 14:03:50 +0000 (UTC) Received: by mail-oi0-f45.google.com with SMTP id l202-v6so16091838oig.7; Sun, 26 Aug 2018 07:18:28 -0700 (PDT) X-Gm-Message-State: APzg51Bbk1l7dAF3sPbn6BiBN9vwzT7/YUitxtMIflEufYHbLWDQUBhJ SU4KjV3m+kInIEOE//7EOo4XU8n5Lzy/9ML+3zs= X-Received: by 2002:aca:e6d4:: with SMTP id d203-v6mr9295762oih.311.1535293107830; Sun, 26 Aug 2018 07:18:27 -0700 (PDT) MIME-Version: 1.0 References: <20180824213849.23647-1-Jason@zx2c4.com> <20180824213849.23647-2-Jason@zx2c4.com> In-Reply-To: From: "Jason A. Donenfeld" Date: Sun, 26 Aug 2018 08:18:15 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 01/17] asm: simd context helper API To: Thomas Gleixner Cc: LKML , Netdev , David Miller , Andrew Lutomirski , Greg Kroah-Hartman , Samuel Neves , linux-arch@vger.kernel.org, Rik van Riel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 26, 2018 at 8:06 AM Thomas Gleixner wrote: > > Do you mean to say you intend to make kernel_fpu_end() and > > kernel_neon_end() only actually do something upon context switch, but > > not when it's actually called? So that multiple calls to > > kernel_fpu_begin() and kernel_neon_begin() can be made without > > penalty? > > On context switch and exit to user. That allows to keep those code pathes > fully preemptible. Still twisting my brain around the details. Just to make sure we're on the same page, the goal is so that this code: kernel_fpu_begin(); kernel_fpu_end(); kernel_fpu_begin(); kernel_fpu_end(); kernel_fpu_begin(); kernel_fpu_end(); kernel_fpu_begin(); kernel_fpu_end(); kernel_fpu_begin(); kernel_fpu_end(); kernel_fpu_begin(); kernel_fpu_end(); ... has the same performance as this code: kernel_fpu_begin(); kernel_fpu_end(); (Unless of course the process is preempted or the like.) Currently the present situation makes the performance of the above wildly different, since kernel_fpu_end() does something immediately. What about something like this: - Add a tristate flag connected to task_struct (or in the global fpu struct in the case that this happens in irq and there isn't a valid current). - On kernel_fpu_begin(), if the flag is 0, do the usual expensive XSAVE stuff, and set the flag to 1. - On kernel_fpu_begin(), if the flag is non-0, just set the flag to 1 and return. - On kernel_fpu_end(), if the flag is non-0, set the flag to 2. (Otherwise WARN() or BUG() or something.) - On context switch / preemption / etc away from the task, if the flag is non-0, XRSTOR and such. - On context switch / preemption / etc back to the task, if the flag is 1, XSAVE and such. If the flag is 2, set it to 0. Jason