Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1321518pxb; Wed, 3 Nov 2021 23:34:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz442SLy/YX/ve15Zz+wTLPDEADe6zsrlMDZkB+CJNkh3obmiivnFEan3zhCGSDiNE6Xn+K X-Received: by 2002:a05:6638:16d6:: with SMTP id g22mr2384470jat.19.1636007650809; Wed, 03 Nov 2021 23:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636007650; cv=none; d=google.com; s=arc-20160816; b=bM9mykhJNvVmgXPSG4NbF9dlmDNbqLn8njXAJaTwQTOuHE4vaSaikJQZzx0k8Mwm/U hd0fRNow7KHJUBa3oecbJ+f/izk8jVMDtZp436FsUhfQsJuA8E1wcNT5ZHs5E0RRL7mh dPRAZ69cOQrlIZjoCUjAh5ldwSYUEJls0nO4YzjWiw39FploixDpWaH/q8KfwndClVTn yaej6HX3Pt16/7M/LDC4bFNYac+DlM+pSS9aq+EUTNb40gXsHGjs2F/csSqn38wZf2Q+ Pe4l1OuizbKVjk4eGH8EeivdMHiCaQvXsgGJ6uv9POLtaoHxQQsEQ6Qg5a4les8klyb/ oyPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=ujnaR23Xpf6ZK6H9LP1kXDUsPR6ZRS5B76puv1raf8Q=; b=Dhb0tv+oLhxsc5VlpyMmD4YLvvbRqC0qnNASi3TqpMZued7i3mDYkUUlR8/CpIADE6 OZRNDZpn2cbVDLvXqz8m2ay5864wOU1FM9SxUCusUbWcG7xqrr4pTSgNkojXomVmsjFY bUWK182Qb9GARfUNQcofEx2UFkMVXHP1qcrVU62MsD6GlR0JHgfPJ3RcJ0Wx7etyHPaa Ze2VgfXtmIz6C8jJ4rDyTTNJk/VnyHCDXuS8F1K0YKJ1Cp0CqeBl4UDCPrcaQHN+PNb+ bozR9oIU+v0nqJtlRw+6oEuAh3dzI5cGDDpAK7rvWc0q0pG4gzpKuFh/uw/uW1CZWwUW v0IA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m6si75846ild.161.2021.11.03.23.33.57; Wed, 03 Nov 2021 23:34:10 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229994AbhKDGfX (ORCPT + 99 others); Thu, 4 Nov 2021 02:35:23 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:30917 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbhKDGfT (ORCPT ); Thu, 4 Nov 2021 02:35:19 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HlDGK5wx3zcZxj; Thu, 4 Nov 2021 14:27:53 +0800 (CST) Received: from dggpeml500025.china.huawei.com (7.185.36.35) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Thu, 4 Nov 2021 14:32:38 +0800 Received: from [10.174.176.117] (10.174.176.117) by dggpeml500025.china.huawei.com (7.185.36.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Thu, 4 Nov 2021 14:32:38 +0800 Subject: Re: [RFC PATCH v3 2/3] bpf: Add selftests To: Joe Burton , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , , , CC: Petar Penkov , Stanislav Fomichev , Joe Burton References: <20211102021432.2807760-1-jevburton.kernel@gmail.com> <20211102021432.2807760-3-jevburton.kernel@gmail.com> From: Hou Tao Message-ID: <98178f0f-ff43-b996-f78b-778f74b44a6b@huawei.com> Date: Thu, 4 Nov 2021 14:32:37 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20211102021432.2807760-3-jevburton.kernel@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.174.176.117] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500025.china.huawei.com (7.185.36.35) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 11/2/2021 10:14 AM, Joe Burton wrote: > From: Joe Burton > > Add selftests verifying that each supported map type is traced. > > Signed-off-by: Joe Burton > --- > .../selftests/bpf/prog_tests/map_trace.c | 166 ++++++++++++++++++ > .../selftests/bpf/progs/bpf_map_trace.c | 95 ++++++++++ > .../bpf/progs/bpf_map_trace_common.h | 12 ++ > 3 files changed, 273 insertions(+) > create mode 100644 tools/testing/selftests/bpf/prog_tests/map_trace.c > create mode 100644 tools/testing/selftests/bpf/progs/bpf_map_trace.c > create mode 100644 tools/testing/selftests/bpf/progs/bpf_map_trace_common.h snip > + /* > + * Invoke core BPF program. > + */ > + write_fd = open("/tmp/map_trace_test_file", O_CREAT | O_WRONLY); > + if (!ASSERT_GE(rc, 0, "open tmp file for writing")) > + goto out; > + > + bytes_written = write(write_fd, &write_buf, sizeof(write_buf)); > + if (!ASSERT_EQ(bytes_written, sizeof(write_buf), "write to tmp file")) > + return; In fentry__x64_sys_write(), you just do trigger updates to maps, so for the portability of the test (e.g. run-able for arm64) and minimal dependency (e.g. don't depends on /tmp), why do you using nanosleep() and replacing fentry_x64_sys_write by tp/syscalls/sys_enter_nanosleep instead. Also it will be better if you can filter out other processes by pid. Thanks, Tao