From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F169C5519F for ; Wed, 25 Nov 2020 08:31:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95EEE208C3 for ; Wed, 25 Nov 2020 08:31:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xk6NMfOL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbgKYIbG (ORCPT ); Wed, 25 Nov 2020 03:31:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbgKYIbF (ORCPT ); Wed, 25 Nov 2020 03:31:05 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6A57C0613D4; Wed, 25 Nov 2020 00:31:05 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id w4so1751011pgg.13; Wed, 25 Nov 2020 00:31:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=N7xGopky69OBXYiirtoLdMN6Zr9cEz2IQpL5ojSkxnM=; b=Xk6NMfOL3m5WhIAFhwkEIqOHkI16g7MRWX6o+UdNUxBLjRHs/n9n7viSWmiHsKSmA2 zju2iLn/g6TfHUsdXJK61M4kCTYQMwvrc0twhq9HOJGQt5bqAJgHDiwF18UTmfp7JLBQ OBQOwMdsDKalNEdHzSzzgOqRPWT41e3F3IAX32kCSAj4X76q4iNV5HPmwe2+4TidUS3L 86yIoIOZNg0n8T1zcBKXvBB/Ld4BeLLhCQfU2h5Dlu8PmPtzKA8vg/Vm4rjkF4u3WHzP Fjpjs8HL1UzixIJwP57/ZMEhEdkOCLl8JNv9dOMpAiGW2RC9zp85zSQPi+yIUD47gRdH ZS6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=N7xGopky69OBXYiirtoLdMN6Zr9cEz2IQpL5ojSkxnM=; b=VVq81uZ0l7GfPzcKYg0sFtpl+QLQnxa/raNxhCqa/a+W+0EH8CuRBrArg8dhwfSP9z WMKTP1H4kP255HUeqFRJffff++zlCrnjjiYCHGBtarTNZk/3fJ5u8xEr1wcdN6VjLt2/ DYpxaIUgO0VkwqTfqKMcogcXjMR0lBZi3R8GMizbMxHixWgZddONd8fVK0pQG01FdMIz 9i9Gk74lqpYZroy4wPDnQKyAIdXoMFDbYYLNYRdni6l6r7pxhro3+2tHf4mJ2aOq2kTJ cINfTyEhqWOK6umQdMZ7uw/y19ZO29+aCqu+DnLthgWQNR1MxH9tXMJDwryivs/HUumu s0qA== X-Gm-Message-State: AOAM53274/p+CzHsGavOSnvVBmdDrwPfDk8l0dxB4paQ43wzLT7eXdjC XN5JL5xVWMuYDjTjxCz+B3xNJEvJrSydI5lCX5k= X-Google-Smtp-Source: ABdhPJweLpimAZFICk7o14nG9tAxizh24vU608v80QOUQtpP+fVDzRK5HR1hWu1fqCBKcZKXSSD2OTU/f7UsdxGjAGc= X-Received: by 2002:a62:2bd0:0:b029:18a:df0f:dd61 with SMTP id r199-20020a622bd00000b029018adf0fdd61mr2168919pfr.19.1606293065179; Wed, 25 Nov 2020 00:31:05 -0800 (PST) MIME-Version: 1.0 References: <1606202474-8119-1-git-send-email-lirongqing@baidu.com> In-Reply-To: From: Magnus Karlsson Date: Wed, 25 Nov 2020 09:30:53 +0100 Message-ID: Subject: Re: [PATCH][V2] libbpf: add support for canceling cached_cons advance To: Daniel Borkmann Cc: Li RongQing , Network Development , bpf , "Karlsson, Magnus" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Tue, Nov 24, 2020 at 10:58 PM Daniel Borkmann wrote: > > On 11/24/20 9:12 AM, Magnus Karlsson wrote: > > On Tue, Nov 24, 2020 at 8:33 AM Li RongQing wrote: > >> > >> Add a new function for returning descriptors the user received > >> after an xsk_ring_cons__peek call. After the application has > >> gotten a number of descriptors from a ring, it might not be able > >> to or want to process them all for various reasons. Therefore, > >> it would be useful to have an interface for returning or > >> cancelling a number of them so that they are returned to the ring. > >> > >> This patch adds a new function called xsk_ring_cons__cancel that > >> performs this operation on nb descriptors counted from the end of > >> the batch of descriptors that was received through the peek call. > >> > >> Signed-off-by: Li RongQing > >> [ Magnus Karlsson: rewrote changelog ] > >> Cc: Magnus Karlsson > >> --- > >> diff with v1: fix the building, and rewrote changelog > >> > >> tools/lib/bpf/xsk.h | 6 ++++++ > >> 1 file changed, 6 insertions(+) > >> > >> diff --git a/tools/lib/bpf/xsk.h b/tools/lib/bpf/xsk.h > >> index 1069c46364ff..1719a327e5f9 100644 > >> --- a/tools/lib/bpf/xsk.h > >> +++ b/tools/lib/bpf/xsk.h > >> @@ -153,6 +153,12 @@ static inline size_t xsk_ring_cons__peek(struct xsk_ring_cons *cons, > >> return entries; > >> } > >> > >> +static inline void xsk_ring_cons__cancel(struct xsk_ring_cons *cons, > >> + size_t nb) > >> +{ > >> + cons->cached_cons -= nb; > >> +} > >> + > >> static inline void xsk_ring_cons__release(struct xsk_ring_cons *cons, size_t nb) > >> { > >> /* Make sure data has been read before indicating we are done > >> -- > >> 2.17.3 > > > > Thank you RongQing. > > > > Acked-by: Magnus Karlsson > > @Magnus: shouldn't the xsk_ring_cons__cancel() nb type be '__u32 nb' instead? All the other interfaces have size_t as the type for "nb". It is kind of weird as a __u32 would have made more sense, but cannot actually remember why I chose a size_t two years ago. But for consistency with the other interfaces, let us keep it a size_t for now. I will do some research around the reason. > Thanks, > Daniel