Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9927383ybi; Wed, 24 Jul 2019 12:28:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTnsDr0Q1XsV+UcUKpPhp8as1BF2+9hcQtbtK0/wBDC3z2x/LkrnINRC3gy9kUxTSRmIGt X-Received: by 2002:aa7:8804:: with SMTP id c4mr12751936pfo.65.1563996519808; Wed, 24 Jul 2019 12:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563996519; cv=none; d=google.com; s=arc-20160816; b=b2bgl79BUmZkBHuIsbtFDSgbXkQQo3F+JP6OIEYmejAgTKYQ1PfcrPUd/AdjVsvUrk i6R/SZd5GUOtDw6CrmjV59+xjGKlMHrRhBiqCcMQLu8t4f+fC8rEJHXiAl9Zgu3lJE3O 4MyaNBXrIx3F3wPYmu1gq9uHo+v+kJxXohgWijTcB/rIpKRun+nsC+brSGwlnP+Ek/le 0xnYz+9VPIfks6qMOpzFX4niT+eb7Xrb76urMK/murE4/jZgGSWXhrQL+N9zJ8nZRBgN QKzbwrfTBWnU3MrnlAmQOGQ36I1XT6JcCGCOCvSBoH/aDN5D8ZtOE+yGe5jE17g26V3W tERg== 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=Jf56Nz05DOfwnERFUQkN8u7zsx4IFXTKejoTcl/rv6g=; b=XGng/hTTwo3OD458KUQIbSPf4Jc+0Esk5VvNrwjc2JN+etMYdZ8DXo/ov60KCqUHxN d961iHs/BTgzD/oC0a1bSK3/nhDyaMLgN4Ax98a0xL1VNbMcKIRoL02sBFDXOvq0Urag m2IUJ+j86YNgTSdRgSn5S8YhW7MTTqPUH0xshgWxgBQbcCbQNhS2aRuM9gPd46y7eJ2K k3N4z1RT9noWL8JpVGxbB7qX0n+fohCr+3m1Ic1B9S02XWOs2jfuycFaalfPZmgxVdNv rvxxUi1f5gPsEoBI97mCVj/xv368H2TxumlhwzwP+qpvGrHrHC6BUbymD4Hq1Txq5OEw bQwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kRCjPwpl; 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 p4si14727624pgh.350.2019.07.24.12.28.25; Wed, 24 Jul 2019 12:28:39 -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=kRCjPwpl; 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 S1727342AbfGXTUQ (ORCPT + 99 others); Wed, 24 Jul 2019 15:20:16 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:44607 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725826AbfGXTUQ (ORCPT ); Wed, 24 Jul 2019 15:20:16 -0400 Received: by mail-qk1-f195.google.com with SMTP id d79so34572559qke.11; Wed, 24 Jul 2019 12:20:15 -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=Jf56Nz05DOfwnERFUQkN8u7zsx4IFXTKejoTcl/rv6g=; b=kRCjPwpl3KV5JZ+jG9MW4RJlkRN421VxJjYbdreISYCOhxnOSwdD3ALzdA46vTmRly b7nqIstNMJQ8CAU19gYGlCqHwmsvkmk1UjR7qooCEt4iAV10ShQ0azpC72pD39vNnuyw 5afkxEf2fctjRwkGzb7B1lKceftIqafcwVp1PR7d4PYfUGHL6zbknxbTJ1u+/fugQQQO S2R41s1q5jD1aKjbRJZoPherbeKwf4gyxVXnNxa5E6CyqtACUL4DLzQP6rWZiJ5W+UiS cdZ3IoAO7d2aR5yy0LtprKyxfFDvJvIoqAOBoX+h6zc0t3KdqN9/AXbhVBLEdJSakywZ sYhA== 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=Jf56Nz05DOfwnERFUQkN8u7zsx4IFXTKejoTcl/rv6g=; b=nYv/2C/FAZbQ9UysrJ366yOSvWKuqog3yU3yb8IzEEGRVJ/WmYQrPvfaFchK4bn8Yp l513bnQnyocfcLWOINoSXj58ViRT6AD7Z9eL6OXflRW5K4sbcFlACTQVZBovdYh+Ev9W Mqco9WqPDRlf6qcjMO8clOEGxYjTGugvNzsa8DSUVpyjOxO3299b00WmdrWmC90xt//u nKNMqvbb1xE6xPq1j0bfJTOfKaTclSTpmCBWa41XGTzUHyBesMb6m+WRa/YKZbgI5I8r ttHvGD69XkTsMBsqcPVvPipO7cjC0uZGkqLW84kcDYbVOWAagl/OwMw7J4+1ntpQ2/JJ 1Uzw== X-Gm-Message-State: APjAAAUWbHeoaN8ovk49SU+bjjnSYY1BDZefEG7PxYfkT3hJnYgpJugn QiI9XmQme882WyXYav7WZwWLjXTOcdTMH7Knbo8= X-Received: by 2002:a37:a854:: with SMTP id r81mr56278918qke.378.1563996015218; Wed, 24 Jul 2019 12:20:15 -0700 (PDT) MIME-Version: 1.0 References: <20190724165803.87470-1-brianvv@google.com> In-Reply-To: <20190724165803.87470-1-brianvv@google.com> From: Song Liu Date: Wed, 24 Jul 2019 12:20:04 -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: Brian Vazquez 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 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? > 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. Thanks, Song