Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp42414imm; Tue, 14 Aug 2018 13:39:37 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxRkCVrli/MzWHoJjn9aA2Hxy54bvZl/eW1uMHV8AbTW+/t1+diw1br+NxuQVvz1zDP1WMT X-Received: by 2002:a63:e001:: with SMTP id e1-v6mr19851465pgh.380.1534279177735; Tue, 14 Aug 2018 13:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534279177; cv=none; d=google.com; s=arc-20160816; b=d34HqQgo2Kp8W5gfGtKSazorbu+c+7ArWAJjifLJPw3SLUQUWyextowQewlHedHkNl 4+anGBKD5gx8MTZxfCOgmCctWMjfL73aoVCHHcfVzbpUPZ493zTHyOwXCQghmw6IIViE gnKGRfulLiqp9+0AIQHuTf5lnovPDj9j+OMT6R+o6aX4RdC2nGr54rmDbrpOZ1W0U/sN 2NmkQxFdsr/HVdJzkezBgHp5cQ5Jcw6HXjQzT2hWejnfRHEMBiMrbIifW1PfRCZtcLk1 lzbzZ+oX6Nf+64ivOw+WdWfLs4Da+6J+GT/FP9GIJOUI2Ou34HudoYGPyBIoVvA+bsM8 dMcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=aeEMnJx+uI+EpPSjRM7zCv3uaeUzXJ9j3MIMcn/Wt/U=; b=O7Q0E+zYYIXimZq4ohQrUHd+x0GrYAC04AnOwMQUxiVtJhelKtU9U1+wgB3hO1Hugj H9zAsW//JXGZMbAjE+wxVxtGM2r2bfbQ7ttQ4bJWMWafw3TA+gFf1tA9VEMW+6JhFSTT jp2qvbZ+bhJ/78cKYkK4NEKTpIPe3a2sNGbHic8CjSRDSS5xfTs9EX5/6digIV0Ul+Fc 40C0vkXlN9JfIbTX6W8EfUD54aBLwYFR0l5aX55tL/rB7cjxzR3h70liOocBJ099Uk/c ogvfQsqb5/594Pq5XzODArDJiJ1K6UxU7CuDmtFADqGPuawXBJF8teNH+0E5HUqTteMc /SKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fcCFwxla; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n61-v6si17111829plb.132.2018.08.14.13.39.20; Tue, 14 Aug 2018 13:39:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fcCFwxla; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729014AbeHNX0I (ORCPT + 99 others); Tue, 14 Aug 2018 19:26:08 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:37752 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728270AbeHNX0I (ORCPT ); Tue, 14 Aug 2018 19:26:08 -0400 Received: by mail-io0-f196.google.com with SMTP id z19-v6so19638988ioh.4 for ; Tue, 14 Aug 2018 13:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=aeEMnJx+uI+EpPSjRM7zCv3uaeUzXJ9j3MIMcn/Wt/U=; b=fcCFwxlamSrMaYIQZof2svsrgyXqBSwCMyHKwUiKBeCf1OPENgTbQIQinX4DV5vHRe kUpaZmDQ0AK2Pz2JWosJXElbs1Dw9neoS67tJ521aHj1OD7AOssQ2Sn2tG2FyzCY6GHd 7aUBJD1OSH4+GXpWcgNEpuQOzPUd67o3ags6INMAaF5oXugJkQ7HDNiWGFfiW0uTAwk6 tBzonCNPHz3+8BkA2B+beSnSuUrO3dikCbPQhSgIclBbuhMirzSm0iGAyTPecFHQ1jOS Kd7F2uVSB/m2uWf/biqcERzKi7wg2wAed7Pxk1Vr0AsbVXKIjltseKNbUE2KJSDxwpmy hLSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=aeEMnJx+uI+EpPSjRM7zCv3uaeUzXJ9j3MIMcn/Wt/U=; b=Dss9QwVC5uBo4SO7/BES41p7X6dEJi8LygDAkJhpFeu1nmPl9h2JEOCnZcCaQyg1JF lxK7Mxelq1uRgkmeX+Degwt9ItFfyubN09MEt9WdnGHCK5OvWaonPYmLVmv6LnBPPrab iyL5UTOkQggDb6kMRFCItPZl2iNwIZo4hSVsNpQBJWMLSk5xddDpTmlOUVBkGZeFEort wISpQvaHXkL5BuYMWBfpB8kMbBg1Jz5HAB0P8doMUlXEklB42SyEBZsFkyUY8G9IJyg3 dStFDItvfth8ACDVOGz2oOwcItOTgYjTgGUm2DogWJMccF0LEO+Iaelq0mjv/fkVOOSQ gxjQ== X-Gm-Message-State: AOUpUlG5Xhr6nfaK7Es+mUuIEEy0llr8V+nklMTMjzr8mebhjmvqEKvs dpMGqzFwzGlUZDu5c72OOM8X23aRWBnBhphkV5vPWA== X-Received: by 2002:a6b:8f4e:: with SMTP id r75-v6mr20603469iod.252.1534279033821; Tue, 14 Aug 2018 13:37:13 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:ba01:0:0:0:0:0 with HTTP; Tue, 14 Aug 2018 13:37:12 -0700 (PDT) In-Reply-To: <20180810225246.3d3pa5qvbtoh42bt@ast-mbp.dhcp.thefacebook.com> References: <20180729205835.34850-1-dancol@google.com> <20180730172641.7d516231@cakuba.netronome.com> <67423232-be56-fd47-06e6-394812c2b918@iogearbox.net> <20180810225246.3d3pa5qvbtoh42bt@ast-mbp.dhcp.thefacebook.com> From: Daniel Colascione Date: Tue, 14 Aug 2018 13:37:12 -0700 Message-ID: Subject: Re: [PATCH v3] Add BPF_SYNCHRONIZE_MAP_TO_MAP_REFERENCES bpf(2) command To: Alexei Starovoitov Cc: Daniel Borkmann , Jakub Kicinski , Joel Fernandes , linux-kernel , Tim Murray , netdev , Lorenzo Colitti , Chenbo Feng , Mathieu Desnoyers , Alexei Starovoitov Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 10, 2018 at 3:52 PM, Alexei Starovoitov wrote: > On Tue, Jul 31, 2018 at 02:36:39AM -0700, Daniel Colascione wrote: >> >> > An API command name >> > such as BPF_SYNCHRONIZE_MAP_TO_MAP_REFERENCES is simply non-generic, and >> > exposes specific map details (here: map-in-map) into the UAPI whereas it >> > should reside within a specific implementation instead similar to other ops >> > we have for maps. >> >> But synchronize isn't conceptually a command that applies to a >> specific map. It waits on all references. Did you address my point >> about your proposed map-specific interface requiring redundant >> synchronize_rcu calls in the case where we swap multiple maps and want >> to wait for all the references to drain? Under my proposal, you'd just >> BPF_SYNCHRONIZE_WHATEVER and call schedule_rcu once. Under your >> proposal, we'd make it a per-map operation, so we'd issue one >> synchronize_rcu per map. > > optimizing for multi-map sync sounds like premature optimization. Maybe, but the per-map proposal is less efficient *and* more complicated! I don't want to spend more code just to go slower. > I believe the only issue being discussed is user space doesn't know > when it's ok to start draining the inner map when it was replaced > by bpf_map_update syscall command with another map, right? Yes. > If we agree on that, should bpf_map_update handle it then? > Wouldn't it be much easier to understand and use from user pov? > No new commands to learn. map_update syscall replaced the map > and old map is no longer accessed by the program via this given map-in-map. Maybe with a new BPF_SYNCHRONIZE flag for BPF_MAP_UPDATE_ELEM and BPF_MAP_DELETE_ELEM. Otherwise, it seems wrong to make every user of these commands pay for synchronization that only a few will need. > But if the replaced map is used directly or it sits in some other > map-in-map slot the progs can still access it. > > My issue with DanielC SYNC cmd that it exposes implementation details What implementation details? The command semantics are defined entirely in terms of existing user-visible primitives. > and introduces complex 'synchronization' semantics. To majority of > the users it won't be obvious what is being synchronized. > > My issue with DanielB WAIT_REF map_fd cmd that it needs to wait for all refs > to this map to be dropped. I think combination of usercnt and refcnt > can answer that, but feels dangerous to sleep potentially forever > in a syscall until all prog->map references are gone, though such > cmd is useful beyond map-in-map use case. In what scenarios? In any case, can we submit _something_?