Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10675304ybi; Thu, 25 Jul 2019 03:27:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/QWt7/M7tpT8zsbF9Cp2howGOmAxn2b3FB1oU2Icc4VTOdnE8jRsOHy9wvLCUWFMJGuSX X-Received: by 2002:a63:b747:: with SMTP id w7mr32494230pgt.205.1564050452110; Thu, 25 Jul 2019 03:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564050452; cv=none; d=google.com; s=arc-20160816; b=RqkD+gN5tHxH4S23VR1RDTH5AIhu77eN7N/+gEFxTYb+ORpCFzIpGL5RMlDTjiBM4Z 3Tby5yxV5qaTRhc39lTFt8rAoMWhN6qbSCwn2kZKJweuxxY9DdcrS4reURA5hMcGYu2p 39Eu6Bf2tL0xM7WNgAR2MpKujF+YZPyevCb+78RmfSOXalrL1bqEqAA4bGHdqNPKpWGt XwLsJbmX9O+y6LBtyDXyguutymdV8rk0PfbntvqtOX9CyBp+CPmG2wRtge6eR//4K6fl 0NAp+ACk3sbVwcmNUGSrURdFDz3SnzD67LHUXewA6qrFaXHF/2uEtoDK2arB8ENYuhWV KKRA== 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 :in-reply-to:references:mime-version:dkim-signature; bh=UBF6bNBt/PemNw217in5S9v8lFOv59SFC9xNcgdoU6Y=; b=AupHzS6ro/hRtsi0HChd9hyw6esWFLYkc36B8uZNBm7luopuGiwlAR61guyS1VqLcV D2JhSDzywtZwQvHv2h3U9HN7A+ShtEyk2mzNc9Xwy7W9jrhEpP0RLb6V1mGnEfWE2H0G KJturOggsy4LNwKsgbwMEwmjsqA5q5/55G+54JTEDvc7n2W0dz2wUjKXfYTQtUQk/znG FmFeG1wolChJ/7jfiWpnsPJIdVIio4xDrPMoUbMmp8AYn91Hdxdx25aYZax3dI6mk0gE WGRAUEyOmX8Nx9cBepCgdb9RT00k0btxc2s54WGp8Pzcl543x5TL1bGIVn5Mi9bmMHJi 1mfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=s+uv8qpF; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7si10781997pgk.377.2019.07.25.03.27.15; Thu, 25 Jul 2019 03:27:32 -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=@gmail.com header.s=20161025 header.b=s+uv8qpF; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728392AbfGXWP5 (ORCPT + 99 others); Wed, 24 Jul 2019 18:15:57 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:36445 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726645AbfGXWP5 (ORCPT ); Wed, 24 Jul 2019 18:15:57 -0400 Received: by mail-lj1-f194.google.com with SMTP id i21so46033965ljj.3; Wed, 24 Jul 2019 15:15:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UBF6bNBt/PemNw217in5S9v8lFOv59SFC9xNcgdoU6Y=; b=s+uv8qpFxE+t54WGQJxNv5PYL7LjIriR64oc1BJyj1009oNYg6lzg+rMYzQQOCEQ/4 QMO4FRyZCOuroPUbx/6MBgHUdMdnEQwtfxh2xCc2q4kRbiUdpUyvMegZrChhGGNgJUAy Avf8nJfUygtP6hrUCLBQbNyAPWmEHblYOzgfDrxZOYT4sb7wUIbwDdogK+r6+C7bntd1 +4WqbjfwD6gUnOOpW6Dx9tKsZJRXETh89NSOLtFpz6P4uu6xdSRhH1vM8s0lTRrSfEjw GorBm5VsmBWs/7Jx2ZCSLyDT5+kidDNLZJ2dWq9ruL3lc9uDai+Qh4U0qR+mrnSPTidp qRfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UBF6bNBt/PemNw217in5S9v8lFOv59SFC9xNcgdoU6Y=; b=fUGyCmD8sMc7BsJPqMr1azO6Hv/2CBZ0CGdOKUeys9APJZBHraNOk1H5mWgFieXks9 M9O8YAaS0WtjcoZISEEKTKHLd3dPAFF+M+Csq+/9w03roWcJeaOoJkRaGExL5aM+nGo8 J2RgQR+UWcuNre9PAoFPLZKZPoayfKc/qYnVEDJD5wdjCqyt404IFz+Zrn38E1SJ3Ilj gLafZRl4rwCIizadG/5PabG7gs5ex1okVSZqjcl15up/9IjjaAPSvlw20ghgYQaQyx4r yZFX7iQb24eDwlC9hKrRdk6L7Ay+jrlh4B/GqfAR5P6FL/Sfio9OWRCE3Vojw5TJ0gDT 6IIA== X-Gm-Message-State: APjAAAXPaesB7+s8PpzShWpa6Xr4H84lwzIKA8DoQJRLeqop+Vv4Xr9/ 2yepAZmDetNvoW49A/X5K9/L8HnN+tUIBKnSJRs= X-Received: by 2002:a2e:9a82:: with SMTP id p2mr45445949lji.64.1564006555385; Wed, 24 Jul 2019 15:15:55 -0700 (PDT) MIME-Version: 1.0 References: <20190724165803.87470-1-brianvv@google.com> In-Reply-To: From: Brian Vazquez Date: Wed, 24 Jul 2019 15:15:44 -0700 Message-ID: Subject: Re: [PATCH bpf-next 0/6] bpf: add BPF_MAP_DUMP command to dump more than one entry per call To: Song Liu Cc: Brian Vazquez , Alexei Starovoitov , Daniel Borkmann , "David S . Miller" , Stanislav Fomichev , Willem de Bruijn , Petar Penkov , open list , Networking , bpf 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 Wed, Jul 24, 2019 at 12:20 PM Song Liu wrote: > > On Wed, Jul 24, 2019 at 10:09 AM Brian Vazquez wrote: > > > > This introduces a new command to retrieve multiple number of entries > > from a bpf map. > > > > This new command can be executed from the existing BPF syscall as > > follows: > > > > err = bpf(BPF_MAP_DUMP, union bpf_attr *attr, u32 size) > > using attr->dump.map_fd, attr->dump.prev_key, attr->dump.buf, > > attr->dump.buf_len > > returns zero or negative error, and populates buf and buf_len on > > succees > > > > This implementation is wrapping the existing bpf methods: > > map_get_next_key and map_lookup_elem > > > > Note that this implementation can be extended later to do dump and > > delete by extending map_lookup_and_delete_elem (currently it only works > > for bpf queue/stack maps) and either use a new flag in map_dump or a new > > command map_dump_and_delete. > > > > Results show that even with a 1-elem_size buffer, it runs ~40 faster > > Why is the new command 40% faster with 1-elem_size buffer? The test is using a really simple map structure: uint64_t key,val. Which makes the lookup_elem logic faster since it doesn't spend too much time copying the value. My conclusion with the 40% was that this new implementation only needs 1 syscall per elem compare to the 2 syscalls that we needed with previous implementation so in this particular case the number of ops that we are doing is almost halved. I did one experiment increasing the value_size (448*64B) and it was only 14% faster with 1-elem_size buffer. > > than the current implementation, improvements of ~85% are reported when > > the buffer size is increased, although, after the buffer size is around > > 5% of the total number of entries there's no huge difference in > > increasing it. > > > > Tested: > > Tried different size buffers to handle case where the bulk is bigger, or > > the elements to retrieve are less than the existing ones, all runs read > > a map of 100K entries. Below are the results(in ns) from the different > > runs: > > > > buf_len_1: 69038725 entry-by-entry: 112384424 improvement > > 38.569134 > > buf_len_2: 40897447 entry-by-entry: 111030546 improvement > > 63.165590 > > buf_len_230: 13652714 entry-by-entry: 111694058 improvement > > 87.776687 > > buf_len_5000: 13576271 entry-by-entry: 111101169 improvement > > 87.780263 > > buf_len_73000: 14694343 entry-by-entry: 111740162 improvement > > 86.849542 > > buf_len_100000: 13745969 entry-by-entry: 114151991 improvement > > 87.958187 > > buf_len_234567: 14329834 entry-by-entry: 114427589 improvement > > 87.476941 > > It took me a while to figure out the meaning of 87.476941. It is probably > a good idea to say 87.5% instead. right, will change it in next version.