From patchwork Thu Jan 22 15:44:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 43523 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0AF04240DB for ; Thu, 22 Jan 2015 15:45:19 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e49sf2087672eek.3 for ; Thu, 22 Jan 2015 07:45:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=8I9rYWs+yNtOqoVkAdnETWAyIg3UJP00Mw5aFXKSEUg=; b=TE//3Mj39TCa0PECdibUuANUm6U+n39SJe4om9wepp+mojH88hb9/f94MXDP4BtjoW 51057xaAb3sMexFkYSzwJqVbvq+G/9Dd7HVHa9Ozsonq3pp+RyUPzkLoGVz+/7OwWndr izoucpzFPwcOJT3IkGp/pKSxKf3GlaQnMowBQhUSYXqozeDU+yN1in/Kq2dU6SdIx8ms DZNvK3S4nv5nyNUvtKwK4MIrt+obd3X/9PGy1ePRb/mGGKuErqJOydhJvV+nU3Yyowx9 u8vngss2qemT+pDAlJeopZIq1hitzZFjH01Qft3E8572sCUcFZEHWU3nrSAdIgVLOiCO NKWA== X-Gm-Message-State: ALoCoQnWNGn7x/pTcbb6i1PcFhu31zxINxOwudN2mSdy6Fy0WppXLJkPlAL5dx5cPb8XiQylIdRj X-Received: by 10.112.9.199 with SMTP id c7mr341692lbb.7.1421941518214; Thu, 22 Jan 2015 07:45:18 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.6.34 with SMTP id cr2ls183685lad.30.gmail; Thu, 22 Jan 2015 07:45:18 -0800 (PST) X-Received: by 10.112.156.132 with SMTP id we4mr2335726lbb.59.1421941518038; Thu, 22 Jan 2015 07:45:18 -0800 (PST) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id v4si22411859lav.88.2015.01.22.07.45.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jan 2015 07:45:17 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by mail-lb0-f174.google.com with SMTP id f15so2248256lbj.5 for ; Thu, 22 Jan 2015 07:45:17 -0800 (PST) X-Received: by 10.112.84.225 with SMTP id c1mr2444180lbz.22.1421941517593; Thu, 22 Jan 2015 07:45:17 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp304008lbb; Thu, 22 Jan 2015 07:45:16 -0800 (PST) X-Received: by 10.229.27.73 with SMTP id h9mr3782756qcc.3.1421941516156; Thu, 22 Jan 2015 07:45:16 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id e37si4926237qgd.75.2015.01.22.07.45.14 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 22 Jan 2015 07:45:16 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YEJwW-0007eX-DL; Thu, 22 Jan 2015 15:45:12 +0000 Received: from mail-lb0-f173.google.com ([209.85.217.173]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YEJwK-0007ch-Sk for lng-odp@lists.linaro.org; Thu, 22 Jan 2015 15:45:01 +0000 Received: by mail-lb0-f173.google.com with SMTP id p9so2252183lbv.4 for ; Thu, 22 Jan 2015 07:44:55 -0800 (PST) X-Received: by 10.112.57.226 with SMTP id l2mr2381091lbq.27.1421941495086; Thu, 22 Jan 2015 07:44:55 -0800 (PST) Received: from localhost.localdomain (broadband-46-188-125-104.2com.net. [46.188.125.104]) by mx.google.com with ESMTPSA id is5sm6405308lac.41.2015.01.22.07.44.53 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 Jan 2015 07:44:54 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 22 Jan 2015 18:44:45 +0300 Message-Id: <1421941485-13742-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1421941485-13742-1-git-send-email-maxim.uvarov@linaro.org> References: <1421941485-13742-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv2 3/3] hugepages: align mmap size for hugepages X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 In case of hugepages munmap requires size aligned to page. Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_shared_memory.c | 12 ++++++++++-- test/validation/odp_shm.c | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index 23a9ceb..7adbe52 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -179,12 +179,20 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, int map_flag = MAP_SHARED; /* If already exists: O_EXCL: error, O_TRUNC: truncate to zero */ int oflag = O_RDWR | O_CREAT | O_TRUNC; - uint64_t alloc_size = size + align; + uint64_t alloc_size; uint64_t page_sz, huge_sz; - huge_sz = odp_sys_huge_page_size(); page_sz = odp_sys_page_size(); +#ifdef MAP_HUGETLB + huge_sz = odp_sys_huge_page_size(); + /* munmap for huge pages requires sizes round up by page */ + alloc_size = (size + align + (huge_sz - 1)) + & (-huge_sz); +#else + alloc_size = size + align; +#endif + if (flags & ODP_SHM_PROC) { /* Creates a file to /dev/shm */ fd = shm_open(name, oflag, diff --git a/test/validation/odp_shm.c b/test/validation/odp_shm.c index c26925b..918a77b 100644 --- a/test/validation/odp_shm.c +++ b/test/validation/odp_shm.c @@ -32,7 +32,11 @@ static void *run_shm_thread(void *arg) CU_ASSERT(0 == info.flags); CU_ASSERT(test_shared_data == info.addr); CU_ASSERT(sizeof(test_shared_data_t) <= info.size); +#ifdef MAP_HUGETLB CU_ASSERT(odp_sys_page_size() == info.page_size); +#else + CU_ASSERT(odp_sys_huge_page_size() == info.page_size); +#endif odp_shm_print_all(); fflush(stdout);