From patchwork Tue Feb 28 09:32:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 62370 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2915786wrd; Tue, 28 Feb 2023 01:44:02 -0800 (PST) X-Google-Smtp-Source: AK7set8J7pn21/0mik1O8gRpRjCYc2ZFYrCrif82YS9JLRRvg+k1QN8TeSVq0MsVS1agJL1vI0G8 X-Received: by 2002:a17:902:cec5:b0:19a:6acc:1de2 with SMTP id d5-20020a170902cec500b0019a6acc1de2mr2262078plg.35.1677577441751; Tue, 28 Feb 2023 01:44:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677577441; cv=none; d=google.com; s=arc-20160816; b=xc0VKRoma56lA0eAER98azV6h6u7WOhoNmrpXoqmClU1EXTOgFp6VK6ZD66UadaLUU V5RLhzwf/Nddxdw9DhZdS66wWZlOCMBTKR+5e+iK1meS6fc0CltBVGFy9Ecv/CD9ipzX twOEcxMxeyKv1cNxdPQ98No0i579yDZquR1cPWvtUQhq6S0eRi/umfbzq0xujekSZ2wz A6s8IlRm7+NjGw1qwrj1UVIdwrIieluyJm/O4Y9qmnuqVbkwZbNVlvnnGqkU0WjGsllY jM8BxdeB6cvY6V5bQJRKLrVqjXmV2+lP5aIgWCYeb3NM6B1b0eqIR8jO2H1smuiTHW2S hj2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YzOjVEVDvmt36cWz38x+2kR8qDP4JvBCurVU7duy1n4=; b=DtmKdKD6bFzNs5JrzW80Esm5U+ebw8KocHjS67b6vTlcCXSVwxG0w6PkUPQbF5cZTO Lhl3cT8tQk07S/Qt3aWCKAocSsLfyBI436b+kw/kikfMq8ns0MpMuOmE2hPQFmMHSRe2 +we7+5nQIyKEE51Qj7SYn3g1wtiABL3+fZNLF67eofo2gTQixP8hDWS9l+ib98ywaR7l C4O0yx0P1ZP8XD5eUYmvNHqTj5Lu1EvjPVGtVv/8Kc9PJ72c3MMTVyfqUrM+LMHPx0zQ q1B6NvPYyP5NusqsgU6DjfHqSLombsawCMSm6eFyVnlAYDxzhBasdhZvsHxB4Nel/36E z23Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Zgd0zI0q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v10-20020a1709028d8a00b001994a358baasi8635545plo.146.2023.02.28.01.43.49; Tue, 28 Feb 2023 01:44:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Zgd0zI0q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231367AbjB1Jdv (ORCPT + 99 others); Tue, 28 Feb 2023 04:33:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231351AbjB1Jdq (ORCPT ); Tue, 28 Feb 2023 04:33:46 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB2B2199B; Tue, 28 Feb 2023 01:33:33 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 07BC7B80DFF; Tue, 28 Feb 2023 09:33:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C855C433EF; Tue, 28 Feb 2023 09:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677576810; bh=ySf52tgWqEzdgE2vONbMq7274Pu4w3NaXS6sukUJ/0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zgd0zI0qCybzWRqKGIKUz+Rm49XKg3Uy7NFHPGFw2GDLDuL1jlUXC13xDSN/8EHMo 4V5P+uyoEs9Zuhajj71FPcUKW6bLUmymtvxLe8/74wwj3vDCvwM2OpXY2WSbg7krW7 2I/yp6iqFJIU2rCfEXQFcDyUYmLHATae/AXLtZhw8EJbUqjr0bA/xp1NLTEdgQZeYy Tz8wUH1wHeEnIXtrUxY9RqgPgS4rx8fn7haijA02hKW2iguF7lEl2VJbKx2E5JQ9dk PrUMUo0oURbDLheqXXfeyY6pA0ObUo3g3d3ZahQGyGxY32/DsyKSs5nof1ZWrI130V S84l0gHSDnRnw== From: Jiri Olsa To: Alexei Starovoitov , Andrii Nakryiko , Hao Luo , Andrew Morton , Alexander Viro , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Matthew Wilcox Cc: bpf@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-perf-users@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Daniel Borkmann , Namhyung Kim Subject: [PATCH RFC v2 bpf-next 6/9] selftests/bpf: Add err.h header Date: Tue, 28 Feb 2023 10:32:03 +0100 Message-Id: <20230228093206.821563-7-jolsa@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230228093206.821563-1-jolsa@kernel.org> References: <20230228093206.821563-1-jolsa@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759067443362711379?= X-GMAIL-MSGID: =?utf-8?q?1759067443362711379?= Moving error macros from profiler.inc.h to new err.h header. It will be used in following changes. Signed-off-by: Jiri Olsa --- tools/testing/selftests/bpf/progs/err.h | 13 +++++++++++++ tools/testing/selftests/bpf/progs/profiler.inc.h | 3 +-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/err.h diff --git a/tools/testing/selftests/bpf/progs/err.h b/tools/testing/selftests/bpf/progs/err.h new file mode 100644 index 000000000000..3ac6324da6fd --- /dev/null +++ b/tools/testing/selftests/bpf/progs/err.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ERR_H__ +#define __ERR_H__ + +#define MAX_ERRNO 4095 +#define IS_ERR_VALUE(x) (unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO + +static inline int IS_ERR_OR_NULL(const void *ptr) +{ + return !ptr || IS_ERR_VALUE((unsigned long)ptr); +} + +#endif /* __ERR_H__ */ diff --git a/tools/testing/selftests/bpf/progs/profiler.inc.h b/tools/testing/selftests/bpf/progs/profiler.inc.h index 875513866032..f799d87e8700 100644 --- a/tools/testing/selftests/bpf/progs/profiler.inc.h +++ b/tools/testing/selftests/bpf/progs/profiler.inc.h @@ -6,6 +6,7 @@ #include #include "profiler.h" +#include "err.h" #ifndef NULL #define NULL 0 @@ -16,7 +17,6 @@ #define O_DIRECTORY 00200000 #define __O_TMPFILE 020000000 #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) -#define MAX_ERRNO 4095 #define S_IFMT 00170000 #define S_IFSOCK 0140000 #define S_IFLNK 0120000 @@ -34,7 +34,6 @@ #define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) #define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) #define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) -#define IS_ERR_VALUE(x) (unsigned long)(void*)(x) >= (unsigned long)-MAX_ERRNO #define KILL_DATA_ARRAY_SIZE 8