From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) by dpdk.org (Postfix) with ESMTP id 1D1BC69FC for ; Wed, 11 Jan 2017 17:18:01 +0100 (CET) Received: by mail-pf0-f179.google.com with SMTP id 127so63300425pfg.1 for ; Wed, 11 Jan 2017 08:18:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4lPnOfWOPWtZvWzbghJDE6/9dV/DY8xFj7ONSjqnQWs=; b=Pv1MYDYlP9v+eu4R2CNuEs5s9X8y7B9vCHMAve+p6z6eOGNke2G0myvJKjEqNCk9Ko ZPqnVX0KqcNJywuiuEx+CIyZexo0F3fbY28bZnlHKs4ZSGS2IyiNG57ptkA/zRfAAWjQ 7TN5Q2tUuyYYnxbwLLVklUL2yPyLbBbo0045C/4Rn94zR6pvp2zlnoOTWgDmYXC7aBge UKYllByQfJ+RCUhwbBfzIP3aoos15ivUGADZ56zjMo4xAl9eKrN1E5MVZHqD54w0tfzC /y7cJ8coOc/n0IJe7ZhMK0H/5bbG6grQOjwkBbBThcUF65OmEdh3SG18FY8zaIKQAOw7 edNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4lPnOfWOPWtZvWzbghJDE6/9dV/DY8xFj7ONSjqnQWs=; b=l6mvsFuNwp/UVBnP8QuNHCe9EbNlr4PAwZNRl4Z7xojU3Yucbs0yjqOBqpSoi9x3Wz Eldss0AUOdOirtXDPY9S19jYmmbGujTHCexWOxaEz2yJgtDiHVlUrojyG8hzv8a5RbYh qm/y+TRBtySug8tKDBXGp7PNBIMEFA/yjM2JzlNd/rZKFHmCE0W6DT8oiOwkPSXaoYJ5 KyY/RphtZXu9CF65bVdxTsaBku+s4GA0r8iShLhzYoGspdIXec+M+2ukHBSS7pyHVDZv V7SICHLROc0FFjWOWPxQ9rIhUZ1VFLn+1zBGaSSDLxlg8w5PhBIraSUWtPDeq0cqVY6z l7BA== X-Gm-Message-State: AIkVDXIktbzm/mDu2umwYvONLRKoxf+mUlno6xEg7K65tU4duL5lSXnB3rhyimLV4oSy7A== X-Received: by 10.99.246.5 with SMTP id m5mr11879933pgh.9.1484151481319; Wed, 11 Jan 2017 08:18:01 -0800 (PST) Received: from xeon-e3 (204-195-18-65.wavecable.com. [204.195.18.65]) by smtp.gmail.com with ESMTPSA id k192sm15079106pgc.3.2017.01.11.08.18.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jan 2017 08:18:01 -0800 (PST) Date: Wed, 11 Jan 2017 08:17:59 -0800 From: Stephen Hemminger To: Sergey Vyazmitinov Cc: olivier.matz@6wind.com, ferruh.yigit@intel.com, dev@dpdk.org Message-ID: <20170111081759.7b1ee146@xeon-e3> In-Reply-To: <1483048216-2936-1-git-send-email-s.vyazmitinov@brain4net.com> References: <1483048216-2936-1-git-send-email-s.vyazmitinov@brain4net.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] kni: use bulk functions to allocate and free mbufs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2017 16:18:02 -0000 On Fri, 30 Dec 2016 04:50:16 +0700 Sergey Vyazmitinov wrote: > /** > + * Free n packets mbuf back into its original mempool. > + * > + * Free each mbuf, and all its segments in case of chained buffers. Each > + * segment is added back into its original mempool. > + * > + * @param mp > + * The packets mempool. > + * @param mbufs > + * The packets mbufs array to be freed. > + * @param n > + * Number of packets. > + */ > +static inline void rte_pktmbuf_free_bulk(struct rte_mempool *mp, > + struct rte_mbuf **mbufs, unsigned n) > +{ > + struct rte_mbuf *mbuf, *m_next; > + unsigned i; > + for (i = 0; i < n; ++i) { > + mbuf = mbufs[i]; > + __rte_mbuf_sanity_check(mbuf, 1); > + > + mbuf = mbuf->next; > + while (mbuf != NULL) { > + m_next = mbuf->next; > + rte_pktmbuf_free_seg(mbuf); > + mbuf = m_next; > + } > + } > + rte_mempool_put_bulk(mp, (void * const *)mbufs, n); > +} The mbufs may come from different pools. You need to handle that.