Received: by 10.213.65.68 with SMTP id h4csp887554imn; Wed, 4 Apr 2018 08:55:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Dzp7X8m0e5TUnR0blA3ZX4a8ptJsIuiVKKdBafdXiea63ZtVy/a4k3SQi7xWFCysvgeeu X-Received: by 2002:a17:902:9696:: with SMTP id n22-v6mr19658728plp.355.1522857335380; Wed, 04 Apr 2018 08:55:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522857335; cv=none; d=google.com; s=arc-20160816; b=GblSs9snA0X/LnH4T8yroccKGv0u6z3mGFzpALc7zfyMO53sUA24GTtXvVMhUPJERZ 7y+91LUHMt8Z+2KU2ukGOjUU0Otozff+ekIYFeC8ISiKqpjX4Y4dGSnaC+jmwXilv0Lu cAhm1vLYGKnRpZl/nkS1USbmDV1j6E/SefIlLu7uTVsLVllDdLON9vsIQwq5wgvKaxeT wC4XB3Kb+wsm6FB5Kxra03CwCxy9afOd6bs8HwuoA4B7wNO+PAJrH1xwiyU3Rrj/996J vreOaXRV25bqqNBHQFMVokrIAuJCDU48iPs8imVKdgW7iKrNGsidcjkSyYCLocgOB0Vk +JSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=qGaeNtuktj5wFE0+p3ERS+y4EvUp4qCu0hseFCBK5b4=; b=Ag62pW5eyh2h3MDBXsWzATTekjOt+I7ablV2T5/S0incll1Cuznroghc3bRnx5OCvg 0OBcAPVA4b6rLGanMQsqRDp1UrLPHUb2EK05MXMZ+U3QhwNcmOR5m5DtfVfgKHccnW9P yBAeftIzPs5H7o3gx0t5jCqYFTKd0+ezR4yqfMw1C3PUqbgVf8+29Bny2ty0vG5K2R4D oDk2ECDLuhGGVIPNLsmEEikYXsvJ3h/YWB+uTLu6Bv01w/KkPC1Z+Bs3Pq6nX32TLcnP XS2Xa0Q0xQMOmEl7EdRjB44jfTgfqCDBytUQXvolnSkkFQfzdywCGfhp+PT7/1fKy+2Y YJUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t132si3839114pgc.350.2018.04.04.08.55.21; Wed, 04 Apr 2018 08:55:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752084AbeDDPyQ (ORCPT + 99 others); Wed, 4 Apr 2018 11:54:16 -0400 Received: from mailout.easymail.ca ([64.68.200.34]:55577 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751558AbeDDPyP (ORCPT ); Wed, 4 Apr 2018 11:54:15 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id A54DEC0D4E; Wed, 4 Apr 2018 15:54:14 +0000 (UTC) Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo01-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YyENbpdNo9rF; Wed, 4 Apr 2018 15:54:14 +0000 (UTC) Received: from [192.168.1.87] (c-24-9-64-241.hsd1.co.comcast.net [24.9.64.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id BC845C079D; Wed, 4 Apr 2018 15:54:04 +0000 (UTC) Subject: Re: [PATCH 1/2] selftests/memfd/memfd_test.c: fix implicit declaration To: Mike Kravetz , Anders Roxell Cc: linux-kselftest@vger.kernel.org, Linux Kernel Mailing List , David Herrmann , Shuah Khan , Shuah Khan References: <20180313114205.27714-1-anders.roxell@linaro.org> <204aed15-390c-f8eb-a248-d0f8305ab694@oracle.com> From: Shuah Khan Message-ID: <75028421-267e-bb1f-a912-5387362eef8b@kernel.org> Date: Wed, 4 Apr 2018 09:54:03 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <204aed15-390c-f8eb-a248-d0f8305ab694@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/04/2018 09:32 AM, Mike Kravetz wrote: > On 04/04/2018 04:36 AM, Anders Roxell wrote: >> On 14 March 2018 at 02:09, Mike Kravetz wrote: >>> On 03/13/2018 04:42 AM, Anders Roxell wrote: >>>> gcc warns about implicit declaration. >>>> >>>> gcc -D_FILE_OFFSET_BITS=64 -I../../../../include/uapi/ >>>> -I../../../../include/ -I../../../../usr/include/ >>>> memfd_test.c common.o -o memfd_test >>>> memfd_test.c: In function ‘mfd_assert_get_seals’: >>>> memfd_test.c:74:6: warning: implicit declaration of function ‘fcntl’ >>>> [-Wimplicit-function-declaration] >>>> r = fcntl(fd, F_GET_SEALS); >>>> ^~~~~ >>>> memfd_test.c: In function ‘mfd_assert_open’: >>>> memfd_test.c:197:6: warning: implicit declaration of function ‘open’ >>>> [-Wimplicit-function-declaration] >>>> r = open(buf, flags, mode); >>>> ^~~~ >>>> memfd_test.c: In function ‘mfd_assert_write’: >>>> memfd_test.c:328:6: warning: implicit declaration of function ‘fallocate’ >>>> [-Wimplicit-function-declaration] >>>> r = fallocate(fd, >>>> ^~~~~~~~~ >>>> >>>> In the current code, we include the headers that the functions want >>>> according to the man pages, and we add some defines that will be used if >>>> they isn't found in glibc. The defines was added into the kernel source >>>> in kernel >= 3.16 and glibc requires kernel header files >= 3.2>>>> >>>> Fixes: 4f5ce5e8d7e2 ("selftests: add memfd_create() + sealing tests") >>>> Signed-off-by: Anders Roxell >>>> --- >>>> tools/testing/selftests/memfd/memfd_test.c | 25 ++++++++++++++++++++++++- >>>> 1 file changed, 24 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c >>>> index 10baa1652fc2..0dbeb29c094c 100644 >>>> --- a/tools/testing/selftests/memfd/memfd_test.c >>>> +++ b/tools/testing/selftests/memfd/memfd_test.c >>>> @@ -6,7 +6,6 @@ >>>> #include >>>> #include >>>> #include >>>> -#include We don't want to change this to fix the warnings. This will defeat the purpose of testing the kernel including the headers. >>>> #include >>>> #include >>>> #include >>>> @@ -14,13 +13,37 @@ >>>> #include >>>> #include >>>> #include >>>> +#include >>>> #include >>>> #include >>>> #include >>>> +#include >>>> #include >>> >>> I suspect there is some guiding philosophy for selftests that I am >>> unfamiliar with. However, it seems that tests should use as much >>> of the header files in the current kernel source tree as possible. >>> This change removes the include of a header in the current source >>> tree . It replaces that with the header >>> from the host system (and some other changes). >>> >>> To me, this seems like step in the wrong direction. But, I could >>> be totally wrong and perhaps self tests should primarily target the >>> host system header files. >> >> So in a way I agree with you. However, what was the design decisions >> internal kernel headers vs. headers from Host System ? >> For me it isn't clear how/when we use them, its a mix today is it not? Internal headers are the primary focus to be able to find regressions. > > I am unsure as well. Was hoping someone who was more involved in the > development/design philosophy of self tests would chime in and comment. > > My thought that the tests should use more of the associated kernel header > files is based on the fact that those header files 'should' be more > aligned with the tests. The host system header files could be very > different than those of the running kernel we are testing. Right. The goal for these tests is to verify the kernel including the headers. So for best results, the tests should be built with the headers in the kernel not the ones that are installed on the system they are being built on. thanks, -- Shuah