From patchwork Fri Feb 13 20:35:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44678 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 492982153D for ; Fri, 13 Feb 2015 20:35:40 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id bs8sf8875465wib.2 for ; Fri, 13 Feb 2015 12:35:39 -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=39PzqB2iI23aJZnhS+xyAalO5I9eAbjwarqN3po9X6o=; b=DJinQObAdwS3C/EPG2aJDBcDli3GPKWOjR5KmRAtLUMTRjNo2Ghu8BrnfxxhK5+d6O EWYJ3j+c5JnLEOB9QusHEdeOPrBAEskO9LaHhCBN9sP+fLFOZGmYo1AHdwCW44GCQkBl uQAbxbwNIGqHbpgam/HckqjKFF8tgwSNHR3aHHCvNE5mQoGeatbvnb1PgV7eqmcLHwiY 0zfJecmeGuakoOEelev6sJq5FaXdStFpo6PfHbcKELxAiHAUSbbxcFUI4bk1LFxB99LJ LLixla/suSno9nvYSDdlpBFXIFcdXxAQYeKV0I3hWnCtzuTrpELmvnGburW4EHWBI4GH CxPg== X-Gm-Message-State: ALoCoQmMR8KGI5d/5lRhY9t1fYyquKRXDWEl7Sye8Zk1nTTVLmSoTUtNCdMBlT3jZqXNldiib0Vi X-Received: by 10.181.13.236 with SMTP id fb12mr1509284wid.1.1423859739522; Fri, 13 Feb 2015 12:35:39 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.17 with SMTP id t17ls412342laz.2.gmail; Fri, 13 Feb 2015 12:35:39 -0800 (PST) X-Received: by 10.112.54.228 with SMTP id m4mr10252631lbp.20.1423859739293; Fri, 13 Feb 2015 12:35:39 -0800 (PST) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id kv18si775055lbb.19.2015.02.13.12.35.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Feb 2015 12:35:39 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id f15so16862145lbj.13 for ; Fri, 13 Feb 2015 12:35:39 -0800 (PST) X-Received: by 10.112.54.167 with SMTP id k7mr9992271lbp.72.1423859738993; Fri, 13 Feb 2015 12:35:38 -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 h5csp92789lbj; Fri, 13 Feb 2015 12:35:38 -0800 (PST) X-Received: by 10.140.95.179 with SMTP id i48mr27247628qge.4.1423859737432; Fri, 13 Feb 2015 12:35:37 -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 r127si759614qha.44.2015.02.13.12.35.35 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 13 Feb 2015 12:35:37 -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 1YMMxZ-0005FA-Ro; Fri, 13 Feb 2015 20:35:33 +0000 Received: from mail-pd0-f174.google.com ([209.85.192.174]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YMMxT-0005Dg-Ic for lng-odp@lists.linaro.org; Fri, 13 Feb 2015 20:35:27 +0000 Received: by pdjz10 with SMTP id z10so21640662pdj.0 for ; Fri, 13 Feb 2015 12:35:22 -0800 (PST) X-Received: by 10.68.189.105 with SMTP id gh9mr18080746pbc.142.1423859722187; Fri, 13 Feb 2015 12:35:22 -0800 (PST) Received: from localhost.localdomain ([210.177.145.245]) by mx.google.com with ESMTPSA id rr9sm7537123pbc.39.2015.02.13.12.35.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Feb 2015 12:35:21 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Fri, 13 Feb 2015 12:35:21 -0800 Message-Id: <1423859721-9719-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH 4/4] 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.217.182 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 --- platform/linux-generic/include/odp_pool_internal.h | 1 + platform/linux-generic/odp_pool.c | 66 +++++++++++----------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h index c5354e5..0c0c0be 100644 --- a/platform/linux-generic/include/odp_pool_internal.h +++ b/platform/linux-generic/include/odp_pool_internal.h @@ -119,6 +119,7 @@ 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 high_wm; uint32_t low_wm; diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index c07392f..1fe0c5f 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; + 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,41 @@ 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: headroom = ODP_CONFIG_PACKET_HEADROOM; tailroom = ODP_CONFIG_PACKET_TAILROOM; - unseg = params->pkt.seg_len > ODP_CONFIG_PACKET_BUF_LEN_MAX; + buf_num = params->pkt.num; + uint32_t seg_len = params->pkt.seg_len == 0 ? + ODP_CONFIG_PACKET_SEG_LEN_MIN : + headroom + params->pkt.seg_len + tailroom; + uint32_t pkt_len = params->pkt.len <= seg_len ? + seg_len : params->pkt.len; + unseg = pkt_len > ODP_CONFIG_PACKET_BUF_LEN_MAX; if (unseg) - blk_size = ODP_ALIGN_ROUNDUP( - headroom + params->pkt.seg_len + tailroom, - buf_align); + blk_size = ODP_ALIGN_ROUNDUP(seg_len, + ODP_CONFIG_BUFFER_ALIGN_MIN); else - blk_size = ODP_ALIGN_ROUNDUP( - headroom + params->pkt.seg_len + tailroom, + blk_size = ODP_ALIGN_ROUNDUP(pkt_len, ODP_CONFIG_PACKET_SEG_LEN_MIN); - buf_stride = params->type == ODP_POOL_PACKET ? - sizeof(odp_packet_hdr_stride) : - sizeof(odp_any_hdr_stride); + 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 +196,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 +233,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 + @@ -375,8 +378,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 +420,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 +446,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; } @@ -591,10 +591,10 @@ void odp_pool_print(odp_pool_t pool_hdl) 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); + 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);