Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2743697imm; Mon, 16 Jul 2018 13:24:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf1B53IOK/lLrlyDYEgfImAMogS9fpIWZb6RMpZ4cbxmgdkAji6oQ12HtmVh50A8H2IeFy6 X-Received: by 2002:a62:ea05:: with SMTP id t5-v6mr5540869pfh.228.1531772654893; Mon, 16 Jul 2018 13:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531772654; cv=none; d=google.com; s=arc-20160816; b=wb/p6cl3MO4tmBjVqFep8I0u7FD81PrkpvIt9Z4KmQh3PNWJL/MI3bML06HqZLsP9U fd7D8R8W/m230Ddta4jB8rlyWv3cu5fhlhXXrnEBm5aMkb9eTSJNc8T+JyW0Ahxgo8sj HlmQ0d8QAjKv+Ckm1riB366CYVJmYLjHfit5IwSecVVqcByGu7kFmhyL3SsW5JhUpShO tSKWtiHP+3Z6jh4t7uOEOhFZEIbNj1yiZKMb8FjBy7no5H/ltAbaoi5fuCUxUP/Z2JyJ 1/4Y7dxiWmw5+cfr//1RM6OUHf8+kt0nG2xPGQm9wP7H9MF09vtoh1GzjqpWjk3dgJ46 QPpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=oi43PK/LlOA786hOlFC+fdGLLE5AMxk1PrN/1xxhqjo=; b=OX/4DZyqcfjaXZTntCA7wlqCqSlCRcVe7EZX+7VFSbk48pbX23bVMrAjHe6VSibH/Q 2obHggNY0MdDgKKNp434jBpcVloIRmbON54zks9Uw1bdUMrtxiN7x0RFXxwhcEQE9a7M imAxKIwsbFThbHC2h67wv/gEFNSQ2xj6usAsK/sHQpGVDIDKwdfB2NsE4BQk1eLXeTFq IwNh40k5GboD+8w5GyIQmMiqdDD8yVeO24XfBVYVIzkzuT6YOiF81PS/1jT119bhoqzA BCFQPlgHMTKVkwWiHKUncCPztnPyC74/ySWA47coJGBcNxh1N5bZpIgVVo4b2fuliXYd 5Qag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=XdSlctQS; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w37-v6si30476219pgl.514.2018.07.16.13.24.00; Mon, 16 Jul 2018 13:24:14 -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=@joelfernandes.org header.s=google header.b=XdSlctQS; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729946AbeGPUwE (ORCPT + 99 others); Mon, 16 Jul 2018 16:52:04 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:37480 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729350AbeGPUwE (ORCPT ); Mon, 16 Jul 2018 16:52:04 -0400 Received: by mail-pg1-f195.google.com with SMTP id n7-v6so1069265pgq.4 for ; Mon, 16 Jul 2018 13:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=oi43PK/LlOA786hOlFC+fdGLLE5AMxk1PrN/1xxhqjo=; b=XdSlctQSAsTO1Kw3q1PF7uvXKjceEkzkyrohixDDWMsZNgqUXsZH9UOgmaEQyr/Khk j3RbmYWKlwl0QE4fhfqBfNYZNBetegoUedzJg1Up8jM0Oc78kpTNlPZgclXsriCYeTyv qdeIQZqTHabonATD+Mv+mpaZ8HmUVU4Ef1yXA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=oi43PK/LlOA786hOlFC+fdGLLE5AMxk1PrN/1xxhqjo=; b=Jz7pSOQb2j67Woqjbm22qD+cE9D6Cs1a8SmqwH/7LM/Ct5tAB8SpAMeQ6dtzp+Uagg h6sYy7HRH2EBkjZgUuy2QB0peyx1O7bjjDdXRnxK91kqVvxga9jUsQHFb/c23Ur+62on r9/GhyjHljuCEEqvostp/Y3uEyPGQ5JPw9R/gi8Yp5hnGwW4tCsx2xIxmI6n1NpMRdTf dFaQyuaP2LRTUQNwjPRwR1/GjOB0K4m+iZTgare7aGRikbojHBZNQDrO06lLerSzby+r miZeu/ciNc0lxTxNprO6FV2+3NIQ5AIj1ndua0Agx1rP2wJePRFsIZo8RECuGaSOvsf8 cCAg== X-Gm-Message-State: AOUpUlH6jgRLsVqiHLHBbvKPhe+BTg8kDYiWRfEWdMrEiL/cmtREZjnm b/qj2R1TWGQj0M11CpFjS6PbIg== X-Received: by 2002:a63:d613:: with SMTP id q19-v6mr16656966pgg.327.1531772582858; Mon, 16 Jul 2018 13:23:02 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id s27-v6sm41475920pfk.133.2018.07.16.13.23.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 13:23:02 -0700 (PDT) Date: Mon, 16 Jul 2018 13:23:01 -0700 From: Joel Fernandes To: Daniel Colascione Cc: Alexei Starovoitov , Lorenzo Colitti , Chenbo Feng , Mathieu Desnoyers , Joel Fernandes , Alexei Starovoitov , lkml , Tim Murray , Daniel Borkmann , netdev Subject: Re: [RFC] Add BPF_SYNCHRONIZE bpf(2) command Message-ID: <20180716202301.GB160902@joelaf.mtv.corp.google.com> References: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 16, 2018 at 08:29:47AM -0700, Daniel Colascione wrote: > 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? Do you mean the changelog? Yes I believe you could use the discussion in this thread for the rationale as Alexei described. thanks, - Joel