From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-x22c.google.com (mail-io0-x22c.google.com [IPv6:2607:f8b0:4001:c06::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C8E9C2007E7E2 for ; Tue, 1 May 2018 21:14:53 -0700 (PDT) Received: by mail-io0-x22c.google.com with SMTP id e12-v6so15930491iob.8 for ; Tue, 01 May 2018 21:14:53 -0700 (PDT) MIME-Version: 1.0 References: <152520750404.36522.15462513519590065300.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: From: Linus Torvalds Date: Wed, 02 May 2018 04:14:41 +0000 Message-ID: Subject: Re: [PATCH 0/6] use memcpy_mcsafe() for copy_to_iter() List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Dan Williams Cc: Tony Luck , "linux-nvdimm@lists.01.org" , Peter Zijlstra , the arch/x86 maintainers , Linux Kernel Mailing List , Andy Lutomirski , Ingo Molnar , Borislav Petkov , Al Viro , Thomas Gleixner , Andrew Morton List-ID: On Tue, May 1, 2018 at 9:00 PM Dan Williams wrote: > > > > I have some dim memory of "rep movs doesn't work well for pmem", but does > > it *seriously* need unrolling to cacheline boundaries? And if it does, who > > designed it, and why is anybody using it? > > > I think this is an FAQ from the original submission, in fact some guy > named "Linus Torvalds" asked [1]: Oh, I already mentioned that I remembered that "rep movs" didn't work well. But there's a big gap between "just use 'rep movs' and 'do some cacheline unrollong'". Why isn't it just doing a simple word-at-a-time loop and letting the CPU do the unrolling that it will already do on its own? I may have gotten that answered too, but there's no comment in the code about why it's such a disgusting mess, so I've long since forgotten _why_ it's such a disgusting mess. That loop unrolling _used_ to be "hey, it's simple". Now it's "Hey, that's truly disgusting", with the separate fault handling for every single case in the unrolled loop. Just look at the nasty _ASM_EXTABLE_FAULT() uses and those E_cache_x error labels, and getting the number rof bytes copied right. And then ask yourself "what if we didn't unroll that thing 8 times, AND WE COULD GET RID OF ALL OF THOSE?" Maybe you already did ask yourself. But I'm asking because it sure isn't explained in the code. Linus _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751029AbeEBEOy (ORCPT ); Wed, 2 May 2018 00:14:54 -0400 Received: from mail-io0-f169.google.com ([209.85.223.169]:39586 "EHLO mail-io0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750878AbeEBEOx (ORCPT ); Wed, 2 May 2018 00:14:53 -0400 X-Google-Smtp-Source: AB8JxZqlYKync3k7gAfrbNlbOVzPRkIxhhEuA6hQjoX/Z0VpwoKhFSNYp2Gw8KD2gvvZhMyonfRlqEBbtj7Ccg6MgK0= MIME-Version: 1.0 References: <152520750404.36522.15462513519590065300.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: From: Linus Torvalds Date: Wed, 02 May 2018 04:14:41 +0000 Message-ID: Subject: Re: [PATCH 0/6] use memcpy_mcsafe() for copy_to_iter() To: Dan Williams Cc: "linux-nvdimm@lists.01.org" , Tony Luck , Peter Zijlstra , Borislav Petkov , "the arch/x86 maintainers" , Thomas Gleixner , Andy Lutomirski , Ingo Molnar , Al Viro , Andrew Morton , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 1, 2018 at 9:00 PM Dan Williams wrote: > > > > I have some dim memory of "rep movs doesn't work well for pmem", but does > > it *seriously* need unrolling to cacheline boundaries? And if it does, who > > designed it, and why is anybody using it? > > > I think this is an FAQ from the original submission, in fact some guy > named "Linus Torvalds" asked [1]: Oh, I already mentioned that I remembered that "rep movs" didn't work well. But there's a big gap between "just use 'rep movs' and 'do some cacheline unrollong'". Why isn't it just doing a simple word-at-a-time loop and letting the CPU do the unrolling that it will already do on its own? I may have gotten that answered too, but there's no comment in the code about why it's such a disgusting mess, so I've long since forgotten _why_ it's such a disgusting mess. That loop unrolling _used_ to be "hey, it's simple". Now it's "Hey, that's truly disgusting", with the separate fault handling for every single case in the unrolled loop. Just look at the nasty _ASM_EXTABLE_FAULT() uses and those E_cache_x error labels, and getting the number rof bytes copied right. And then ask yourself "what if we didn't unroll that thing 8 times, AND WE COULD GET RID OF ALL OF THOSE?" Maybe you already did ask yourself. But I'm asking because it sure isn't explained in the code. Linus