From patchwork Wed Jan 19 10:15:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 533392 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCA77C433FE for ; Wed, 19 Jan 2022 10:17:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353696AbiASKRY (ORCPT ); Wed, 19 Jan 2022 05:17:24 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:47820 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353710AbiASKRJ (ORCPT ); Wed, 19 Jan 2022 05:17:09 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: usama.anjum) with ESMTPSA id AC62B1F44443 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1642587428; bh=ZgAzpMGfSGdCPLE/fHhKIS82NhtSqBUPZr7WBPwkwXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C0mGMmA7q7UPYsiXK18YhhsNEQ//QfrpSJuvfRmQUme1U5Fg4vobtB0Ao0YZiGUUk L3hEF7/vTCey+drcto8FB1II8khu5KrNSHj6tZDVDCrTS/eyExq2QqwYILoP2Qy10F 8Lmdf9wO/NjKg5Xp17P9zVfjJyRzSjdWaMGg9JMiYgITkIDPxQCI6DPGYbmCiq48wl KdwbBRzvSFh0zarKFe2Y/qPcaWxXsJAdqBodS6834V2pv09q05jLvBfhen5Zoq/3Ih uJqUJrZT+o/JZh8YBKDePxlOaWJ6AvYf+Pwr482gk45PmGVBeQDczi22XKAu6KIjXv v5snzb//VssZA== From: Muhammad Usama Anjum To: Shuah Khan , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , Davidlohr Bueso , =?utf-8?q?Andr=C3=A9_Almeida?= , Paolo Bonzini , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , "David S. Miller" , Jakub Kicinski , Mat Martineau , Matthieu Baerts , Andrew Morton , chiminghao , linux-kselftest@vger.kernel.org (open list:KERNEL SELFTEST FRAMEWORK), linux-kernel@vger.kernel.org (open list), kvm@vger.kernel.org (open list:KERNEL VIRTUAL MACHINE (KVM)), linux-security-module@vger.kernel.org (open list:LANDLOCK SECURITY MODULE), netdev@vger.kernel.org (open list:NETWORKING [GENERAL]), mptcp@lists.linux.dev (open list:NETWORKING [MPTCP]), linux-mm@kvack.org (open list:MEMORY MANAGEMENT) Cc: Muhammad Usama Anjum , kernel@collabora.com Subject: [PATCH V2 10/10] selftests: vm: remove dependecy from internal kernel macros Date: Wed, 19 Jan 2022 15:15:31 +0500 Message-Id: <20220119101531.2850400-11-usama.anjum@collabora.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220119101531.2850400-1-usama.anjum@collabora.com> References: <20220119101531.2850400-1-usama.anjum@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The defination of swap() is used from kernel's internal header when this test is built in source tree. The build fails when this test is built out of source tree as defination of swap() isn't found. Selftests shouldn't depend on kernel's internal header files. They can only depend on uapi header files. Add the defination of swap() to fix the build error: gcc -Wall -I/linux_mainline2/build/usr/include -no-pie userfaultfd.c -lrt -lpthread -o /linux_mainline2/build/kselftest/vm/userfaultfd userfaultfd.c: In function ‘userfaultfd_stress’: userfaultfd.c:1530:3: warning: implicit declaration of function ‘swap’; did you mean ‘swab’? [-Wimplicit-function-declaration] 1530 | swap(area_src, area_dst); | ^~~~ | swab /usr/bin/ld: /tmp/cclUUH7V.o: in function `userfaultfd_stress': userfaultfd.c:(.text+0x4d64): undefined reference to `swap' /usr/bin/ld: userfaultfd.c:(.text+0x4d82): undefined reference to `swap' collect2: error: ld returned 1 exit status Fixes: 2c769ed7137a ("tools/testing/selftests/vm/userfaultfd.c: use swap() to make code cleaner") Signed-off-by: Muhammad Usama Anjum Reviewed-by: Alistair Popple --- tools/testing/selftests/vm/userfaultfd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index d3fd24f9fae8..d2480ab93037 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -119,6 +119,9 @@ struct uffd_stats { ~(unsigned long)(sizeof(unsigned long long) \ - 1))) +#define swap(a, b) \ + do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) + const char *examples = "# Run anonymous memory test on 100MiB region with 99999 bounces:\n" "./userfaultfd anon 100 99999\n\n"