Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp234711pxu; Fri, 4 Dec 2020 01:49:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9y6og5YPDr+WcRU/jr2UQul5JBs52oqN9mT8D1oIWx/a3TRSRE52w6z5gYgzsH7Zyp9rl X-Received: by 2002:a17:906:591a:: with SMTP id h26mr6227662ejq.174.1607075392944; Fri, 04 Dec 2020 01:49:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607075392; cv=none; d=google.com; s=arc-20160816; b=xQ8RpgTZ9MkjhW1NSjlp+jUEgIzijE3FBukkGTvBNW2FQhExKGaInFhhDvzr4JEXZf fMR3UKjtTpUdiDi+q/iSXP5qMRxNgsiZM+GKDdK09BeICaRIsbLtpUL3n+S9Rg/C/bpc 5nO5NsrvY9B3qtBEfr+cdacPc4fu3lk7rM4PrgXYV/gzgHXI30mf6+/WyokCrbO6gOeU Li0z1xxTaeYOCmMsb9Y8Fk8fouMySP45nto/1yUVVDXInQZj1FXJNtK8dfZWKRZJ1Pb0 4G2ugSvSoEe+mpC3DEWnR+xcmq7j36Q0Qc6Prg5jzaadj1WHk3ZblBGXLS0cy9YXw9Tw jXfw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HTMk/hXiedF9fES6DLjMJhevTJ/XIDlYzClccSpz43c=; b=xw99Twu5+XFdlbNHRdF3p+eEr3+mXdrozlJqS4GSLaXqdWkQh9a76J+SqZ0i3pIZXs bQLGMvbBhN3odVETz/Z0qmSAins/dKQNxKnDI+Yqueap9PMjFL8Ac5dpyrSAtkO5heEt 7PH/We+Yq3cUtwDqp6yFxK8+HkU6KvKxDF4DgboCkoA+Vv5C3kBQL3d/F7YRslYPbOWs dVEU0g4PgdhZisYXbH15EyMZy+tHaIYvwWlAQTZWqIzLPhVM+vAZhz3ajcsSuMcS9Fa+ uCfR8G56PmgEzxucWfk1CDxXOADHay442R/tmD6aXwZ5+dBc3/8VVXjBC+EY4M+GALf0 oN8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rkzVE3Nc; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u23si1014287ejj.163.2020.12.04.01.49.29; Fri, 04 Dec 2020 01:49:52 -0800 (PST) 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=@google.com header.s=20161025 header.b=rkzVE3Nc; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387724AbgLDJp5 (ORCPT + 99 others); Fri, 4 Dec 2020 04:45:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727430AbgLDJp4 (ORCPT ); Fri, 4 Dec 2020 04:45:56 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE93DC061A52 for ; Fri, 4 Dec 2020 01:45:15 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id x22so4955980wmc.5 for ; Fri, 04 Dec 2020 01:45:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=HTMk/hXiedF9fES6DLjMJhevTJ/XIDlYzClccSpz43c=; b=rkzVE3Nc+vVTKg+EdCO3dJ6wRI0pzX7FjqvkyEpkK0bLmE5LVKyIJqwVQ/WNCKCLk3 o5fpFW4ZRRI8zzNeeZR3T2dZGXrT4vurLWNqDwUQJwEfI42JbSRww51bmuEnus9br57/ D2mYNHHQFaRTE+wJ9l9LBG7RdSaevA4HP1Eejqf0PkrU3w+q9RooxbmDkLvalGsUgUXe +wkDEPj65CcO5HjQum7fQNKvJR4Jx5Ss7NrkzBexvTTEo8x0yiZDmzwJJVAWJdvvoRFf CtlWLfkZFUsouE64CAR5VZrk/+U1r2vlsMReEzdNENOPRzLZIE/G0erM5fOF4DDpOf8q DRAw== 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; bh=HTMk/hXiedF9fES6DLjMJhevTJ/XIDlYzClccSpz43c=; b=jKzhjUrpc7yy1l55EAtv55fOKW9vV08uNppnmfN7AaapCshOPA65prsGRFlc2aM56D mNIBjMzFZucUGoFKhLTcsKPGlaa9zlDXl7j4JAglUMGskR1fVnDykc9KhPQ3v2Pnlwsw aBBKblrf1+i5HGho3/OZg5uz2j8Ecek1pdiic/Gnif2AkKt2W9vcynT/06HhUkYynV2g zRO5sxLEFbuO0MuJ7ukmJWhHsyL7ECLhH20XhO9Sclx64jQ4lv6KP36ypsen9QPyAZWd 7/hbd06VIz26oFnAsSofZnRPW1cylZYSwGXlxj35ZpJyqi2ZiW5J+Lc8MaA/om4o9Gex Y/Ag== X-Gm-Message-State: AOAM532XKZXv1YW6w8CdTgdYJJHcmyq5xhGJswG3LZpO504tpLtT8qa0 wMHoKsUrmXl6e6nkFtwZamhDVQ== X-Received: by 2002:a1c:4954:: with SMTP id w81mr3186191wma.60.1607075114273; Fri, 04 Dec 2020 01:45:14 -0800 (PST) Received: from google.com (203.75.199.104.bc.googleusercontent.com. [104.199.75.203]) by smtp.gmail.com with ESMTPSA id p11sm3010541wrj.14.2020.12.04.01.45.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 01:45:13 -0800 (PST) Date: Fri, 4 Dec 2020 09:45:09 +0000 From: Brendan Jackman To: Yonghong Song Cc: bpf@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , KP Singh , Florent Revest , linux-kernel@vger.kernel.org, Jann Horn Subject: Re: [PATCH bpf-next v3 13/14] bpf: Add tests for new BPF atomic operations Message-ID: References: <20201203160245.1014867-1-jackmanb@google.com> <20201203160245.1014867-14-jackmanb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 03, 2020 at 11:06:31PM -0800, Yonghong Song wrote: > On 12/3/20 8:02 AM, Brendan Jackman wrote: [...] > > diff --git a/tools/testing/selftests/bpf/prog_tests/atomics_test.c b/tools/testing/selftests/bpf/prog_tests/atomics_test.c > > new file mode 100644 > > index 000000000000..66f0ccf4f4ec > > --- /dev/null > > +++ b/tools/testing/selftests/bpf/prog_tests/atomics_test.c > > @@ -0,0 +1,262 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > + > > +#include > > + > > + > > +#include "atomics_test.skel.h" > > + > > +static struct atomics_test *setup(void) > > +{ > > + struct atomics_test *atomics_skel; > > + __u32 duration = 0, err; > > + > > + atomics_skel = atomics_test__open_and_load(); > > + if (CHECK(!atomics_skel, "atomics_skel_load", "atomics skeleton failed\n")) > > + return NULL; > > + > > + if (atomics_skel->data->skip_tests) { > > + printf("%s:SKIP:no ENABLE_ATOMICS_TEST (missing Clang BPF atomics support)", > > + __func__); > > + test__skip(); > > + goto err; > > + } > > + > > + err = atomics_test__attach(atomics_skel); > > + if (CHECK(err, "atomics_attach", "atomics attach failed: %d\n", err)) > > + goto err; > > + > > + return atomics_skel; > > + > > +err: > > + atomics_test__destroy(atomics_skel); > > + return NULL; > > +} > > + > > +static void test_add(void) > > +{ > > + struct atomics_test *atomics_skel; > > + int err, prog_fd; > > + __u32 duration = 0, retval; > > + > > + atomics_skel = setup(); > > When running the test, I observed a noticeable delay between skel load and > skel attach. The reason is the bpf program object file contains > multiple programs and the above setup() tries to do attachment > for ALL programs but actually below only "add" program is tested. > This will unnecessarily increase test_progs running time. > > The best is for setup() here only load and attach program "add". > The libbpf API bpf_program__set_autoload() can set a particular > program not autoload. You can call attach function explicitly > for one specific program. This should be able to reduce test > running time. Interesting, thanks a lot - I'll try this out next week. Maybe we can actually load all the progs once at the beginning (i.e. in test_atomics_test) then attach/detch each prog individually as needed... Sorry, I haven't got much of a grip on libbpf yet.