From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw0-f195.google.com (mail-yw0-f195.google.com [209.85.161.195]) by dpdk.org (Postfix) with ESMTP id 718BE93FA for ; Mon, 16 May 2016 04:46:27 +0200 (CEST) Received: by mail-yw0-f195.google.com with SMTP id i22so17748536ywc.1 for ; Sun, 15 May 2016 19:46:27 -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=vUdqSQY/SLLXXabL8V7jqr/oVxQqDrChreJoYCR5upo=; b=qGlc7C59qHFJm7cOM4ykWOFvX6U2kD450TuNrl9I6pBudQF/dP3cdrqSqc64xk/ie8 9fXCx1hEbAyACWjSU6rPvSrcuiQ9EEWo6RQOFqaHosVxj7bsv6ArjAfV3Jf96kIzQBH2 CG0n2931D2ySrvlCgCVuMpjIwuCkRQSwzCUDXVm/kchJj4EDGXpJCMFCWPlHNNhADNOs niKIa1+KbQZ8hOoeEfQG6a8lF0eZaIB3SqkL7Qk4mSNqEdMz3uGGWRX7rQ2t4EfvM0Yx vI6KI1ZMC9cOJhmRsyIWatF5NOaR0i3VtTsBZyEbuJzbIHq5GPi5jAE0lx7LPLsR19gX fGEg== 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=vUdqSQY/SLLXXabL8V7jqr/oVxQqDrChreJoYCR5upo=; b=PvYYh+T9kj9Lb95QrygfG45T75tX634W3aD38O5CwCdkYNx0zBiUjXM6toHq/7XfUT KF0d+3sxOHllgCAT7iUNdhPSL2fOS5zoHe7Nu+Nyd7JHvxCWqeMohFUE0ettWXChiPXf fgAi+OvVuB9Q85EiPVu8KB3nEO/lHCh5MKDQlCwrCa4pVxISqvaOfEvxHAynwXGw+2YO z1KseiBm7Aj3edISVHDVTw85ZeuHsMQJWje4id22l7KLCT7BIUDAZVceOe3nNdIfQezB IzyosFgxE8wpMUOflsb1G25LE4swJTy/21sWH9EqLVUw6vQSfplPHUPyo+9xbv14DgyY f7EQ== X-Gm-Message-State: AOPr4FUbL4SQAK8wl3gin5HOxFhj2n9giuzDK5XjMTzd9PelZwMPApO37eDPqvXDns6bx/RKnojok/UsdJ4sJA== X-Received: by 10.37.114.3 with SMTP id n3mr13063514ybc.158.1463366786885; Sun, 15 May 2016 19:46:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.50.214 with HTTP; Sun, 15 May 2016 19:46:07 -0700 (PDT) In-Reply-To: <2601191342CEEE43887BDE71AB97725836B50F15@irsmsx105.ger.corp.intel.com> References: <1463327436-6863-1-git-send-email-h.mikita89@gmail.com> <2601191342CEEE43887BDE71AB97725836B50F15@irsmsx105.ger.corp.intel.com> From: Hiroyuki MIKITA Date: Mon, 16 May 2016 11:46:07 +0900 Message-ID: To: "Ananyev, Konstantin" , "olivier.matz@6wind.com" Cc: "dev@dpdk.org" Content-Type: text/plain; charset=UTF-8 Subject: Re: [dpdk-dev] [PATCH] 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: Mon, 16 May 2016 02:46:27 -0000 Hi Konstantin, Now, the attach operation increases refcnt, but the detach does not decrease it. I think both operations should affect refcnt or not. Which design is intended? In "6.7. Direct and Indirect Buffers" of Programmer's Guide, it is mentioned that "...whenever an indirect buffer is attached to the direct buffer, the reference counter on the direct buffer is incremented. Similarly, whenever the indirect buffer is detached, the reference counter on the direct buffer is decremented." Regards, Hiroyuki 2016-05-16 9:05 GMT+09:00 Ananyev, Konstantin : > > >> -----Original Message----- >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Hiroyuki Mikita >> Sent: Sunday, May 15, 2016 4:51 PM >> To: olivier.matz@6wind.com >> Cc: dev@dpdk.org >> Subject: [dpdk-dev] [PATCH] mbuf: decrease refcnt when detaching >> >> The rte_pktmbuf_detach() function should decrease refcnt on a direct >> buffer. > > Hmm, why is that? > What's wrong with the current approach? > Konstantin > >> >> Signed-off-by: Hiroyuki Mikita >> --- >> lib/librte_mbuf/rte_mbuf.h | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h >> index 529debb..3b117ca 100644 >> --- a/lib/librte_mbuf/rte_mbuf.h >> +++ b/lib/librte_mbuf/rte_mbuf.h >> @@ -1468,9 +1468,11 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, struct rte_mbuf *m) >> */ >> 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; >> >> + rte_mbuf_refcnt_update(md, -1); >> priv_size = rte_pktmbuf_priv_size(mp); >> mbuf_size = sizeof(struct rte_mbuf) + priv_size; >> buf_len = rte_pktmbuf_data_room_size(mp); >> @@ -1498,7 +1500,7 @@ __rte_pktmbuf_prefree_seg(struct rte_mbuf *m) >> 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) >> + if (rte_mbuf_refcnt_read(md) == 0) >> __rte_mbuf_raw_free(md); >> } >> return m; >> -- >> 1.9.1 >