Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3168521imu; Fri, 23 Nov 2018 23:11:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/W75ohQ887sxy6J9M7l6CkM0V+pzK8at3Sn1a67FC8IVAxRyQdfOQpunZRA78ziOGC16cm8 X-Received: by 2002:a17:902:8648:: with SMTP id y8-v6mr18955628plt.159.1543043479805; Fri, 23 Nov 2018 23:11:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543043479; cv=none; d=google.com; s=arc-20160816; b=lFdnm/z75aPvVSPCsxW/EXVZXTDL/V8xY4WToKeCBT1P+/blPM75C+yAaJN3uUri5o a0zz6DQyrs5IJ/p80VV+RstE1jw/0HJO+gzJigBa12ZPxkL2866BaQztH3O93/2wFaND RcjYcafTrRpQfPWe3iuFm4+ULM9bAZMou9v4Y8wwbeZB1TNTQWYR2SvoAvxeCH1/dhE3 dANo6VxCL0vHk6QYweSye1yjWlg0Pd5xEfvr21BG7bJ7Xl0j+3IvPCox0rWZebpUqMx4 6LKG4LVhucAT+wk0FzOh1oAi6mWUjl0hPtfv+nIcNMw1Q7TzSQ8ycMMNHMP4w8yE1v0R 1+Xw== 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; bh=eFmw88yuJi47nhCDVacP//v8Th04BYz97g3lcAzmOqk=; b=EGqshmlh12KBnYaqBXJl0C6JpYl1EFW1aqXGxaaWb+ANwZ9BZ/1Q821hXrQMmD6xzf YXMLsRGp/yynI45PPr6+R6/xe3kqBCFB9CuUjuoK7OvGbU0Iv2hZi0zyR4dOCDvQzFDp nKSaWVc88pUIRviTd2t8NtMkQJ1LebCGi0IWdEBa4gAGQYCxFNpD1vlNGo7HbQ5kKZXg p0dsgr5sQtc4YtSkzvAO8ljRPh5MdxlZ+pznh8VvwdnPNkxfG8xUL/F1Kn0XcoDSOkJ8 JvcPKNUzagbxyJ+yF8e8mSZ8ZGOyqKOUeeUpQMP41Do5aBJljgqH1ZnLOy6YE06Wvi2b bB+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vF25Zz6E; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si40306616plz.118.2018.11.23.23.11.05; Fri, 23 Nov 2018 23:11:19 -0800 (PST) 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=@kernel.org header.s=default header.b=vF25Zz6E; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438201AbeKWErl (ORCPT + 99 others); Thu, 22 Nov 2018 23:47:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:37628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730604AbeKWErl (ORCPT ); Thu, 22 Nov 2018 23:47:41 -0500 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5EBC6213A2 for ; Thu, 22 Nov 2018 18:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542910032; bh=NLEjE+Lb8hSmXXek1PLb2TbjWwn8mr/hUyikcOoFyD0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=vF25Zz6EGi9X0EuE0YKJERyiegnzoDzQwkqEnB3PTd2naTr+PRk5f1HxFYYXqp2Ad 7yoB13O2R/OervGwi1tDKIVCi19WSsz3W1GEzkDTpZfeuhULAyiiekcDIauGiqdFlC 9YSMS0VJ0TL32HhQ1AQXB3zvQPuMx2uk/ESkt5RQ= Received: by mail-wr1-f44.google.com with SMTP id v13so6610470wrw.5 for ; Thu, 22 Nov 2018 10:07:12 -0800 (PST) X-Gm-Message-State: AA+aEWZVoQ4kxTUlSn1TZ6ljd5OV1/jBGPcNk8crvg3DKGcvIPVM7ctO XV9GzF7HLCP5BW5dA0kTFtPyxL9WbhOP7Y9fKowlew== X-Received: by 2002:adf:90af:: with SMTP id i44-v6mr10168899wri.77.1542910030740; Thu, 22 Nov 2018 10:07:10 -0800 (PST) MIME-Version: 1.0 References: <02bfc577-32a5-66be-64bf-d476b7d447d2@kernel.dk> <20181121063609.GA109082@gmail.com> <48e27a3a-2bb2-ff41-3512-8aeb3fd59e57@kernel.dk> <26eff539-7de7-784c-0c88-f1d30753299d@redhat.com> <7ea44458b90b4d41a08ba9012818d273@AcuMS.aculab.com> In-Reply-To: From: Andy Lutomirski Date: Thu, 22 Nov 2018 10:06:58 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86: only use ERMS for user copies for larger sizes To: Linus Torvalds Cc: David Laight , Denys Vlasenko , Jens Axboe , Ingo Molnar , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , X86 ML , Andrew Morton , Andrew Lutomirski , Peter Zijlstra , Brian Gerst , LKML , pabeni@redhat.com 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 Thu, Nov 22, 2018 at 9:53 AM Linus Torvalds wrote: > > On Thu, Nov 22, 2018 at 9:36 AM David Laight wrote: > > > > The other problem with the ERMS copy is that it gets used > > for copy_to/from_io() - and the 'rep movsb' on uncached > > locations has to do byte copies. > > Ugh. I thought we changed that *long* ago, because even our non-ERMS > copy is broken for PCI (it does overlapping stores for the small tail > cases). > > But looking at "memcpy_{from,to}io()", I don't see x86 overriding it > with anything better. > > I suspect nobody uses those functions for anything critical any more. > The fbcon people have their own copy functions, iirc. > > But we definitely should fix this. *NONE* of the regular memcpy > functions actually work right for PCI space any more, and haven't for > a long time. I'm not personally volunteering, but I suspect we can do much better than we do now: - The new MOVDIRI and MOVDIR64B instructions can do big writes to WC and UC memory. I assume those would be safe to use in ...toio() functions, unless there are quirky devices out there that blow up if their MMIO space is written in 64-byte chunks. - MOVNTDQA can, I think, do 64-byte loads, but only from WC memory. For sufficiently large copies, it could plausibly be faster to create a WC alias and use MOVNTDQA than it is to copy in 8- for 16-byte chunks. The i915 driver has a copy implementation using MOVNTDQA -- maybe this should get promoted to something in arch/x86 called memcpy_from_wc(). --Andy