From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mathieu Desnoyers Subject: Re: [PATCH 2/3] selftests: add membarrier syscall test Date: Mon, 7 Sep 2015 16:01:46 +0000 (UTC) Message-ID: <2098747118.39146.1441641706942.JavaMail.zimbra@efficios.com> References: <1436561912-24365-1-git-send-email-mathieu.desnoyers@efficios.com> <1436561912-24365-3-git-send-email-mathieu.desnoyers@efficios.com> <1441004040.5735.7.camel@ellerman.id.au> <1071313434.33305.1441127478843.JavaMail.zimbra@efficios.com> <1441272839.26379.2.camel@ellerman.id.au> <1734164155.35899.1441295233847.JavaMail.zimbra@efficios.com> <1441337809.13721.1.camel@ellerman.id.au> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_39144_1147905605.1441641706941" Return-path: In-Reply-To: <1441337809.13721.1.camel@ellerman.id.au> Sender: linux-kernel-owner@vger.kernel.org To: Michael Ellerman Cc: Andy Lutomirski , Andrew Morton , linux-kernel@vger.kernel.org, linux-api , Pranith Kumar List-Id: linux-api@vger.kernel.org ------=_Part_39144_1147905605.1441641706941 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit ----- On Sep 3, 2015, at 11:36 PM, Michael Ellerman mpe@ellerman.id.au wrote: > On Thu, 2015-09-03 at 15:47 +0000, Mathieu Desnoyers wrote: >> ----- On Sep 3, 2015, at 5:33 AM, Michael Ellerman mpe@ellerman.id.au wrote: >> >> > On Tue, 2015-09-01 at 11:32 -0700, Andy Lutomirski wrote: >> >> On Tue, Sep 1, 2015 at 10:11 AM, Mathieu Desnoyers >> >> wrote: >> >> > Just to make sure I understand: should we expect that >> >> > everyone will issue "make headers_install" on their system >> >> > before doing a make kselftest ? >> >> > >> >> > I see that a few selftests (e.g. memfd) are adding the >> >> > source tree include paths to the compiler include paths, >> >> > which I guess is to ensure that the kselftest will >> >> > work even if the system headers are not up to date. >> >> >> >> It would be really nice if there were a clean way for selftests to >> >> include the kernel headers. >> > >> > What's wrong with make headers_install? >> > >> > Or do you mean when writing the tests? That we could fix by adding the >> > ../../../../usr/include path to CFLAGS in lib.mk. And fixing all the tests that >> > overwrite CFLAGS to append to CFLAGS. >> > >> >> Perhaps make should build the exportable headers somewhere as a dependency of >> >> kselftests. >> > >> > Yeah the top-level kselftest target could do that I think. >> > >> > Folks who don't want the headers installed can just run the selftests Makefile >> > directly. >> > >> > Does this work for you? >> > >> > diff --git a/Makefile b/Makefile >> > index c361593..c8841d3 100644 >> > --- a/Makefile >> > +++ b/Makefile >> > @@ -1080,7 +1080,7 @@ headers_check: headers_install >> > # Kernel selftest >> > >> > PHONY += kselftest >> > -kselftest: >> > +kselftest: headers_install >> > $(Q)$(MAKE) -C tools/testing/selftests run_tests >> >> My personal experience is that make headers_install does not necessarily play >> well with the distribution header file hierarchy, which requires some tweaks >> to be done by the users (e.g. asm vs x86_64-linux-gnu). > > OK, I've never had issues. What exactly are you doing and how is it going wrong? After some investigation, I noticed the following: 1) I first ran make headers_install as root, which installed the headers within my build tree. I later tried it again as user, and it failed due to permission issues (my bad). This is where I tried to install it into my system rather than under my build directory, which caused a mess. 2) Since make kselftest should be run as root (according to make help), this means that all the output files generated by the build are owned by root. It leads to permissions issues when trying to rebuild the tests as user afterward. Perhaps we could introduce a distinction between make kselftest_build and make kselftest_run ? The former could be executed as user, and the latter as root. > >> Also, headers_install typically expects a INSTALL_HDR_PATH. > > You can specify it, but the default is just usr/, ie. in the kernel directory, > that is what I was proposing. (Actually it's $(objtree)/usr). OK, trying it out. > >> It would be interesting if we could install the kernel headers into a >> specific location that is then re-used by kselftest, so using it without too >> much manual configuration does not require to overwrite the distribution >> header files to run tests. > > I think we can do that now, ie: > > $ ls /usr/include/linux/membarrier.h > ls: cannot access /usr/include/linux/membarrier.h: No such file or directory > > $ cd linux-next > $ make mrproper > $ make headers_install > ... > $ ls usr/include/linux/membarrier.h > usr/include/linux/membarrier.h > $ make -C tools/testing/selftests TARGETS=membarrier > make: Entering directory > '/home/michael/work/topics/selftests/linux-next/tools/testing/selftests' > for TARGET in membarrier; do \ > make -C $TARGET; \ > done; > make[1]: Entering directory > '/home/michael/work/topics/selftests/linux-next/tools/testing/selftests/membarrier' > gcc -g -I../../../../usr/include/ membarrier_test.c -o membarrier_test > make[1]: Leaving directory > '/home/michael/work/topics/selftests/linux-next/tools/testing/selftests/membarrier' > make: Leaving directory > '/home/michael/work/topics/selftests/linux-next/tools/testing/selftests' > > $ ./tools/testing/selftests/membarrier/membarrier_test > membarrier MEMBARRIER_CMD_QUERY failed. Function not implemented. > $ > > > So that seems to be working for me. Are you doing some different work flow, or > am I just missing something? When doing make headers_install, it indeed installs membarrier.h where we expect it under the build output dir: $ ls usr/include/linux/membarrier.h usr/include/linux/membarrier.h However, if I issue $ make -C tools/testing/selftests TARGETS=membarrier make: Entering directory `/home/efficios/git/linux-next/tools/testing/selftests' for TARGET in membarrier; do \ make -C $TARGET; \ done; make[1]: Entering directory `/home/efficios/git/linux-next/tools/testing/selftests/membarrier' gcc membarrier_test.c -o membarrier_test membarrier_test.c:2:30: fatal error: linux/membarrier.h: No such file or directory #include This is after applying the modifications you requested (see patch attached). Perhaps I did something wrong ? > > I guess it probably doesn't work if you're using O=.. ? I'm not using anything special here. My src tree is my obj output directory. Thanks, Mathieu > > cheers -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com ------=_Part_39144_1147905605.1441641706941 Content-Type: text/x-patch; name=0001-to-send-Cleanup-membarrier-selftest-header-inclusion.patch Content-Disposition: attachment; filename=0001-to-send-Cleanup-membarrier-selftest-header-inclusion.patch Content-Transfer-Encoding: base64 RnJvbSAzNTI0NjViZDQyNzM3ZGU0Yjk3Y2UyMDcyZjBiMzZiMjQ5OWRiYjllIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNYXRoaWV1IERlc25veWVycyA8bWF0aGlldS5kZXNub3llcnNA ZWZmaWNpb3MuY29tPgpEYXRlOiBUdWUsIDEgU2VwIDIwMTUgMTM6NDI6NTIgLTA0MDAKU3ViamVj dDogW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