From patchwork Thu Nov 9 14:40:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Plewa X-Patchwork-Id: 10051059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E5CB7603FF for ; Thu, 9 Nov 2017 14:46:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3C522ADC8 for ; Thu, 9 Nov 2017 14:46:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C86112ADD3; Thu, 9 Nov 2017 14:46:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, URIBL_BLACK autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 74CC82ADC8 for ; Thu, 9 Nov 2017 14:46:02 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DB46E20355215; Thu, 9 Nov 2017 06:41:59 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=lukasz.plewa@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1FF3A2034EE00 for ; Thu, 9 Nov 2017 06:41:58 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP; 09 Nov 2017 06:46:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,370,1505804400"; d="scan'208";a="5752714" Received: from gklab-124-122.igk.intel.com (HELO localhost) ([10.91.124.122]) by orsmga002.jf.intel.com with ESMTP; 09 Nov 2017 06:45:59 -0800 From: lukasz.plewa@intel.com To: linux-nvdimm@lists.01.org Subject: [PATCH] daxctl: remove libpmem dependency Date: Thu, 9 Nov 2017 15:40:53 +0100 Message-Id: <1510238453-7713-1-git-send-email-lukasz.plewa@intel.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?=C5=81ukasz=20Plewa?= Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Łukasz Plewa The next version of libpmem will depend on libndctl - as daxctl depends on libpmem, it will make building packages inconvenient. This patch replaces libpmem calls with intrinsic functions what allows to remove a libpmem dependency. Signed-off-by: Łukasz Plewa --- configure.ac | 15 +++++---------- daxctl/Makefile.am | 4 ---- daxctl/io.c | 23 +++++++++++++++++++---- ndctl.spec.in | 7 ------- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/configure.ac b/configure.ac index 5b10381..33a3e6e 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,7 @@ AC_PREFIX_DEFAULT([/usr]) AC_PROG_SED AC_PROG_MKDIR_P +AC_CANONICAL_HOST AC_ARG_ENABLE([docs], AS_HELP_STRING([--disable-docs], @@ -94,16 +95,10 @@ PKG_CHECK_MODULES([UDEV], [libudev]) PKG_CHECK_MODULES([UUID], [uuid]) PKG_CHECK_MODULES([JSON], [json-c]) -AC_ARG_WITH([libpmem], - AS_HELP_STRING([--with-libpmem], - [Install with libpmem support. @<:@default=no@:>@]), - [], - [with_libpmem=no]) -if test "x$with_libpmem" = "xyes"; then - PKG_CHECK_MODULES([PMEM], [libpmem]) - AC_DEFINE(ENABLE_DAXIO, 1, [Enable daxctl io]) -fi -AM_CONDITIONAL([ENABLE_DAXIO], [test "x$with_libpmem" = "xyes"]) +AS_IF([test "x$host_cpu" == "xx86_64"], + [AC_DEFINE([ENABLE_DAXIO], [1], enable daxctl io command)]) +AM_CONDITIONAL([ENABLE_DAXIO], [test "x$host_cpu" == "xx86_64"]) + AC_ARG_WITH([bash-completion-dir], AS_HELP_STRING([--with-bash-completion-dir[=PATH]], diff --git a/daxctl/Makefile.am b/daxctl/Makefile.am index 81d405e..8e3fd7e 100644 --- a/daxctl/Makefile.am +++ b/daxctl/Makefile.am @@ -17,7 +17,3 @@ daxctl_LDADD =\ ../libutil.a \ $(UUID_LIBS) \ $(JSON_LIBS) - -if ENABLE_DAXIO -daxctl_LDADD += $(PMEM_LIBS) -endif diff --git a/daxctl/io.c b/daxctl/io.c index 27e7463..a0f9613 100644 --- a/daxctl/io.c +++ b/daxctl/io.c @@ -20,9 +20,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -357,6 +357,20 @@ static int clear_badblocks(struct io_dev *dev, uint64_t len) return 0; } +#define FLUSH_ALIGN 64 + +static void clflush(const void *addr, size_t len) +{ + /* + * Loop through cache-line-size (typically 64B) aligned chunks + * covering the given range. + */ + for (uintptr_t uptr = (uintptr_t)addr & ~(FLUSH_ALIGN - 1); + uptr < (uintptr_t)addr + len; uptr += FLUSH_ALIGN) + _mm_clflush((char *)uptr); + _mm_sfence(); +} + static int64_t __do_io(struct io_dev *dst_dev, struct io_dev *src_dev, uint64_t len, bool zero) { @@ -366,12 +380,13 @@ static int64_t __do_io(struct io_dev *dst_dev, struct io_dev *src_dev, if (zero && dst_dev->is_dax) { dst = (uint8_t *)dst_dev->mmap + dst_dev->offset; memset(dst, 0, len); - pmem_persist(dst, len); + clflush(dst, len); rc = len; } else if (dst_dev->is_dax && src_dev->is_dax) { src = (uint8_t *)src_dev->mmap + src_dev->offset; dst = (uint8_t *)dst_dev->mmap + dst_dev->offset; - pmem_memcpy_persist(dst, src, len); + memcpy(dst, src, len); + clflush(dst, len); rc = len; } else if (src_dev->is_dax) { src = (uint8_t *)src_dev->mmap + src_dev->offset; @@ -422,7 +437,7 @@ static int64_t __do_io(struct io_dev *dst_dev, struct io_dev *src_dev, break; count += rc; } while (count != (ssize_t)len); - pmem_persist(dst, count); + clflush(dst, count); rc = count; if (rc != (ssize_t)len) printf("Requested size %lu larger than destination.\n", len); diff --git a/ndctl.spec.in b/ndctl.spec.in index 4aa133d..b481762 100644 --- a/ndctl.spec.in +++ b/ndctl.spec.in @@ -20,9 +20,6 @@ BuildRequires: pkgconfig(libudev) BuildRequires: pkgconfig(uuid) BuildRequires: pkgconfig(json-c) BuildRequires: pkgconfig(bash-completion) -%ifarch x86_64 -BuildRequires: pkgconfig(libpmem) -%endif %description Utility library for managing the "libnvdimm" subsystem. The "libnvdimm" @@ -93,11 +90,7 @@ control API for these devices. %build echo "VERSION" > version ./autogen.sh -%ifarch x86_64 -%configure --disable-static --enable-local --disable-silent-rules --with-libpmem -%else %configure --disable-static --enable-local --disable-silent-rules -%endif make %{?_smp_mflags} %install