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=-3.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 CD35CC433E1 for ; Tue, 16 Jun 2020 09:04:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACEFE2074D for ; Tue, 16 Jun 2020 09:04:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hB+PqTy9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725710AbgFPJEY (ORCPT ); Tue, 16 Jun 2020 05:04:24 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:40156 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725896AbgFPJEX (ORCPT ); Tue, 16 Jun 2020 05:04:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592298262; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ka0//B8iqVe7XF0DH1uWb/HCvgCVFTO+HcSeWwz6I0c=; b=hB+PqTy9Dfc/BD+3GhRQ2XdIowAZPtVSd9bKvO0TqQGlYsCO8RvPWmKhQI2PGV3hZHvtBw sCX3+PrTVEK+x57zvHwjumwC1ddNiggWLqDrbwKnpvZJqkcieSw5XJ8MJSg/vCzXOA2w/s HSWLuY5mAzhyzfy2ZwgSQma9PD7//6U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-341-eTzddpHJOjmIAzN8h4b-kw-1; Tue, 16 Jun 2020 05:04:18 -0400 X-MC-Unique: eTzddpHJOjmIAzN8h4b-kw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 29C1E100961D; Tue, 16 Jun 2020 09:04:17 +0000 (UTC) Received: from carbon (unknown [10.40.208.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 995B319D71; Tue, 16 Jun 2020 09:04:05 +0000 (UTC) Date: Tue, 16 Jun 2020 11:04:04 +0200 From: Jesper Dangaard Brouer To: Toke =?UTF-8?B?SMO4aWxhbmQtSsO4cmdlbnNlbg==?= Cc: Hangbin Liu , bpf@vger.kernel.org, netdev@vger.kernel.org, Jiri Benc , Eelco Chaudron , ast@kernel.org, Daniel Borkmann , Lorenzo Bianconi , brouer@redhat.com Subject: Re: [PATCHv4 bpf-next 1/2] xdp: add a new helper for dev map multicast support Message-ID: <20200616110404.27149171@carbon> In-Reply-To: <87d0678b8w.fsf@toke.dk> References: <20200415085437.23028-1-liuhangbin@gmail.com> <20200526140539.4103528-1-liuhangbin@gmail.com> <20200526140539.4103528-2-liuhangbin@gmail.com> <20200610122153.76d30e37@carbon> <87d0678b8w.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Wed, 10 Jun 2020 12:29:35 +0200 Toke H=C3=B8iland-J=C3=B8rgensen wrote: > Jesper Dangaard Brouer writes: >=20 > > On Tue, 26 May 2020 22:05:38 +0800 > > Hangbin Liu wrote: > > =20 > >> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c > >> index a51d9fb7a359..ecc5c44a5bab 100644 > >> --- a/kernel/bpf/devmap.c > >> +++ b/kernel/bpf/devmap.c =20 > > [...] > > =20 > >> +int dev_map_enqueue_multi(struct xdp_buff *xdp, struct net_device *de= v_rx, > >> + struct bpf_map *map, struct bpf_map *ex_map, > >> + bool exclude_ingress) > >> +{ [...] > >> + if (!first) { > >> + nxdpf =3D xdpf_clone(xdpf); > >> + if (unlikely(!nxdpf)) > >> + return -ENOMEM; > >> + > >> + bq_enqueue(dev, nxdpf, dev_rx); > >> + } else { > >> + bq_enqueue(dev, xdpf, dev_rx); =20 > > > > This looks racy. You enqueue the original frame, and then later > > xdpf_clone it. The original frame might have been freed at that > > point. =20 >=20 > This was actually my suggestion; on the assumption that bq_enqueue() > just puts the frame on a list that won't be flushed until we exit the > NAPI loop. >=20 > But I guess now that you mention it that bq_enqueue() may flush the > queue, so you're right that this won't work. Sorry about that, Hangbin :/ >=20 > Jesper, the reason I suggested this was to avoid an "extra" copy (i.e., > if we have two destinations, ideally we should only clone once instead > of twice). Got any clever ideas for a safe way to achieve this? :) Maybe you/we could avoid the clone on the last destination? --=20 Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer