From patchwork Thu Mar 16 17:01:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13178093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4CE4C6FD1F for ; Thu, 16 Mar 2023 17:03:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E00B900005; Thu, 16 Mar 2023 13:03:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 790FD900002; Thu, 16 Mar 2023 13:03:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 658BF900005; Thu, 16 Mar 2023 13:03:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 570E1900002 for ; Thu, 16 Mar 2023 13:03:19 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 02A3CA140B for ; Thu, 16 Mar 2023 17:03:18 +0000 (UTC) X-FDA: 80575382118.24.DBB2E2C Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf28.hostedemail.com (Postfix) with ESMTP id 98CFCC001C for ; Thu, 16 Mar 2023 17:03:16 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="u/EISLQO"; spf=pass (imf28.hostedemail.com: domain of jolsa@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=jolsa@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678986196; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=AZlHEINR9onG3cKIk69fPVKDvd0fZzvOxjv7iemp418=; b=EKyqeUWStG9k1yviNpADPZyOGny5q3ta1uQnQRrMm6ZOqyUwfw/GzCuhvFzjDHbcaiGThq Ux/SYrNUiz2vYMl1keXv/lfx5IVSwIeNY+uKWFG0XNPZf3t2NAo0sJJVBYSN2xKMtfcrN7 7NaJCwhsVRhzw+LV8A4/TqVRLvIgrYo= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="u/EISLQO"; spf=pass (imf28.hostedemail.com: domain of jolsa@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=jolsa@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678986196; a=rsa-sha256; cv=none; b=TD0DC2lEkf4hme/AmtTZ/OCzVI2xoAfmp9hE8ALgFHhrYWFJI+QQs2SUg2TMsR4Ma0sTBQ eqx3q6pAi5TNHWdKd54rqoAcbTT9I+ntOzh8Km2HC4y4Xwy2L6CRM5L4p6ZKh0qZNTw0GH hNwmNp/ifZtEN7vZOh9Qq4EM+k0DphA= 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 40A24B8228C; Thu, 16 Mar 2023 17:03:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE8B1C433EF; Thu, 16 Mar 2023 17:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678986194; bh=XHhvrIWZe8yN3WAyFVo4Xi7J+OqocuCK7k5vskhhChE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u/EISLQO2803reejxf8JO9MgqJ4NQbmCh7G+bn4fdRV+pQjJWe7KhKZRVVRMnw/ro ky1GblNRwpv7o43sqGdjR+vtMiXrfHmEkRy8GDHTp5zyIIcdCaW4MxkTblBR6l0SbR TAOctZXlkrbvfAr32VS7QCdN1vTKcd2FZpyaKwV6Mip5pPdN0fuTmWVv1nPd5jY5FD bZBxvJTG9trTD+BxrlJdfuicdsC4pgcFCE22xVsACPERaSCMmO+3odXdTcRCiUZbhM JiYpsGUKNn82I0dJFtheJV6qlT2BNNhuk7D4WYnHHcRnSXICVtX3RbdWfjsCO+7e5l iBrppzqNKKC5Q== 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 , Dave Chinner Subject: [PATCHv3 bpf-next 6/9] selftests/bpf: Add err.h header Date: Thu, 16 Mar 2023 18:01:46 +0100 Message-Id: <20230316170149.4106586-7-jolsa@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230316170149.4106586-1-jolsa@kernel.org> References: <20230316170149.4106586-1-jolsa@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 98CFCC001C X-Stat-Signature: wg3tzm7duh9rechswpjb4nzrz4twgmw3 X-HE-Tag: 1678986196-807189 X-HE-Meta: U2FsdGVkX198qEi3AEapGBmmB0DwTH3MOsG5ayLHGnU0KWWai4UhhFMa2x/zjRk6ldVrR4F+TwiOGOLpqvQ5wh54gxqJr7zG3/uSTX1V78+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k9LtcnjQok7Xy1LjIpWg1gkfZDCjaqQpLNHxcvTKblefAXsA+f2KLldUgGZY+Z09Ex3Wn9D3ShgIW7zi2UkbPrQ1ZNdHyCdrtCGKpEbdBii6vLrCExzK8O0CnX8lhZBIJpyiGvJaXRq2nNIr41r18HJ71bT/mfZ1i15nl7a6KmdTmJhNrtPp9d/aXN3U9lCPpf+FcIi7xkDXNwhBN+3NsrJ+TLrRlh9q0x6oKFxgBuDpPEA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Moving error macros from profiler.inc.h to new err.h header. It will be used in following changes. Also adding PTR_ERR macro that will be used in following changes. Signed-off-by: Jiri Olsa Acked-by: Andrii Nakryiko --- tools/testing/selftests/bpf/progs/err.h | 18 ++++++++++++++++++ .../testing/selftests/bpf/progs/profiler.inc.h | 3 +-- 2 files changed, 19 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..d66d283d9e59 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/err.h @@ -0,0 +1,18 @@ +/* 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); +} + +static inline long PTR_ERR(const void *ptr) +{ + return (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