Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2589140imm; Sun, 5 Aug 2018 07:37:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcDpXYPqoehA4EUIB+LtYn8FmlqNO/Najbq2KVlGSMbCLSVBrFsZ3EVNtzXhMusFD8twjEX X-Received: by 2002:a62:4cd3:: with SMTP id e80-v6mr12940946pfj.234.1533479829849; Sun, 05 Aug 2018 07:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533479829; cv=none; d=google.com; s=arc-20160816; b=SP63El4R7EzBHNa0H1bd3SbxX5aH3hJbEdeirgfN4l/Yj6asZzZtTFFKKRm6U9kROQ iagzO/R1lj0YGeSfLGreWGM/QCqEq1dxY+jj3QWtiKq8/dNK+ldsYf/h7jJCLMoVeAbq m2K+lvEN6bin8lhxejeCesDmGZxkqknWnfKjVdFhVTn5UYg3hY39w0MMLhe/IlhNWkOE lw3Ka0MQTPHxN+E24DuO3b9gfdyl9GGkaZBxiSfXDlHyapmjF2fsjO9HvQtyySsa3vLX 6E4Uhd/CZb7HsudrKr/NbsPJIWd+L2lzt6CZtG0tg6v0MAKpcLXD2JcKXwoSYxaa4Tgo ufcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=/A/YKKk3ZYhlsRC9vtYCkj0r7ZEl3SZp8R9/w3ZrXt8=; b=Uf5Jl4saNl4V2PwriMICmkm+D8XNJzXVrGQfhIZl7e4dw6JrnfWWiyGnxZeFkiPalm fz4ijABQnH8ZVHWL6mWeJLdoEodazP4BevbKk/Zv3OTp7hv+DPUs7XeMGU6an6pkO+ZJ 2YTvBUrqka2EnkEUdJgG4AR0ZFdBn7A7gVznW67Tsf5S+ay4ZAoc1vZjeFnNh1ugduTq Xj28rSNYdC5rbGmopFVy21cN/mBty1ZfBTlJY70pu8yy5wT/z9vd50/1UlmAj8rNeQ/5 gBTwpWd1OBqsKG+7YtyB+4DmEiOHO70A6Q49P+uWZ3Wv6CFV/xBLEWK/Xi8YY3CT37l5 H96A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3-v6si8149479pld.281.2018.08.05.07.36.54; Sun, 05 Aug 2018 07:37:09 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726267AbeHEQky (ORCPT + 99 others); Sun, 5 Aug 2018 12:40:54 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51940 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726191AbeHEQky (ORCPT ); Sun, 5 Aug 2018 12:40:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B0754021700; Sun, 5 Aug 2018 14:36:05 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A875D7C5F; Sun, 5 Aug 2018 14:36:04 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id w75Ea4Jw025496; Sun, 5 Aug 2018 10:36:04 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w75Ea10C025475; Sun, 5 Aug 2018 10:36:02 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Sun, 5 Aug 2018 10:36:01 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: David Laight cc: "'Ard Biesheuvel'" , Ramana Radhakrishnan , Florian Weimer , Thomas Petazzoni , GNU C Library , Andrew Pinski , Catalin Marinas , Will Deacon , Russell King , LKML , linux-arm-kernel Subject: RE: framebuffer corruption due to overlapping stp instructions on arm64 In-Reply-To: Message-ID: References: <9acdacdb-3bd5-b71a-3003-e48132ee1371@redhat.com> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Sun, 05 Aug 2018 14:36:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Sun, 05 Aug 2018 14:36:05 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mpatocka@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 3 Aug 2018, David Laight wrote: > From: Mikulas Patocka > > Sent: 03 August 2018 13:05 > ... > > > Even on x86 using memcpy() on PCIe memory (maybe mmap()ed into userspace) > > > isn't a good idea. > > > In the kernel memcpy_to/fromio() ought to be a better choice but that > > > is just an alternate name for memcpy(). > > > > > > The problem on x86 is that memcpy() is likely to be implemented as > > > 'rep movsb' on modern cpu - relying on the cpu hardware to perform > > > cache-line sized transfers (etc). > > > Unfortunately on uncached locations it has to revert to byte copies. > > > So PCIe transfers (especially reads) are very slow. > > > > > > The transfers need to use the largest size register available. > > > > > > David > > > > On x86, the framebuffer is mapped as write-combining memory type, so "rep > > movsb" could merge the byte writes to larger chunks. I don't have a cpu > > with the ERMS feature - could anyone try it if rep movsb works worse or > > better than explicit writes to the framebuffer? > > I don't think 'write combining' can help reads, and memcpy_to/fromio() There's an instruction movntdqa (and vmovntdqa) that can actually do prefetch on write-combining memory type. It's the only instruction that can do it. It this instruction is used on non-write-combining memory type, it behaves like movdqa. > are likely to be used for normal memory mapped io areas. > > David I benchmarked it on a processor with ERMS - for writes to the framebuffer, there's no difference between memcpy, 8-byte writes, rep stosb, rep stosq, mmx, sse, avx - all this method achieve 16-17 GB/s For reading from the framebuffer: 323 MB/s - memcpy (using avx2) 91 MB/s - explicit 8-byte reads 249 MB/s - rep movsq 307 MB/s - rep movsb 90 MB/s - mmx 176 MB/s - sse 4750 MB/s - sse movntdqa 330 MB/s - avx 5369 MB/s - avx vmovntdqa So - it may make sense to introduce a function memcpy_from_framebuffer() that uses movntdqa or vmovntdqa on CPUs that support it. Mikulas