Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1765133pxb; Sat, 16 Oct 2021 19:39:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnw9zVYW0XgjxMxSDM0AYhUqqPvHfEo8XJzA2Vqxp162HWS/n14qZNbCqX6dcpVwSc9Dl2 X-Received: by 2002:a62:7904:0:b0:44c:ca08:1956 with SMTP id u4-20020a627904000000b0044cca081956mr20659722pfc.47.1634438347722; Sat, 16 Oct 2021 19:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634438347; cv=none; d=google.com; s=arc-20160816; b=dpv0WOA2KXnKad3P8QPX+dK2CLZ4JOC6CtVjT5e2yv9gxKjeF9iCqyLnSQrFxZoFkQ HSoH9gAshwHSWZF/4kDHMsi9G8cCbSmMYM7YaNlowJQYpuaY8UyfsmjeQsUPOL9Y+RcM yZBXZ3v+t+Bn/pnuCglIs/KEhsNN9uNsNK3VRw6IcidfjASpXvO18VP5nw7AiwQDcDTr 3xD2MUU/U5w57kk0JlKXVrLmhSk4ayp9bEej0k2Mtrh+phm4K710xGVOmftK1kq5Q0cb pV/cUFp2Ow/VcK87zO2JYE+lpi0bdn9pg+k5+y9hRwAKHaGsvvxceGoHW6YswmYB1Ekg Hpvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=q21BemEBT9xiSl83II9mI72B4tHLilVao/GwBgbq/bE=; b=Y0vOjU2u/r/ymvZzJ8RoJJHjnXx/FzwTU5jkAjYzq+4ttU9sA+oFoiwN6fmrPkM08s cj/TQCf00vyaDMbR5Ffr0ikcTYM9S9pRtd5egG+dV83WzrZcLXXZmydbxrAjPIA8+xoG 6K9IMQfUTAvV6Cd1h4C2ELFZ9xeI54TMvZqBbPdgdw2Cem9r9eEhsXfmNx7jBgxS2go+ YdgMXawjDLQQJ4Yr2iCBfBco0XkwWJtGP42EgiQ3SuXRZTY58JbzJTxBhf9VAtC4ZdfK 5OepHXb7QvR4OjLuKaw3cwTEkAk/urIHbA+bYSLyc/BkR0NvnYL7iquoLPgnM945wxaq 8uKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=KS89ThOu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si15790468plh.326.2021.10.16.19.38.55; Sat, 16 Oct 2021 19:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=KS89ThOu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241280AbhJOQ1d (ORCPT + 99 others); Fri, 15 Oct 2021 12:27:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241282AbhJOQ1b (ORCPT ); Fri, 15 Oct 2021 12:27:31 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B9AFC061762 for ; Fri, 15 Oct 2021 09:25:24 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id h10so7751478ilq.3 for ; Fri, 15 Oct 2021 09:25:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=q21BemEBT9xiSl83II9mI72B4tHLilVao/GwBgbq/bE=; b=KS89ThOuupxwC7b/hhZU+KwujC/82lQzJJWhndOGIXtwtCE3vT1I2iKDxSQgyw38Gy gRElRcu+P6GjaAosUyTPNiUUlVk2lmsGwCDAV6lONm5DUYbhnWtSflYde1o0HSj1u49Q KVa6ZSPD3TWuSmw9nYqBgNlsvA83B5I96Atkw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=q21BemEBT9xiSl83II9mI72B4tHLilVao/GwBgbq/bE=; b=6g9ezU1F5kWD9b1mcZtS8h6shcezD76vto/pMElt3gpyPGYvi7+s3Fm4BYV4VEFDJX 0HCHWhi2Z+7AhS+JJUvtoMrfHBztLtMNvlVsqSrbW/iTlgv8XpctXaq3HzCLOolewd9L qG471xd3G/3vWpaPOvbCAhbcGPn3zYgDVhw21+5Dgfi/v0o5x7LiXmJWZSVuKC9fmYXO brl7PhpfWyXE/pTiadO+6RWAUkmYoeRQ9FGoYcxD8aVZQW/g3AG24oBZg3MsPLThd2I/ IwrbH3N0JMnjZljYRfth/ccP95CvtGIGqHFBXQ3EGoN4kHQMS4HPbSaxAKsmJvBY4vhn n9Ig== X-Gm-Message-State: AOAM533jc7Tbbvlg6SFuwW5PRR9VocPgYsw8PfqKf53uLes2ZkB5/YPc wa71HSGanKCUunaD8HEmOIoVsA== X-Received: by 2002:a05:6e02:1e02:: with SMTP id g2mr4417981ila.89.1634315123955; Fri, 15 Oct 2021 09:25:23 -0700 (PDT) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id g20sm2936776ilk.64.2021.10.15.09.25.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Oct 2021 09:25:23 -0700 (PDT) Subject: Re: selftests/vm madv_populate.c test To: David Hildenbrand Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan References: <0a20f6b6-5985-8b3e-a577-7495dcf7d2b8@redhat.com> <3a06d58e-7301-6fbc-a305-d9f7c7220843@linuxfoundation.org> <77f4c6a9-141d-e103-7339-0055cc00f752@redhat.com> <78de0991-8e9a-693c-c020-472daa9ce916@redhat.com> From: Shuah Khan Message-ID: Date: Fri, 15 Oct 2021 10:25:23 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <78de0991-8e9a-693c-c020-472daa9ce916@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/15/21 10:19 AM, David Hildenbrand wrote: > On 15.10.21 18:15, David Hildenbrand wrote: >> On 15.10.21 18:06, David Hildenbrand wrote: >>> On 15.10.21 17:47, David Hildenbrand wrote: >>>> On 15.10.21 17:45, Shuah Khan wrote: >>>>> On 9/18/21 1:41 AM, David Hildenbrand wrote: >>>>>> On 18.09.21 00:45, Shuah Khan wrote: >>>>>>> Hi David, >>>>>>> >>>>>>> I am running into the following warning when try to build this test: >>>>>>> >>>>>>> madv_populate.c:334:2: warning: #warning "missing MADV_POPULATE_READ or MADV_POPULATE_WRITE definition" [-Wcpp] >>>>>>>     334 | #warning "missing MADV_POPULATE_READ or MADV_POPULATE_WRITE definition" >>>>>>>         |  ^~~~~~~ >>>>>>> >>>>>>> >>>>>>> I see that the following handling is in place. However there is no >>>>>>> other information to explain why the check is necessary. >>>>>>> >>>>>>> #if defined(MADV_POPULATE_READ) && defined(MADV_POPULATE_WRITE) >>>>>>> >>>>>>> #else /* defined(MADV_POPULATE_READ) && defined(MADV_POPULATE_WRITE) */ >>>>>>> >>>>>>> #warning "missing MADV_POPULATE_READ or MADV_POPULATE_WRITE definition" >>>>>>> >>>>>>> I do see these defined in: >>>>>>> >>>>>>> include/uapi/asm-generic/mman-common.h:#define MADV_POPULATE_READ       22 >>>>>>> include/uapi/asm-generic/mman-common.h:#define MADV_POPULATE_WRITE      23 >>>>>>> >>>>>>> Is this the case of missing include from madv_populate.c? >>>>>> >>>>>> Hi Shuan, >>>>>> >>>>>> note that we're including "#include ", which in my >>>>>> understanding maps to the version installed on your system instead >>>>>> of the one in our build environment.ing. >>>>>> >>>>>> So as soon as you have a proper kernel + the proper headers installed >>>>>> and try to build, it would pick up MADV_POPULATE_READ and >>>>>> MADV_POPULATE_WRITE from the updated headers. That makes sense: you >>>>>> annot run any MADV_POPULATE_READ/MADV_POPULATE_WRITE tests on a kernel >>>>>> that doesn't support it. >>>>>> >>>>>> See vm/userfaultfd.c where we do something similar. >>>>>> >>>>> >>>>> Kselftest is for testing the kernel with kernel headers. That is the >>>>> reason why there is the dependency on header install. >>>>> >>>>>> >>>>>> As soon as we have a proper environment, it seems to work just fine: >>>>>> >>>>>> Linux vm-0 5.15.0-0.rc1.20210915git3ca706c189db.13.fc36.x86_64 #1 SMP Thu Sep 16 11:32:54 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux >>>>>> [root@vm-0 linux]# cat /etc/redhat-release >>>>>> Fedora release 36 (Rawhide) >>>>> >>>>> This is a distro release. We don't want to have dependency on headers >>>>> from the distro to run selftests. Hope this makes sense. >>>>> >>>>> I still see this on my test system running Linux 5.15-rc5. >>>> >>>> Did you also install Linux headers? I assume no, correct? >>>> >>> >>> What happens in your environment when compiling and running the >>> memfd_secret test? >>> >>> If assume you'll see a "skip" when executing, because it might also >>> refer to the local version of linux headers and although it builds, it >>> really cannot build something "functional". It just doesn't add a >>> "#warning" to make that obvious. >>> >> >> The following works but looks extremely hackish. >> >> diff --git a/tools/testing/selftests/vm/madv_populate.c >> b/tools/testing/selftests/vm/madv_populate.c >> index b959e4ebdad4..ab26163db540 100644 >> --- a/tools/testing/selftests/vm/madv_populate.c >> +++ b/tools/testing/selftests/vm/madv_populate.c >> @@ -14,12 +14,11 @@ >> #include >> #include >> #include >> +#include "../../../../usr/include/linux/mman.h" >> #include >> >> #include "../kselftest.h" >> >> -#if defined(MADV_POPULATE_READ) && defined(MADV_POPULATE_WRITE) >> - >> /* >> * For now, we're using 2 MiB of private anonymous memory for all tests. >> */ >> @@ -328,15 +327,3 @@ int main(int argc, char **argv) >> err, ksft_test_num()); >> return ksft_exit_pass(); >> } >> - >> -#else /* defined(MADV_POPULATE_READ) && defined(MADV_POPULATE_WRITE) */ >> - >> -#warning "missing MADV_POPULATE_READ or MADV_POPULATE_WRITE definition" >> - >> -int main(int argc, char **argv) >> -{ >> - ksft_print_header(); >> - ksft_exit_skip("MADV_POPULATE_READ or MADV_POPULATE_WRITE not >> defined\n"); >> -} >> - >> -#endif /* defined(MADV_POPULATE_READ) && defined(MADV_POPULATE_WRITE) */ >> >> >> There has to be some clean way to achieve the same. >> > > Sorry for the spam, > > diff --git a/tools/testing/selftests/vm/Makefile > b/tools/testing/selftests/vm/Makefile > index d9605bd10f2d..ce198b329ff5 100644 > --- a/tools/testing/selftests/vm/Makefile > +++ b/tools/testing/selftests/vm/Makefile > @@ -23,7 +23,7 @@ MACHINE ?= $(shell echo $(uname_M) | sed -e > 's/aarch64.*/arm64/' -e 's/ppc64.*/p > # LDLIBS. > MAKEFLAGS += --no-builtin-rules > > -CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) > +CFLAGS = -Wall -idirafter ../../../../usr/include $(EXTRA_CFLAGS) > LDLIBS = -lrt -lpthread > TEST_GEN_FILES = compaction_test > TEST_GEN_FILES += gup_test > > > Seems to set the right include path priority. > > Yes. It works on linux-next-20211012 Do you mind sending a me patch for this? thanks, -- Shuah