From patchwork Thu Jan 22 15:00:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 43520 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 77C6C240DB for ; Thu, 22 Jan 2015 15:01:20 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id l61sf1340588wev.0 for ; Thu, 22 Jan 2015 07:01:19 -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: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=sDd4VHiudn+IvdS43RtjwE2aJQ1AePffpfEyKtwKkkI=; b=QBopBWaLuVwk9o/mGwE4/pLvbb3R/WvXVHlkHi8ZfuPRpll5NuNo7IkXkDsZGtH9jz 3fFPzhVUzSYP2Kmccs1c6lzv44QSnL3RRCXoFFae+a6e5CVZYEakiXGONRrSiknfcE1j ZwE/2ArxILeFc8NqoC0jXqWchtNNq56vbsHJ+CTWYpe2mknsxgHIOD5NwuRQDSF6rsJz 8aODSXjVtrZHXXvamY1CDb78ojcFeqEK139vd7tJkeMae+MQeAqeDEpMgIuhznIlLp2+ EtykzmvKYCXSfzoYQhaODKSY3/l+TyWQ9LLgnXKeBgadpZoUphBVhDi0YcIDVI3F+x4p vyzg== X-Gm-Message-State: ALoCoQlISjT2TAVlJkIYozbBWpDxv0VGBq1FNmyXacJ6vPBGsJpOHYoIbEhhUoubj3Xx8TU8sOor X-Received: by 10.112.9.199 with SMTP id c7mr307470lbb.7.1421938879389; Thu, 22 Jan 2015 07:01:19 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.38 with SMTP id ld6ls180060lac.50.gmail; Thu, 22 Jan 2015 07:01:19 -0800 (PST) X-Received: by 10.112.159.195 with SMTP id xe3mr2108447lbb.64.1421938879248; Thu, 22 Jan 2015 07:01:19 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id m3si20943867lbc.51.2015.01.22.07.01.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jan 2015 07:01:19 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id pn19so2064145lab.9 for ; Thu, 22 Jan 2015 07:01:19 -0800 (PST) X-Received: by 10.112.26.135 with SMTP id l7mr2085885lbg.56.1421938879163; Thu, 22 Jan 2015 07:01:19 -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 c8csp289982lbb; Thu, 22 Jan 2015 07:01:17 -0800 (PST) X-Received: by 10.224.165.77 with SMTP id h13mr3373922qay.14.1421938877271; Thu, 22 Jan 2015 07:01:17 -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 w7si9047127qal.128.2015.01.22.07.01.15 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 22 Jan 2015 07:01:17 -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 1YEJFx-0005Sl-P7; Thu, 22 Jan 2015 15:01:13 +0000 Received: from mail-la0-f53.google.com ([209.85.215.53]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YEJFr-0005SY-Ly for lng-odp@lists.linaro.org; Thu, 22 Jan 2015 15:01:07 +0000 Received: by mail-la0-f53.google.com with SMTP id gq15so2050580lab.12 for ; Thu, 22 Jan 2015 07:01:01 -0800 (PST) X-Received: by 10.112.134.74 with SMTP id pi10mr2070716lbb.67.1421938861433; Thu, 22 Jan 2015 07:01:01 -0800 (PST) Received: from localhost.localdomain (broadband-46-188-125-104.2com.net. [46.188.125.104]) by mx.google.com with ESMTPSA id ao2sm6390497lac.8.2015.01.22.07.01.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 Jan 2015 07:01:00 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 22 Jan 2015 18:00:55 +0300 Message-Id: <1421938855-6814-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 X-Topics: patch Subject: [lng-odp] [PATCH] linux-generic: shm fix unmap 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.215.50 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 unmap has to be done with address aligned to page size. Also unmap() has to be done for address returned by mmap(), not for aligned address after that. To reproduce original bug run: echo 4096 > /proc/sys/vm/nr_hugepages make check Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_shared_memory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index 99c5b40..51eba02 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -134,8 +134,14 @@ int odp_shm_free(odp_shm_t shm) odp_spinlock_lock(&odp_shm_tbl->lock); shm_block = &odp_shm_tbl->block[i]; +#ifdef MAP_HUGETLB + /* round up alloc size by page */ + alloc_size = (shm_block->size + (shm_block->page_sz - 1)) + & (-shm_block->page_sz); +#else alloc_size = shm_block->size + shm_block->align; - ret = munmap(shm_block->addr, alloc_size); +#endif + ret = munmap(shm_block->addr_orig, alloc_size); if (0 != ret) { ODP_DBG("odp_shm_free: munmap failed\n"); odp_spinlock_unlock(&odp_shm_tbl->lock);