From patchwork Tue Sep 13 12:40:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 76061 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1316048qgf; Tue, 13 Sep 2016 04:41:31 -0700 (PDT) X-Received: by 10.200.34.81 with SMTP id p17mr321184qtp.7.1473766891016; Tue, 13 Sep 2016 04:41:31 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q8si7452504qtb.102.2016.09.13.04.41.30; Tue, 13 Sep 2016 04:41:30 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 5C385609A9; Tue, 13 Sep 2016 11:41:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id DC1A1609B2; Tue, 13 Sep 2016 11:41:26 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 439A760DF1; Tue, 13 Sep 2016 11:41:24 +0000 (UTC) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by lists.linaro.org (Postfix) with ESMTPS id 42611609A9 for ; Tue, 13 Sep 2016 11:41:23 +0000 (UTC) Received: by mail-lf0-f54.google.com with SMTP id h127so107758027lfh.0 for ; Tue, 13 Sep 2016 04:41:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=hhMJqEMHtRdjThHtiPciChWHt0xlHHLtQDMH0crT9oU=; b=jrUhYwiVfnJlBQvIJrdzC3N5gqwn+LmH1NqYfGn9maurQujW6lfDxFHsH5LhJ1CB8s BaYJqUop4McvLb0rOiJdsrp6tmjy23FAT1cCzHd1XPbGKc4SO3I9AtHblOQvN0NMGeM2 jI5kRTNT5++TVoA51asduQceIsUmc80Uvr0efW/ltql6rSOJjJ284TAKuunOVjjMCalO Rovr7HxSPCpCgX78mtozrAr6GKHSJhBPNGk3ZLWgCVbgXqHV6R5bZ5bZp4H9OJFvPHQB ICl5RWB+JVtFkNC7Wc4DxFqJ/FfWGyQYh5ZMBDDBMpvb1BvjYOOepy6pFjU6ZlO9AT5a twxQ== X-Gm-Message-State: AE9vXwNJ2jG4vF0HX4IevpgoqPgllMnvfI/fceqQ5LtcUzi7Egxnnkb8zHqolbOr4Xvru4/akeE= X-Received: by 10.25.74.138 with SMTP id x132mr8000151lfa.154.1473766882034; Tue, 13 Sep 2016 04:41:22 -0700 (PDT) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id l65sm1111765lfl.30.2016.09.13.04.41.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Sep 2016 04:41:21 -0700 (PDT) From: Christophe Milard To: lng-odp@lists.linaro.org, mike.holmes@linaro.org, bill.fischofer@linaro.org Date: Tue, 13 Sep 2016 14:40:46 +0200 Message-Id: <1473770446-54915-1-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2] linux-generic: _fdserver: allocating data table dynamicaly X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" The table containing the saved file-descriptors<->{context, key} couples is now dynamically malloc'd in the fd server process, hence avoiding the memory waste which happened in other process when the table was staticaly reserved in all processes. Signed-off-by: Christophe Milard --- platform/linux-generic/_fdserver.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) -- 2.7.4 Reviewed-by: Bill Fischofer diff --git a/platform/linux-generic/_fdserver.c b/platform/linux-generic/_fdserver.c index bf36eb2..5cef806 100644 --- a/platform/linux-generic/_fdserver.c +++ b/platform/linux-generic/_fdserver.c @@ -73,7 +73,7 @@ typedef struct fdentry_s { uint64_t key; int fd; } fdentry_t; -static fdentry_t fd_table[FDSERVER_MAX_ENTRIES]; +static fdentry_t *fd_table; static int fd_table_nb_entries; /* @@ -622,8 +622,20 @@ int _odp_fdserver_init_global(void) /* TODO: pin the server on appropriate service cpu mask */ /* when (if) we can agree on the usage of service mask */ + /* allocate the space for the file descriptor<->key table: */ + fd_table = malloc(FDSERVER_MAX_ENTRIES * sizeof(fdentry_t)); + if (!fd_table) { + ODP_ERR("maloc failed!\n"); + exit(1); + } + + /* wait for clients requests */ wait_requests(sock); /* Returns when server is stopped */ close(sock); + + /* release the file descriptor table: */ + free(fd_table); + exit(0); }