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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS 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 16D6BC43381 for ; Tue, 5 Mar 2019 09:53:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E72522082C for ; Tue, 5 Mar 2019 09:53:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727265AbfCEJxd convert rfc822-to-8bit (ORCPT ); Tue, 5 Mar 2019 04:53:33 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:41085 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726190AbfCEJxd (ORCPT ); Tue, 5 Mar 2019 04:53:33 -0500 Received: by mail-ed1-f65.google.com with SMTP id x7so6687096eds.8 for ; Tue, 05 Mar 2019 01:53:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=8bOdMDpKU7tNIvin/TGoU4s4X3LjyCCTPOGjl6eZ1kc=; b=TBA2ooCRNp/PKIZdcl+K3FiUeaP5FmQp+JARebTX4+qNU2Xwx4MaQll6ODcf68j5xZ 5RzuArMOg5tQr8G2VMIY1nqfYRTq+dI+b0IBWrbXcDGt34/hP4nb8sBUBBJkh0SaGVwL ym5r5VwDj6OQIBb2X6oUYhnA042/Aj1KpP3DNh+N/L4+UtHAntd1Yol0XkT59JkeHvns JtIDbooKiEe1THlzVBigMKElGZUE9aLfsJyEgPp/qdsDaKWz40erYEaHoRv8Ph9Hxaye qmENUr8Q3UX2rbjdMGqOspU8HsmWx/oTjvsFMlBdmUzP2iLWFvPAVKwzIvGIjf3/FcYu n+WA== X-Gm-Message-State: APjAAAW/tWFFtNBRLrm1etnCVI3vfEUH/XHq3sT9n4X5SorhjhvUYFMm QFAq1ZkvJ9TdytT+do2NsU10Ng== X-Google-Smtp-Source: APXvYqwxyW7aplhsui4Adl/+NcBpNNxA6F9PMJwoyuHiEnsVHItcioekwbEig5rvGH0ZPdr1wjyX4A== X-Received: by 2002:a17:906:49c3:: with SMTP id w3mr16019898ejv.148.1551779611626; Tue, 05 Mar 2019 01:53:31 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk (borgediget.toke.dk. [85.204.121.218]) by smtp.gmail.com with ESMTPSA id b10sm2805650edy.80.2019.03.05.01.53.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2019 01:53:30 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 810A6182F33; Tue, 5 Mar 2019 10:53:27 +0100 (CET) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Jakub Kicinski Cc: David Miller , netdev@vger.kernel.org, Jesper Dangaard Brouer , Daniel Borkmann , Alexei Starovoitov Subject: Re: [PATCH net-next v3 2/3] xdp: Always use a devmap for XDP_REDIRECT to a device In-Reply-To: <20190304144934.42cff55c@cakuba.netronome.com> References: <155144955030.28287.14029975169967438162.stgit@alrua-x1> <155144955045.28287.6187020206969282688.stgit@alrua-x1> <20190301180945.1152c6de@cakuba.netronome.com> <877edelukk.fsf@toke.dk> <20190304094452.375ba6e7@cakuba.netronome.com> <87fts231fp.fsf@toke.dk> <20190304141558.061824a7@cakuba.netronome.com> <877ede2s1t.fsf@toke.dk> <20190304144934.42cff55c@cakuba.netronome.com> X-Clacks-Overhead: GNU Terry Pratchett Date: Tue, 05 Mar 2019 10:53:27 +0100 Message-ID: <874l8h3aw8.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Jakub Kicinski writes: > On Mon, 04 Mar 2019 23:28:14 +0100, Toke Høiland-Jørgensen wrote: >> Jakub Kicinski writes: >> > On Mon, 04 Mar 2019 20:05:30 +0100, Toke Høiland-Jørgensen wrote: >> >> > Hm. I think you'll still need a lock (mutex?) on the alloc path, but >> >> > the free path should be fine as long as you load the map pointer before >> >> > looking at the refcnt (atomic op ensuring the barrier there). >> >> >> >> Yeah, for the per-namespace refcnt it's pretty straight forward, the >> >> trouble is the global count that needs to iterate over all namespaces; >> >> probably need to put that all behind a (non-spin)lock, right? >> > >> > Because net iteration is under RCU? You can switch to taking net_rwsem >> > for that one, no? I'm probably confused again ;) >> >> Because there's a single refcount that needs to trigger >> creation/deletion of *all* the default maps. I.e. >> >> if (atomic_dec_return(&global_refcnt)) >> for_each_namespace(net) >> destroy_default_map(net); >> >> which needs to not step on the toes of a subsequent >> >> if (atomic_inc_return(&global_refcnt) == 1) >> for_each_namespace(net) >> create_default_map(net); >> >> (or vice versa, of course). >> >> Not sure there's a way to do that without wrapping both of those >> constructs (including the refcnt inc/dec) in a mutex? > > Seems like it :( Right. Well I'm glad that we at least agree, so I can stop racking my brain for other ways to do it ;) -Toke