Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp704793pxk; Thu, 24 Sep 2020 16:49:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzGCIMlXm0Mu+VaZI7G6FX1m72vG4RerF27di8htKHac6eHCcjr6YF+9HsBCsHHRo2DfWV X-Received: by 2002:a17:906:c447:: with SMTP id ck7mr96440ejb.358.1600991383611; Thu, 24 Sep 2020 16:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600991383; cv=none; d=google.com; s=arc-20160816; b=vtPn5mKnLXsO5/g+QhmUT6XJj3jo+XmP7CmRATzqOBpquV4XTBgudeyb1bDg2L7CnX 02UxSAHEZ5XDXW0Wis8D45OQG3gSupiBNHcdHeja8BXbFyDs/spS9+7iKpINKoIqT9QA 1FXgCDNBkNPwIw23exl8l1/tQ/eTV1VkuwbMJYNQKc5AR1sGQ8uFEhFZ8N2uF9/t2LA9 UEGIEF39LrBJ9NiEfT1mT914GA4ezXm17w+9lMP12Skz3OBAZ3NU9eGYY0y8sZs7l5r0 hQnN4j4zkqkPQRROLZNB0vYOuF56X45dWVHOeUkpojX11D0JYWc0IDe7zeF4sG4WqkH2 F/4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dhceond6MhN2R2DQeCMd0g/2xnp3K8y0mvTHC2tschA=; b=himI8NhYuO6naKmHlfvjliJX+V10cjMxtXOZEcqJfJENwv7evOY+RuhidxkWg3Vvac WY8N0QKVlKKx2IHBsEXscmxPEFl8cIWfv/lUwbKDx/BQpMosMDMvZvr7K4H0Rcy5jOkI IxYf5znxvqiJTJhFsJbVX3gR0KSS9puR1imffwy+zaSPufoFrg7WTiFDML691b2gwJ3t rLKTIiaP55jf0Isin9p8DVfAlVGWT3YRnAVmFkYz82b0e9RzoBtRRyzJsCj1WdLVjqkS iTAJYcLlQjYpk0BqIusUvf4luo0XV1ZCnTfaCUA4Huh64EwWiMOoCqi5wvK/y+Hh3oWO uuoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VFyC5KeN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si667729edz.97.2020.09.24.16.49.20; Thu, 24 Sep 2020 16:49:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VFyC5KeN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726768AbgIXXrn (ORCPT + 99 others); Thu, 24 Sep 2020 19:47:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726706AbgIXXrn (ORCPT ); Thu, 24 Sep 2020 19:47:43 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 437EBC0613D3 for ; Thu, 24 Sep 2020 16:47:43 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id o20so1244078pfp.11 for ; Thu, 24 Sep 2020 16:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=dhceond6MhN2R2DQeCMd0g/2xnp3K8y0mvTHC2tschA=; b=VFyC5KeNqyRRNwJ2rIqr64ZAdhtd3ZjHKi/FlEg6q1kPOgt6jHtVOG5WenIgUz+WhE wPdvUdWlU8OufLk3klwumvuTjCzgSVta9G3tmEHbHyw00UO5g5AmnSaWsmsA1JTkdntn +CeaImnE6+DIvQMWrDoXvTu0JKpZVaUbnMIps= 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:content-transfer-encoding :in-reply-to; bh=dhceond6MhN2R2DQeCMd0g/2xnp3K8y0mvTHC2tschA=; b=sqonR8lvm29fdtoCroNs+6AMgkss7M20jp/frHUtrLvyIpGwfBgt4zHheRPuazBpiw Cj4BfnNsjJzKzhRG77Mts6bziDaJjDNq5vT34ouixJoo5MhWzOoTJLKtyeg4UeV7qfgi 7XaPlVez7MvjQNi/eRE8w0Vs0ylu+CuKXSaFG1/61CD1lLe+A/y6HeJylcsNXcE/reLn pzC+S+wpbq2yIFzLVWUoDBhn/DbXiv5dsJfJpUo1Jo9cNkpLdc668ThkWOoI/T0A9a0L BSccJUu2U1c65CbnaaC/slyYSIR43CsOwq7+RBz6m3ej0Fo/PlgL75naVufXCvLPchle PbHg== X-Gm-Message-State: AOAM530XvHyLUMK6o/vxJScox5P/GXcKQBob+BVtYNJcodyTHwvfeOht cqe0v28zTrZUo6jfKohsTXpEjyeR+Ssg8dkG X-Received: by 2002:a17:902:b18f:b029:d2:1ec0:4161 with SMTP id s15-20020a170902b18fb02900d21ec04161mr1559187plr.58.1600991262838; Thu, 24 Sep 2020 16:47:42 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id n125sm526792pfn.185.2020.09.24.16.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 16:47:42 -0700 (PDT) Date: Thu, 24 Sep 2020 16:47:41 -0700 From: Kees Cook To: YiFei Zhu Cc: containers@lists.linux-foundation.org, YiFei Zhu , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Aleksa Sarai , Andrea Arcangeli , Andy Lutomirski , Dimitrios Skarlatos , Giuseppe Scrivano , Hubertus Franke , Jack Chen , Jann Horn , Josep Torrellas , Tianyin Xu , Tobin Feldman-Fitzthum , Tycho Andersen , Valentin Rothberg , Will Drewry Subject: Re: [PATCH v2 seccomp 5/6] selftests/seccomp: Compare bitmap vs filter overhead Message-ID: <202009241646.5739BE3@keescook> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 24, 2020 at 07:44:20AM -0500, YiFei Zhu wrote: > From: Kees Cook > > As part of the seccomp benchmarking, include the expectations with > regard to the timing behavior of the constant action bitmaps, and report > inconsistencies better. > > Example output with constant action bitmaps on x86: > > $ sudo ./seccomp_benchmark 100000000 > Current BPF sysctl settings: > net.core.bpf_jit_enable = 1 > net.core.bpf_jit_harden = 0 > Benchmarking 100000000 syscalls... > 63.896255358 - 0.008504529 = 63887750829 (63.9s) > getpid native: 638 ns > 130.383312423 - 63.897315189 = 66485997234 (66.5s) > getpid RET_ALLOW 1 filter (bitmap): 664 ns > 196.789080421 - 130.384414983 = 66404665438 (66.4s) > getpid RET_ALLOW 2 filters (bitmap): 664 ns > 268.844643304 - 196.790234168 = 72054409136 (72.1s) > getpid RET_ALLOW 3 filters (full): 720 ns > 342.627472515 - 268.845799103 = 73781673412 (73.8s) > getpid RET_ALLOW 4 filters (full): 737 ns > Estimated total seccomp overhead for 1 bitmapped filter: 26 ns > Estimated total seccomp overhead for 2 bitmapped filters: 26 ns > Estimated total seccomp overhead for 3 full filters: 82 ns > Estimated total seccomp overhead for 4 full filters: 99 ns > Estimated seccomp entry overhead: 26 ns > Estimated seccomp per-filter overhead (last 2 diff): 17 ns > Estimated seccomp per-filter overhead (filters / 4): 18 ns > Expectations: > native ≤ 1 bitmap (638 ≤ 664): ✔️ > native ≤ 1 filter (638 ≤ 720): ✔️ > per-filter (last 2 diff) ≈ per-filter (filters / 4) (17 ≈ 18): ✔️ > 1 bitmapped ≈ 2 bitmapped (26 ≈ 26): ✔️ > entry ≈ 1 bitmapped (26 ≈ 26): ✔️ > entry ≈ 2 bitmapped (26 ≈ 26): ✔️ > native + entry + (per filter * 4) ≈ 4 filters total (732 ≈ 737): ✔️ > > Signed-off-by: Kees Cook > Signed-off-by: YiFei Zhu BTW, did this benchmark tool's results match your expectations from what you saw with your RFC? (I assume it helped since you've included in here.) -- Kees Cook