From patchwork Fri Mar 25 01:14:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12791212 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 5F104C433EF for ; Fri, 25 Mar 2022 01:14:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5CF98D0051; Thu, 24 Mar 2022 21:14:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DBE598D004D; Thu, 24 Mar 2022 21:14:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C38ED8D0051; Thu, 24 Mar 2022 21:14:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id ADF088D004D for ; Thu, 24 Mar 2022 21:14:17 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 710898249980 for ; Fri, 25 Mar 2022 01:14:17 +0000 (UTC) X-FDA: 79281137754.20.880FCAE Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id F05E140005 for ; Fri, 25 Mar 2022 01:14:16 +0000 (UTC) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 6C700618F7; Fri, 25 Mar 2022 01:14:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C645DC340EC; Fri, 25 Mar 2022 01:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648170855; bh=7SRsMXupj0RrnQBFbCgm7EaGx8rN51ziwzcte7YuUT0=; h=Date:To:From:In-Reply-To:Subject:From; b=ZAYOGfQu2ixqs+qEBldHxjQP8l/cWsik8o4grOWLNJq+cZzkZr5WhieacNKcipI8Z 3gA1jgB5MgZyFBVJl06VKYaLpih3UcCXk9UmYk9GihlJ7903DrWPNGJx88RGF1q2Gu D5H50wNW05q8GeGuD63o6Okq/zClfkH0iTQuytWI= Date: Thu, 24 Mar 2022 18:14:15 -0700 To: tglx@linutronix.de,shuah@kernel.org,peterz@infradead.org,pbonzini@redhat.com,mingo@redhat.com,mic@digikod.net,matthieu.baerts@tessares.net,mathew.j.martineau@linux.intel.com,kuba@kernel.org,dvhart@infradead.org,dave@stgolabs.net,davem@davemloft.net,chi.minghao@zte.com.cn,apopple@nvidia.com,andrealmeid@collabora.com,usama.anjum@collabora.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220324180758.96b1ac7e17675d6bc474485e@linux-foundation.org> Subject: [patch 113/114] selftests: vm: remove dependecy from internal kernel macros Message-Id: <20220325011415.C645DC340EC@smtp.kernel.org> X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: F05E140005 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=ZAYOGfQu; dmarc=none; spf=pass (imf11.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Stat-Signature: ffaqyjyiycw8oahx74tgb5j1tituz4x5 X-HE-Tag: 1648170856-644104 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: From: Muhammad Usama Anjum Subject: selftests: vm: remove dependecy from internal kernel macros 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 Link: https://lkml.kernel.org/r/20220119101531.2850400-11-usama.anjum@collabora.com Fixes: 2c769ed7137a ("tools/testing/selftests/vm/userfaultfd.c: use swap() to make code cleaner") Signed-off-by: Muhammad Usama Anjum Reviewed-by: Alistair Popple Cc: Andr Almeida Cc: Darren Hart Cc: Davidlohr Bueso Cc: "David S. Miller" Cc: Ingo Molnar Cc: Jakub Kicinski Cc: Mat Martineau Cc: Matthieu Baerts Cc: Mickal Salan Cc: Minghao Chi Cc: Paolo Bonzini Cc: Peter Zijlstra Cc: Shuah Khan Cc: Thomas Gleixner Signed-off-by: Andrew Morton --- tools/testing/selftests/vm/userfaultfd.c | 3 +++ 1 file changed, 3 insertions(+) --- a/tools/testing/selftests/vm/userfaultfd.c~selftests-vm-remove-dependecy-from-internal-kernel-macros +++ a/tools/testing/selftests/vm/userfaultfd.c @@ -122,6 +122,9 @@ struct uffd_stats { #define swap(a, b) \ do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) +#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"