From patchwork Tue Feb 23 06:59:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yigal Korman X-Patchwork-Id: 8387871 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B884BC0553 for ; Tue, 23 Feb 2016 06:59:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C78DA20678 for ; Tue, 23 Feb 2016 06:59:44 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id CACF320676 for ; Tue, 23 Feb 2016 06:59:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 327EB1A1FF7; Mon, 22 Feb 2016 22:59:46 -0800 (PST) X-Original-To: linux-nvdimm@ml01.01.org Delivered-To: linux-nvdimm@ml01.01.org Received: from mail-wm0-x22c.google.com (mail-wm0-x22c.google.com [IPv6:2a00:1450:400c:c09::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 61E661A1FF7 for ; Mon, 22 Feb 2016 22:59:45 -0800 (PST) Received: by mail-wm0-x22c.google.com with SMTP id b205so186021340wmb.1 for ; Mon, 22 Feb 2016 22:59:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plexistor-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=2v+IIAjj+mO0Z+0LQ0HEPC9dL73yWPBkWHpcdS7LpLU=; b=roQVhJFp5TQTWXZDndRnspQloGvl8wVjvnkAJ/txORC1ASRhzRrlAW7HhouYfdi1g+ YlOOjPheA6JJKHoOjOIPSpdo3jx9RYVdSNemfIAiJ3QFgHPTlbhjm+aVy7F+433W2FYF RsmaJ+WaXRPcOHRQvpMx6dllXeKsydEO4ztGq+dfQ0ExW/RKdKrEy6tTnHGNjV17ELZu pgBioRZYlifF3c5rNuOpuxwvTy0iqiwhOn2f4/lfuOs28aJCRaS58VbQjB4fIdfPXERJ opV3D7uiApo9WZde+XLI6e1OUEF82Ufhy4Qdly7dgEMtxj0CcdBS8FJCRBc+DYEOsRCi LgXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=2v+IIAjj+mO0Z+0LQ0HEPC9dL73yWPBkWHpcdS7LpLU=; b=T6FOCqJSTlw26liNEWn5N9QXLDkMmVcAph8Qx0l/L0BdZecFbUDcO3catOShAHtFKR mpkjHcwy7J6dTguyWf+T7j+g9bX88dnKn2oeNmhOgJuDNlDnX431u/LOoWIja1iIZeva JhzgQLNrzo7TAjt5feuzeUUFpwAEekoJ9Q73b3nXHlpqwtlce/WMrSDRefBfrAjRn7UC sPcvzZubM6WUDlHEiyCKZi89cop13+ZO0lrYI2bnH2cALRpq7saHyEVEjLK2DePnUbUr 1AuUTSbO8T2CQZs8AJuHHZ5a94imAJA1Mrt8ot+7ILCPZVkrJVrntpyZkbsoTQv3ju70 H2Ww== X-Gm-Message-State: AG10YOSN/5Qz2GG8B/aI5LsxSg2Rki+iZOxNmn3LYIgq+BqPSKrpVOUjxsvyvkSI8oR1tAROAkCSjHn0AC6CCA== X-Received: by 10.28.222.68 with SMTP id v65mr17286733wmg.66.1456210781122; Mon, 22 Feb 2016 22:59:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.27.56.204 with HTTP; Mon, 22 Feb 2016 22:59:21 -0800 (PST) In-Reply-To: <20160222183924.GA24538@linux.intel.com> References: <56C9EDCF.8010007@plexistor.com> <56C9EF45.4040205@plexistor.com> <20160222183924.GA24538@linux.intel.com> From: Yigal Korman Date: Tue, 23 Feb 2016 08:59:21 +0200 Message-ID: Subject: Re: [RFC 1/1] util: add pmem-aware flag to mmap() To: Ross Zwisler Cc: Dave Chinner , Arnd Bergmann , linux-nvdimm X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Feb 22, 2016 at 8:39 PM, Ross Zwisler wrote: > On Sun, Feb 21, 2016 at 07:09:25PM +0200, Boaz Harrosh wrote: >> From: Yigal Korman >> >> Tell the kernel that the library is responsible for the persistence of >> its writes and there's no need to flush/drain the pmem. >> >> TODO: use #ifdef to check if the pmem-aware flag exists >> >> Signed-off-by: Yigal Korman >> --- >> src/common/util.c | 9 +++++++-- >> 1 file changed, 7 insertions(+), 2 deletions(-) >> >> diff --git a/src/common/util.c b/src/common/util.c >> index 17b3305..0f6feaa 100644 >> --- a/src/common/util.c >> +++ b/src/common/util.c >> @@ -312,9 +312,14 @@ util_map(int fd, size_t len, int cow, size_t req_align) >> >> void *base; >> void *addr = util_map_hint(len, req_align); >> + int flags = MAP_PMEM_AWARE; >> >> - if ((base = mmap(addr, len, PROT_READ|PROT_WRITE, >> - (cow) ? MAP_PRIVATE|MAP_NORESERVE : MAP_SHARED, >> + if (cow) >> + flags |= MAP_SHARED; >> + else >> + flags |= MAP_PRIVATE | MAP_NORESERVE; > > You've got the flags backwards from how the old code worked. > > Old: > cow = MAP_PRIVATE|MAP_NORESERVE > nocow = MAP_SHARED > > New: > cow = MAP_SHARED > nocow = MAP_PRIVATE|MAP_NORESERVE > Ouch... yep, sorry about that, this is my mistake. I didn't intend to switch the meaning. fixed version: >> + >> + if ((base = mmap(addr, len, PROT_READ|PROT_WRITE, flags, >> fd, 0)) == MAP_FAILED) { >> ERR("!mmap %zu bytes", len); >> return NULL; >> -- >> 1.9.3 >> > _______________________________________________ > Linux-nvdimm mailing list > Linux-nvdimm@lists.01.org > https://lists.01.org/mailman/listinfo/linux-nvdimm --- a/src/common/util.c +++ b/src/common/util.c @@ -312,9 +312,14 @@ util_map(int fd, size_t len, int cow, size_t req_align) void *base; void *addr = util_map_hint(len, req_align); + int flags = MAP_PMEM_AWARE; - if ((base = mmap(addr, len, PROT_READ|PROT_WRITE, - (cow) ? MAP_PRIVATE|MAP_NORESERVE : MAP_SHARED, + if (cow) + flags |= MAP_PRIVATE | MAP_NORESERVE; + else + flags |= MAP_SHARED; + + if ((base = mmap(addr, len, PROT_READ|PROT_WRITE, flags, fd, 0)) == MAP_FAILED) { ERR("!mmap %zu bytes", len); return NULL;