From patchwork Thu Feb 19 18:49:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44855 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E10FA21553 for ; Thu, 19 Feb 2015 18:50:46 +0000 (UTC) Received: by wesw55 with SMTP id w55sf1195566wes.0 for ; Thu, 19 Feb 2015 10:50:46 -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=iPrGDYWtqlAOYwZnwYieYdEREqA/b69N7Wzp+qMRO3Q=; b=kZkQAZYZ3NIEFB8rusFt916wdqC7wJ1f5E4xLQN/tlIBbVRb3gK8NIIbFJT5y1QP9B ZkpNhi8EITFlxbVFpX/ITCzUWJ3Vt4uVnPJtd9I1YnH3VY/C4P954esZ+iJyfDM8GQQV NRf407lIwHMZ+uHbpMc8ZHmm+btd3zPe5vGNhRH+OLZzDTaMZGALDUT/7KPOnFJZEiMH l7Z+T0V23YNhSgF5LzXv+XiLD1W8084mZl9Xr5+Fn6CJ0ojtbKbOkWd1bnRxKojCJRcX Qn/8OwM1QtGmNCw3gZ8VfayZg3P/JkQ5CF7aSmxSEHiYjBXPLCyBpMFNJViWu55w4Sb3 1V/A== X-Gm-Message-State: ALoCoQk2MZ2xvykXIdgc7NX0x56Nd006XDHWCC71MRaBYWydfvQrOla8JLFfh+k3393u988anOJR X-Received: by 10.180.13.98 with SMTP id g2mr1243963wic.3.1424371846213; Thu, 19 Feb 2015 10:50:46 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.165 with SMTP id uf5ls196659lac.60.gmail; Thu, 19 Feb 2015 10:50:46 -0800 (PST) X-Received: by 10.152.5.167 with SMTP id t7mr5515295lat.32.1424371846042; Thu, 19 Feb 2015 10:50:46 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id pu8si4230346lbb.51.2015.02.19.10.50.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Feb 2015 10:50:45 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by labge10 with SMTP id ge10so1406481lab.12 for ; Thu, 19 Feb 2015 10:50:45 -0800 (PST) X-Received: by 10.112.181.41 with SMTP id dt9mr5459297lbc.56.1424371845906; Thu, 19 Feb 2015 10:50:45 -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.35.133 with SMTP id h5csp681752lbj; Thu, 19 Feb 2015 10:50:44 -0800 (PST) X-Received: by 10.140.102.165 with SMTP id w34mr14941323qge.26.1424371844271; Thu, 19 Feb 2015 10:50:44 -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 r140si890251qha.39.2015.02.19.10.50.43 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 19 Feb 2015 10:50:44 -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 1YOWBN-0001in-J2; Thu, 19 Feb 2015 18:50:41 +0000 Received: from mail-ob0-f172.google.com ([209.85.214.172]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YOWB5-0001gp-Lb for lng-odp@lists.linaro.org; Thu, 19 Feb 2015 18:50:23 +0000 Received: by mail-ob0-f172.google.com with SMTP id nt9so18069204obb.3 for ; Thu, 19 Feb 2015 10:50:18 -0800 (PST) X-Received: by 10.182.85.225 with SMTP id k1mr4005007obz.20.1424371818433; Thu, 19 Feb 2015 10:50:18 -0800 (PST) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by mx.google.com with ESMTPSA id z184sm15375902oie.0.2015.02.19.10.50.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Feb 2015 10:50:17 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 19 Feb 2015 12:49:59 -0600 Message-Id: <1424371800-4249-5-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1424371800-4249-1-git-send-email-bill.fischofer@linaro.org> References: <1424371800-4249-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv5 5/6] linux-generic: pools: cleanup to reflect new pool parameters 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: bill.fischofer@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.45 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 Signed-off-by: Bill Fischofer --- .../linux-generic/include/odp_buffer_internal.h | 3 - platform/linux-generic/include/odp_pool_internal.h | 2 + platform/linux-generic/odp_pool.c | 101 ++++++++++++--------- 3 files changed, 58 insertions(+), 48 deletions(-) diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h index c532e35..3a3d2a2 100644 --- a/platform/linux-generic/include/odp_buffer_internal.h +++ b/platform/linux-generic/include/odp_buffer_internal.h @@ -53,9 +53,6 @@ extern "C" { _ODP_STATIC_ASSERT(ODP_CONFIG_PACKET_SEG_LEN_MIN >= 256, "ODP Segment size must be a minimum of 256 bytes"); -_ODP_STATIC_ASSERT((ODP_CONFIG_PACKET_SEG_LEN_MIN % ODP_CACHE_LINE_SIZE) == 0, - "ODP Segment size must be a multiple of cache line size"); - _ODP_STATIC_ASSERT((ODP_CONFIG_PACKET_BUF_LEN_MAX % ODP_CONFIG_PACKET_SEG_LEN_MIN) == 0, "Packet max size must be a multiple of segment size"); diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h index 46c2961..3d1497a 100644 --- a/platform/linux-generic/include/odp_pool_internal.h +++ b/platform/linux-generic/include/odp_pool_internal.h @@ -119,7 +119,9 @@ struct pool_entry_s { odp_atomic_u64_t blkempty; odp_atomic_u64_t high_wm_count; odp_atomic_u64_t low_wm_count; + uint32_t buf_num; uint32_t seg_size; + uint32_t blk_size; uint32_t high_wm; uint32_t low_wm; uint32_t headroom; diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index c07392f..8da3801 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -136,13 +136,9 @@ odp_pool_t odp_pool_create(const char *name, ODP_CACHE_LINE_SIZE_ROUNDUP(init_params->udata_size) : 0; - uint32_t blk_size, buf_stride; - uint32_t buf_align; - - if (params->type == ODP_POOL_PACKET) - buf_align = 0; - else - buf_align = params->buf.align; + uint32_t blk_size, buf_stride, buf_num, seg_len; + uint32_t buf_align = + params->type == ODP_POOL_BUFFER ? params->buf.align : 0; /* Validate requested buffer alignment */ if (buf_align > ODP_CONFIG_BUFFER_ALIGN_MAX || @@ -158,35 +154,45 @@ odp_pool_t odp_pool_create(const char *name, /* Calculate space needed for buffer blocks and metadata */ switch (params->type) { case ODP_POOL_BUFFER: - case ODP_POOL_TIMEOUT: + buf_num = params->buf.num; blk_size = params->buf.size; /* Optimize small raw buffers */ if (blk_size > ODP_MAX_INLINE_BUF || params->buf.align != 0) blk_size = ODP_ALIGN_ROUNDUP(blk_size, buf_align); - buf_stride = params->type == ODP_POOL_BUFFER ? - sizeof(odp_buffer_hdr_stride) : - sizeof(odp_timeout_hdr_stride); + buf_stride = sizeof(odp_buffer_hdr_stride); break; case ODP_POOL_PACKET: + unseg = 0; /* Packets are always segmented */ headroom = ODP_CONFIG_PACKET_HEADROOM; tailroom = ODP_CONFIG_PACKET_TAILROOM; - unseg = params->pkt.seg_len > ODP_CONFIG_PACKET_BUF_LEN_MAX; - - if (unseg) - blk_size = ODP_ALIGN_ROUNDUP( - headroom + params->pkt.seg_len + tailroom, - buf_align); - else - blk_size = ODP_ALIGN_ROUNDUP( - headroom + params->pkt.seg_len + tailroom, - ODP_CONFIG_PACKET_SEG_LEN_MIN); - - buf_stride = params->type == ODP_POOL_PACKET ? - sizeof(odp_packet_hdr_stride) : - sizeof(odp_any_hdr_stride); + buf_num = params->pkt.num; + + seg_len = params->pkt.seg_len == 0 ? + ODP_CONFIG_PACKET_SEG_LEN_MIN : + (params->pkt.seg_len <= ODP_CONFIG_PACKET_SEG_LEN_MAX ? + params->pkt.seg_len : ODP_CONFIG_PACKET_SEG_LEN_MAX); + + seg_len = ODP_ALIGN_ROUNDUP( + headroom + seg_len + tailroom, + ODP_CONFIG_BUFFER_ALIGN_MIN); + + blk_size = params->pkt.len <= seg_len ? seg_len : + ODP_ALIGN_ROUNDUP(params->pkt.len, seg_len); + + /* Reject create if pkt.len needs too many segments */ + if (blk_size / seg_len > ODP_BUFFER_MAX_SEG) + return ODP_POOL_INVALID; + + buf_stride = sizeof(odp_packet_hdr_stride); + break; + + case ODP_POOL_TIMEOUT: + blk_size = 0; + buf_num = params->tmo.num; + buf_stride = sizeof(odp_timeout_hdr_stride); break; default: @@ -194,7 +200,7 @@ odp_pool_t odp_pool_create(const char *name, } /* Validate requested number of buffers against addressable limits */ - if (params->buf.num > + if (buf_num > (ODP_BUFFER_MAX_BUFFERS / (buf_stride / ODP_CACHE_LINE_SIZE))) return ODP_POOL_INVALID; @@ -231,14 +237,15 @@ odp_pool_t odp_pool_create(const char *name, block_size = 0; pool->s.buf_align = blk_size == 0 ? 0 : sizeof(void *); } else { - block_size = params->buf.num * blk_size; + block_size = buf_num * blk_size; pool->s.buf_align = buf_align; } pad_size = ODP_CACHE_LINE_SIZE_ROUNDUP(block_size) - block_size; - mdata_size = params->buf.num * buf_stride; - udata_size = params->buf.num * udata_stride; + mdata_size = buf_num * buf_stride; + udata_size = buf_num * udata_stride; + pool->s.buf_num = buf_num; pool->s.pool_size = ODP_PAGE_SIZE_ROUNDUP(block_size + pad_size + mdata_size + @@ -283,9 +290,8 @@ odp_pool_t odp_pool_create(const char *name, pool->s.flags.unsegmented = unseg; pool->s.flags.zeroized = zeroized; - pool->s.seg_size = unseg ? - blk_size : ODP_CONFIG_PACKET_SEG_LEN_MIN; - + pool->s.seg_size = unseg ? blk_size : seg_len; + pool->s.blk_size = blk_size; uint8_t *block_base_addr = pool->s.pool_base_addr; uint8_t *mdata_base_addr = @@ -355,6 +361,7 @@ odp_pool_t odp_pool_create(const char *name, do { ret_blk(&pool->s, blk); blk -= pool->s.seg_size; + i++; } while (blk >= block_base_addr); /* Initialize pool statistics counters */ @@ -375,8 +382,8 @@ odp_pool_t odp_pool_create(const char *name, pool->s.tailroom = tailroom; /* Watermarks are hard-coded for now to control caching */ - pool->s.high_wm = params->buf.num / 2; - pool->s.low_wm = params->buf.num / 4; + pool->s.high_wm = buf_num / 2; + pool->s.low_wm = buf_num / 4; pool_hdl = pool->s.pool_hdl; break; @@ -417,10 +424,7 @@ int odp_pool_info(odp_pool_t pool_hdl, odp_pool_info_t *info) info->name = pool->s.name; info->shm = pool->s.flags.user_supplied_shm ? pool->s.pool_shm : ODP_SHM_INVALID; - info->params.buf.size = pool->s.params.buf.size; - info->params.buf.align = pool->s.params.buf.align; - info->params.buf.num = pool->s.params.buf.num; - info->params.type = pool->s.params.type; + info->params = pool->s.params; return 0; } @@ -446,7 +450,7 @@ int odp_pool_destroy(odp_pool_t pool_hdl) flush_cache(&local_cache[pool_id], &pool->s); /* Call fails if pool has allocated buffers */ - if (odp_atomic_load_u32(&pool->s.bufcount) < pool->s.params.buf.num) { + if (odp_atomic_load_u32(&pool->s.bufcount) < pool->s.buf_num) { POOL_UNLOCK(&pool->s.lock); return -1; } @@ -470,7 +474,7 @@ odp_buffer_t buffer_alloc(odp_pool_t pool_hdl, size_t size) /* Reject oversized allocation requests */ if ((pool->s.flags.unsegmented && totsize > pool->s.seg_size) || (!pool->s.flags.unsegmented && - totsize > ODP_CONFIG_PACKET_BUF_LEN_MAX)) + totsize > pool->s.seg_size * ODP_BUFFER_MAX_SEG)) return ODP_BUFFER_INVALID; /* Try to satisfy request from the local cache */ @@ -587,14 +591,21 @@ void odp_pool_print(odp_pool_t pool_hdl) ODP_DBG(" pool mdata base %p\n", pool->s.pool_mdata_addr); ODP_DBG(" udata size %zu\n", pool->s.init_params.udata_size); ODP_DBG(" headroom %u\n", pool->s.headroom); - ODP_DBG(" buf size %zu\n", pool->s.params.buf.size); ODP_DBG(" tailroom %u\n", pool->s.tailroom); - ODP_DBG(" buf align %u requested, %u used\n", - pool->s.params.buf.align, pool->s.buf_align); - ODP_DBG(" num bufs %u\n", pool->s.params.buf.num); + if (pool->s.params.type == ODP_POOL_BUFFER) { + ODP_DBG(" buf size %zu\n", pool->s.params.buf.size); + ODP_DBG(" buf align %u requested, %u used\n", + pool->s.params.buf.align, pool->s.buf_align); + } else if (pool->s.params.type == ODP_POOL_PACKET) { + ODP_DBG(" seg length %u requested, %u used\n", + pool->s.params.pkt.seg_len, pool->s.seg_size); + ODP_DBG(" pkt length %u requested, %u used\n", + pool->s.params.pkt.len, pool->s.blk_size); + } + ODP_DBG(" num bufs %u\n", pool->s.buf_num); ODP_DBG(" bufs available %u %s\n", bufcount, pool->s.low_wm_assert ? " **low wm asserted**" : ""); - ODP_DBG(" bufs in use %u\n", pool->s.params.buf.num - bufcount); + ODP_DBG(" bufs in use %u\n", pool->s.buf_num - bufcount); ODP_DBG(" buf allocs %lu\n", bufallocs); ODP_DBG(" buf frees %lu\n", buffrees); ODP_DBG(" buf empty %lu\n", bufempty);