Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2468621imm; Mon, 16 Jul 2018 08:30:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfB0bficuUPHWVHn2jSjmzV0PgNOImnZzLEKWifWrczVqtfw5oZdEdEtZOSY/v89HKsO8wa X-Received: by 2002:a65:64c8:: with SMTP id t8-v6mr15813474pgv.110.1531755058272; Mon, 16 Jul 2018 08:30:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531755058; cv=none; d=google.com; s=arc-20160816; b=cgWKh/kmmDzHEK3vC1w4hkk5rxhw5YrS/5TFBsixC9Iw5tP0LGi13zFP69RbR6uPBs iaQqLpVDxjBcL4PnV2TzQtVTb6lOCTy5+RsnYfC8JYoDtFyr4ek4soc2U+5ppsCz5qi2 zEJja8fR3sw4dXXzGX7ejENST0VuVsCUW/VMIOUz/thu3BWfyedyD49Nx+j97+8GVoq5 KnQ4usmzLqzx2yb4EBru4djnKKDfg9PvCHXRihyr+6A6WOKjSqEVDI2zY0Ng6Iw+WR/z Z3UyBddIPrQ2uFPTAtzklhvqG5MxkBaSFfhO1JqrslcyCvN9ANDZKyCx5OKz3sRdsAIJ FPiA== 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=zIenD44khob/6JStWiqv5fGyAtotdvdBsyMlyX7RnNY=; b=Y/QVuFRV1h8TYcxVv6+F0B9T8iXUlKEIE8Uj7PYyu+2+JAAzVsoidskMe0DG6VC/t0 b+JvCJfsgl127jZFgyC34Fm/HZAaN96lVH6/qen2AAKXv1eW+sKAYNTwBt4WvEFQkmcN MY73CytVvENqj87fkYZX5VNHqGh4cfDuKmsY5OIqVRAM7eNWccYcl5xhIU5UMh324zcH fx7JCn+rDjeAVWxLuf1ccR9BKyOdUgkhyWpdQGNd7UvK7VYVjfhQDMu2H+hjWCNcDzdl bvKUh3SuN+vRHUPrtECMtipu/ejpSx08+XnIHvAcyJHLii3qJdWujqiqDsllECJhVjFy VJKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=F3ildcLq; 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 g16-v6si10406803pgk.465.2018.07.16.08.30.40; Mon, 16 Jul 2018 08:30:58 -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=F3ildcLq; 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 S1729840AbeGPP5q (ORCPT + 99 others); Mon, 16 Jul 2018 11:57:46 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:37482 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727610AbeGPP5o (ORCPT ); Mon, 16 Jul 2018 11:57:44 -0400 Received: by mail-it0-f67.google.com with SMTP id p17-v6so21951207itc.2 for ; Mon, 16 Jul 2018 08:29:48 -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=zIenD44khob/6JStWiqv5fGyAtotdvdBsyMlyX7RnNY=; b=F3ildcLqUk7r2C0OF/vmYIUd7OQVZLIaznrWdvNSoHsAwfzTFDpEQa6pXFz7jQ7JNp QfRfPgWNTYC9CK7vs1zKXzkhjwCIqb5GfM6laRP1YuziQyy473rgAjlv7mIglbjqGTbn DM1f6ouQqN9fbgdRaZO3c+EPwRaKDzKb4qRm0jbUr91rjBRklEU3Pb55K6aHPinHo+7s 2bC42kp7kOht6MrRqNjrZyaxTKweVhKx+WymVlZGsJgfWbHTUPNCxy8paS74Q2gdroPC ss9EK5Tv/TIkM+FuTjH6zJxh7tSi7PCjC7U4G0PFOZ8R8CwpiNnQSo4T7lhNnRghx24e QS1Q== 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=zIenD44khob/6JStWiqv5fGyAtotdvdBsyMlyX7RnNY=; b=QQUj7zYNpS3QE6kFVvc1do6rf5fC3WsWIafDnvcPmuYC+2hcDI8KSnq6icUqwtaxVl 5PRkLRRA7xRWD51tL3T3SlLuf30BheD1k315zScpMQp0iNnMvZEtkaFR2VZnVYKMD5sj A16J3r7sJfxcIN8MBR4HHaXsAlYp8PAlt2sgnE2KF3OdF7noMR4VYnFU/4GKGkSPBhM7 Wj27r/zWw+Q1VSEMT0dQW4AcDCA4wGhnyulcTSkuMu+TLUmqYkLI4hmmauKwD9Vc8zYz PL6PG7aNuJUWpV3fn6/AZouvMvjIQRnd/ggavG5++vjcsJVix1p2Og6vxkCx8L8hwmgG I1fw== X-Gm-Message-State: AOUpUlG9k/wjMFiDWdfPH96fleXm4F09E7BowZh6T2THDMUD3ItQtzLN g5v5MBSmvoOYYa12drKfqH4MRjX1ZhXfocRFNvikxQ== X-Received: by 2002:a24:130c:: with SMTP id 12-v6mr13601410itz.35.1531754988095; Mon, 16 Jul 2018 08:29:48 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:ba01:0:0:0:0:0 with HTTP; Mon, 16 Jul 2018 08:29:47 -0700 (PDT) In-Reply-To: <20180714181815.GA199777@joelaf.mtv.corp.google.com> References: <951478560.1636.1531083278064.JavaMail.zimbra@efficios.com> <20180709210944.quulirpmv3ydytk7@ast-mbp.dhcp.thefacebook.com> <20180709221005.sintsjkle4xpkcyk@ast-mbp.dhcp.thefacebook.com> <20180709223439.uc2a6hyic35inwye@ast-mbp.dhcp.thefacebook.com> <20180710235252.mioihpgtu4n3syaq@ast-mbp.dhcp.thefacebook.com> <20180711034017.o2ehf27tv5hpl3td@ast-mbp.dhcp.thefacebook.com> <20180714181815.GA199777@joelaf.mtv.corp.google.com> From: Daniel Colascione Date: Mon, 16 Jul 2018 08:29:47 -0700 Message-ID: Subject: Re: [RFC] Add BPF_SYNCHRONIZE bpf(2) command To: Joel Fernandes Cc: Alexei Starovoitov , Lorenzo Colitti , Chenbo Feng , Mathieu Desnoyers , Joel Fernandes , Alexei Starovoitov , lkml , Tim Murray , Daniel Borkmann , netdev 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 Sat, Jul 14, 2018 at 11:18 AM, Joel Fernandes wrote: > On Tue, Jul 10, 2018 at 08:40:19PM -0700, Alexei Starovoitov wrote: > [..] >> > The kernel program might do: >> > >> > ===== >> > const int current_map_key = 1; >> > void *current_map = bpf_map_lookup_elem(outer_map, ¤t_map_key); >> > >> > int stats_key = 42; >> > uint64_t *stats_value = bpf_map_lookup_elem(current_map, &stats_key); >> > __sync_fetch_and_add(&stats_value, 1); >> > ===== >> > >> > If a userspace does: >> > >> > 1. Write new fd to outer_map[1]. >> > 2. Call BPF_SYNC_MAP_ACCESS. >> > 3. Start deleting everything in the old map. >> > >> > How can we guarantee that the __sync_fetch_and_add will not add to the >> > old map? >> >> without any changes to the kernel sys_membarrier will work. >> And that's what folks use already. >> BPF_SYNC_MAP_ACCESS implemented via synchronize_rcu() will work >> as well whether in the current implementation where rcu_lock/unlock >> is done outside of the program and in the future when >> rcu_lock/unlock are called by the program itself. > > Cool Alexei and Lorenzo, sounds great to me. Daniel want to send a follow up > patch with BPF_SYNC_MAP_ACCESS changes then? Will do. Mind if I just mine this thread for the doc comment?