Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752220AbaKDXO6 (ORCPT ); Tue, 4 Nov 2014 18:14:58 -0500 Received: from mail-wg0-f49.google.com ([74.125.82.49]:57868 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751562AbaKDXO4 (ORCPT ); Tue, 4 Nov 2014 18:14:56 -0500 MIME-Version: 1.0 In-Reply-To: <5458A349.5020401@redhat.com> References: <1415069656-14138-1-git-send-email-ast@plumgrid.com> <1415069656-14138-4-git-send-email-ast@plumgrid.com> <5458A349.5020401@redhat.com> Date: Tue, 4 Nov 2014 15:14:55 -0800 Message-ID: Subject: Re: [PATCH net-next 3/7] bpf: add array type of eBPF maps From: Alexei Starovoitov To: Daniel Borkmann Cc: "David S. Miller" , Ingo Molnar , Andy Lutomirski , Hannes Frederic Sowa , Eric Dumazet , Linux API , Network Development , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 4, 2014 at 1:58 AM, Daniel Borkmann wrote: >> + >> + memcpy(array->value + array->elem_size * index, value, >> array->elem_size); > > What would protect this from concurrent updates? nothing. that's what I meant in commit log: - map_update_elem() replaces elements in an non-atomic way (for atomic updates hashtable type should be used instead) The array map is like C array of structures. Nothing protects concurrent access. It's used in the cases where accuracy is not needed or when there is no concurrent access. To compute a histogram of events in tracing the array of integers is used. Every integer is a counter. Program increments it (may be without using xadd) and user space periodically reads it back. map_update_elem() is called by userspace once to initialize it if zero-init is not enough. Programs do lookup() and modify the values. For array type update() method is used rarely, delete() is never used and get_next() is needed for completeness to browse maps through common map API. I'm guessing you're asking, because it may feel that adding a lock() will help to make it more useful? ;) It's not, since programs cannot take a lock(). -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/