From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 12D3CA0471 for ; Fri, 19 Jul 2019 16:03:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6C1542C2B; Fri, 19 Jul 2019 16:03:34 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id D45EB2C17 for ; Fri, 19 Jul 2019 16:03:32 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jul 2019 07:03:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,282,1559545200"; d="scan'208";a="176300691" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.251.81.9]) ([10.251.81.9]) by FMSMGA003.fm.intel.com with ESMTP; 19 Jul 2019 07:03:29 -0700 To: Olivier Matz , Vamsi Krishna Attunuru , dev@dpdk.org Cc: Andrew Rybchenko , Thomas Monjalon , Jerin Jacob Kollanukkaran , Kokkilagadda , Ferruh Yigit References: <20190719133845.32432-1-olivier.matz@6wind.com> <20190719133845.32432-5-olivier.matz@6wind.com> From: "Burakov, Anatoly" Message-ID: Date: Fri, 19 Jul 2019 15:03:29 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190719133845.32432-5-olivier.matz@6wind.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [RFC 4/4] mempool: prevent objects from being across pages 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 19-Jul-19 2:38 PM, Olivier Matz wrote: > When using iova contiguous memory and objets smaller than page size, > ensure that objects are not located across several pages. > > Signed-off-by: Vamsi Krishna Attunuru > Signed-off-by: Olivier Matz > --- > lib/librte_mempool/rte_mempool_ops_default.c | 39 ++++++++++++++++++++++++++-- > 1 file changed, 37 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_mempool/rte_mempool_ops_default.c b/lib/librte_mempool/rte_mempool_ops_default.c > index 4e2bfc82d..2bbd67367 100644 > --- a/lib/librte_mempool/rte_mempool_ops_default.c > +++ b/lib/librte_mempool/rte_mempool_ops_default.c > @@ -45,19 +45,54 @@ rte_mempool_op_calc_mem_size_default(const struct rte_mempool *mp, > return mem_size; > } > > +/* Returns -1 if object falls on a page boundary, else returns 0 */ > +static inline int > +mempool_check_obj_bounds(void *obj, uint64_t pg_sz, size_t elt_sz) > +{ > + uintptr_t page_end, elt_addr = (uintptr_t)obj; > + uint32_t pg_shift; > + uint64_t page_mask; > + > + if (pg_sz == 0) > + return 0; > + if (elt_sz > pg_sz) > + return 0; > + > + pg_shift = rte_bsf32(pg_sz); > + page_mask = ~((1ull << pg_shift) - 1); > + page_end = (elt_addr & page_mask) + pg_sz; This looks like RTE_PTR_ALIGN should do this without the magic? E.g. page_end = RTE_PTR_ALIGN(elt_addr, pg_sz) would that not be equivalent? -- Thanks, Anatoly