From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw0-f196.google.com (mail-yw0-f196.google.com [209.85.161.196]) by dpdk.org (Postfix) with ESMTP id C64915A90 for ; Wed, 18 May 2016 16:29:32 +0200 (CEST) Received: by mail-yw0-f196.google.com with SMTP id v81so6811418ywa.2 for ; Wed, 18 May 2016 07:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=jB+e9IlsF+7NL3KF3IStAMEdAehUYB2uS8Rb7qc5E1o=; b=j1BoD+JmBe1ITdmC2AskELjB0ePURNA6L19RPaDto+p/LkQPyKlRlIM6PjDK3uXc8f cqcHRWYacEJS5Fil0ckgtQaodIiinE1Z9JjeGH6aYgA4l40jPb/GIyoHro5sfZ5nGK/V PgfoecfPFa3GB8thE5wa23sejnF/s1H57xZBVIwmsOmPzFSUvxKwDBE9445WYjKg4ugW QtLTzRoPvlpZlOpNO600OBTDwtuVZ1vGUveX+sI+rW4kVEstdAFhk+XlXAvUixsZnqG1 K5TLpSu6FW9LCzJz3E1qETu9TrK8OI8C6YE0IDcTVRPkRpQr177oi7hRiq1xGinUEDQ7 DxkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=jB+e9IlsF+7NL3KF3IStAMEdAehUYB2uS8Rb7qc5E1o=; b=f1DzIulM2sIxUPiAyrsx1OWjGidfVY+1dhAHN1yhY8YkEofGtTWwikU1TwSVq5PZbH 7fSIJiP7XBa8l9q3J+3i3AzuxoO4veXJD5KIsrbbaRA5yasDvmVxBRbPB52QELvc1LuX mzWlz4QQwus1SBCHCserSVMo6/YQG21EbO8Sws+0SorxEd/UMsR2RplJUc3n2T0qyhD3 NaNG7SKI8OVP+2XrRZvkSEo3wwJkqHR0MqK4iz4Mc4jmgTI/dxSu8dvCwKi8dHrQvqJG 2mo8u8ZaPR7u/hT9N1gKm/aCm2kgIbKcIGiyE/HUPbxFpVegHL8YT4nnPPcSq5Q8sJGw kBqw== X-Gm-Message-State: AOPr4FUM1hkTxKkoPG8AK70fvbzbWm0xqBOj5DFtNB28GGGSgkRM0sGgazkBzTPLmjYuiCemG4P3/RTD7yCNZg== X-Received: by 10.129.96.214 with SMTP id u205mr4021015ywb.14.1463581772295; Wed, 18 May 2016 07:29:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.50.214 with HTTP; Wed, 18 May 2016 07:29:12 -0700 (PDT) In-Reply-To: <573C58FE.3020101@6wind.com> References: <1463417600-20943-1-git-send-email-h.mikita89@gmail.com> <1463502902-5295-1-git-send-email-h.mikita89@gmail.com> <573C58FE.3020101@6wind.com> From: Hiroyuki Mikita Date: Wed, 18 May 2016 23:29:12 +0900 Message-ID: To: Olivier Matz Cc: Thomas Monjalon , "Ananyev, Konstantin" , dev@dpdk.org Content-Type: text/plain; charset=UTF-8 Subject: Re: [dpdk-dev] [PATCH v3] mbuf: decrease refcnt when detaching X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 May 2016 14:29:33 -0000 Hi Olivier, Thanks for reviewing. I am fixing the patch to follow your comments. Regards, Hiroyuki 2016-05-18 20:58 GMT+09:00 Olivier Matz : > Hi Hiroyuki, > > Thanks for submitting a new version. > > There are some styling issues in the patch, I highlighted them below > but you can check them by using checkpatch: > > DPDK_CHECKPATCH_PATH=/path/to/linux/checkpatch.pl \ > scripts/checkpatches.sh file.patch > > > On 05/17/2016 06:35 PM, Hiroyuki Mikita wrote: >> The rte_pktmbuf_detach() function should decrease refcnt on a direct >> buffer. >> >> Signed-off-by: Hiroyuki Mikita >> >> [...] >> >> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h >> index 529debb..299b60e 100644 >> --- a/lib/librte_mbuf/rte_mbuf.h >> +++ b/lib/librte_mbuf/rte_mbuf.h >> @@ -1408,6 +1408,8 @@ static inline int rte_pktmbuf_alloc_bulk(struct rte_mempool *pool, >> * >> * After attachment we refer the mbuf we attached as 'indirect', >> * while mbuf we attached to as 'direct'. >> + * The direct mbuf's reference counter is incremented. >> + * > > ERROR:TRAILING_WHITESPACE: trailing whitespace > #82: FILE: lib/librte_mbuf/rte_mbuf.h:1412: > + * $ > > >> * Right now, not supported: >> * - attachment for already indirect mbuf (e.g. - mi has to be direct). >> * - mbuf we trying to attach (mi) is used by someone else >> @@ -1462,12 +1464,15 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, struct rte_mbuf *m) >> * - restore original mbuf address and length values. >> * - reset pktmbuf data and data_len to their default values. >> * All other fields of the given packet mbuf will be left intact. >> + * - decrement the direct mbuf's reference counter. >> + * When the reference counter becomes 0, the direct mbuf is freed. > > Minor comment here: I think something like that would be clearer: > > * - restore original mbuf address and length values. > * - reset pktmbuf data and data_len to their default values. > * - decrement the direct mbuf's reference counter. When the > * reference counter becomes 0, the direct mbuf is freed. > * > * All other fields of the given packet mbuf will be left intact. > > >> * >> * @param m >> * The indirect attached packet mbuf. >> */ >> static inline void rte_pktmbuf_detach(struct rte_mbuf *m) >> { >> + struct rte_mbuf *md = rte_mbuf_from_indirect(m); >> struct rte_mempool *mp = m->pool; >> uint32_t mbuf_size, buf_len, priv_size; >> >> @@ -1482,6 +1487,10 @@ static inline void rte_pktmbuf_detach(struct rte_mbuf *m) >> m->data_off = RTE_MIN(RTE_PKTMBUF_HEADROOM, (uint16_t)m->buf_len); >> m->data_len = 0; >> m->ol_flags = 0; >> + >> + if (rte_mbuf_refcnt_update(md, -1) == 0) { >> + __rte_mbuf_raw_free(md); >> + } >> } > > WARNING:BRACES: braces {} are not necessary for single statement blocks > #107: FILE: lib/librte_mbuf/rte_mbuf.h:1491: > + if (rte_mbuf_refcnt_update(md, -1) == 0) { > + __rte_mbuf_raw_free(md); > + } > > >> >> static inline struct rte_mbuf* __attribute__((always_inline)) >> @@ -1491,15 +1500,9 @@ __rte_pktmbuf_prefree_seg(struct rte_mbuf *m) >> >> if (likely(rte_mbuf_refcnt_update(m, -1) == 0)) { >> >> - /* if this is an indirect mbuf, then >> - * - detach mbuf >> - * - free attached mbuf segment >> - */ >> + /* if this is an indirect mbuf, it is detached. */ >> if (RTE_MBUF_INDIRECT(m)) { >> - struct rte_mbuf *md = rte_mbuf_from_indirect(m); >> rte_pktmbuf_detach(m); >> - if (rte_mbuf_refcnt_update(md, -1) == 0) >> - __rte_mbuf_raw_free(md); >> } >> return m; >> } >> > > It's not seen by checkpatch, but the braces could also be removed > here. > > Apart from this, it looks good to me. I'm ok with not providing a > compat function as we could consider it was a bug. > > Thanks for working on this. > > Olivier >