From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751479AbbHQWX1 (ORCPT ); Mon, 17 Aug 2015 18:23:27 -0400 Received: from mga03.intel.com ([134.134.136.65]:45141 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750875AbbHQWXT (ORCPT ); Mon, 17 Aug 2015 18:23:19 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,697,1432623600"; d="scan'208";a="785605818" Message-ID: <1439850198.11296.5.camel@linux.intel.com> Subject: Re: [PATCH v3 5/7] pmem: add copy_from_iter_pmem() and clear_pmem() From: Ross Zwisler To: Christoph Hellwig , Al Viro Cc: linux-kernel@vger.kernel.org, linux-nvdimm@ml01.01.org, Dan Williams , Matthew Wilcox , Dave Chinner , "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , x86@kernel.org Date: Mon, 17 Aug 2015 16:23:18 -0600 In-Reply-To: <20150817191016.GC6752@lst.de> References: <1439836211-4719-1-git-send-email-ross.zwisler@linux.intel.com> <1439836211-4719-6-git-send-email-ross.zwisler@linux.intel.com> <20150817191016.GC6752@lst.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.11 (3.12.11-1.fc21) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2015-08-17 at 21:10 +0200, Christoph Hellwig wrote: > > #include > > +#include > > + > > Can we keep this in linux/pmem.h? I'm pretty sure the stubs would need > it as well, and even if they don't it'll keep the includes consistent. Sure. > > +{ > > + size_t len; > > + > > + len = copy_from_iter_nocache((void __force *)addr, bytes, i); > > + > > + /* > > + * copy_from_iter_nocache() on x86 only uses non-temporal stores for > > + * iovec iterators, so for other types (bvec & kvec) we must do a > > + * cache write-back. > > Shouldn't we fi that? I'm not sure - When Al make copy_from_iter_nocache() it was just a copy of copy_from_iter(), with the iovec case changed to use __copy_from_user_nocache(). The other cases use memcpy_from_page() and memcpy(). To have everything do non-temporal stores we'd probably need to make non-temporal versions of each of those (alluded to by Al's comment in the copy_from_iter_nocache() commit: "BTW, do we want memcpy_nocache()?"). > > + */ > > + if (iter_is_iovec(i) == false) > > + __arch_wb_cache_pmem(addr, bytes); > > And if not and iter_needs_pmem_wb helper to encode this knowledge would > be useful. Maybe this should be the short-term solution, and I'll add a TODO to fix the copy_from_iter_nocache() implementation as described above so we can always have non-temporal stores? > > +static inline void arch_clear_pmem(void __pmem *addr, size_t size) > > +{ > > + /* TODO: implement the zeroing via non-temporal writes */ > > + if (size == PAGE_SIZE && ((unsigned long)addr & ~PAGE_MASK) == 0) > > + clear_page((void __force *)addr); > > + else > > + memset((void __force *)addr, 0, size); > > + > > + __arch_wb_cache_pmem(addr, size); > > Please add a local vaiable so that the __force casting is only needed > once. Same for other functions with this pattern. Sure.