From mboxrd@z Thu Jan 1 00:00:00 1970 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 7F5BCD3C533 for ; Thu, 17 Oct 2024 22:11:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D0FD6B007B; Thu, 17 Oct 2024 18:11:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 059F26B0082; Thu, 17 Oct 2024 18:11:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E157A6B0083; Thu, 17 Oct 2024 18:11:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C09D06B007B for ; Thu, 17 Oct 2024 18:11:29 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8BC05A166F for ; Thu, 17 Oct 2024 22:11:08 +0000 (UTC) X-FDA: 82684491204.24.887FDD6 Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) by imf19.hostedemail.com (Postfix) with ESMTP id A703E1A000B for ; Thu, 17 Oct 2024 22:11:14 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=google header.b=IapN9eXg; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf19.hostedemail.com: domain of skhan@linuxfoundation.org designates 209.85.166.171 as permitted sender) smtp.mailfrom=skhan@linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729202980; a=rsa-sha256; cv=none; b=xj6Qx5/15KL8mkROxqccwAN6M2YBmDWAN8aPrbfguAUqPdp3y+u46QA6xEyfcShM8IeZGp EW3TDng8d5PmyZ7X8cYnWhWIn7V+hy3hkSvf/AqhzYhAzNAVXlc3wKA6xupoVA0tIGUEEe OI1NeSyeal9NLckLVJPIqHgtuz+3hTI= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=google header.b=IapN9eXg; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf19.hostedemail.com: domain of skhan@linuxfoundation.org designates 209.85.166.171 as permitted sender) smtp.mailfrom=skhan@linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729202980; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=80fvdKHL+LkkjROKMT2nujzFhw5zymQ3Xd+BXMmYCek=; b=vHDVssYHldpf1A5t4aQD65GyxGoFkYcIQW2OrrAisRoiv3h+vMoRT3NTgjgT8PbTp3QfMV pnFoZ+cFn9b45/LfMk1V4iXnDRrblbYdS16yWxH6C1k0kSMiKFhdx65CCHYZNOnrcZNOR/ Bxw0M5Xe3xrkeSIRJLSFLPghFMdPULU= Received: by mail-il1-f171.google.com with SMTP id e9e14a558f8ab-3a3b8b34be9so5848195ab.2 for ; Thu, 17 Oct 2024 15:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1729203086; x=1729807886; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=80fvdKHL+LkkjROKMT2nujzFhw5zymQ3Xd+BXMmYCek=; b=IapN9eXgVx2P5DS+BjBrpYkg6e/IV4THpYe8DaDOBsEB4330qC2tDDSa12cvQYG9vT V3DWTTaiwBVFpALdBtT0H5AtNdDogYC4QTQ4fVSpLxH9Fhmcz6rIZ8aynLuV72rqpGjR NVRXZMZ4kX/0E4tkKvOe1DINCHQyyv3hYKNmQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729203086; x=1729807886; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=80fvdKHL+LkkjROKMT2nujzFhw5zymQ3Xd+BXMmYCek=; b=AP1ANaArszyHgL9w3rIX/rCEpj7YDtS588yE2aoLikkpqCVTPpj7hhQV5He+ynuh+h RiIWg+wIRRLRcRWyNy46XMRKFThlDyGChGtFtjiaN2vdNmPIxa4qJrqe3MK9Y5n66eIF TnYmcLurKHzziIVCQXuzP4U1Z+ndm/sm54qZiCjEYy1ztscPu8fSiaj7CsnAz5C0AXid R+oBqYDVOV0X4OadS8oRDh9ymUMfSW6Zh/+zUwYxDafaIraJ6cZEgRCwG8xuqJFnePoY ijD/LtlntvjdLESKSG4mYbm8j2Y6+Yjl7EE4gMfTx2/lDWJSR+Pgq8wlaYfjd5FZxlBj HqnA== X-Forwarded-Encrypted: i=1; AJvYcCXJobTvOtV00j3Xdc8nzZUCBFw4K/S7FSwnISPJIpQtSX50n0yRn9mmX10SwXkytzs4EDbgEr/3lw==@kvack.org X-Gm-Message-State: AOJu0Yz3AfX47GNxze3o9Qtgpqnf7w5tSiJaonbp50UkbBAGBxNa+Zf6 XCumsWG2I1mEoRL0d8vlLRzmE0KnbiqY3ZXbDOetmVRB8nZgg6miKhFrQ4C+yJ8= X-Google-Smtp-Source: AGHT+IGRDu7myT8V60NfvWUuXuL9jKLj9q5dD9aFUZOLMttTXNFIQ4EOoYcRbPFcwugpa5vCSEVEHA== X-Received: by 2002:a05:6e02:13a7:b0:3a0:a311:6773 with SMTP id e9e14a558f8ab-3a3f40b531fmr2839035ab.21.1729203086340; Thu, 17 Oct 2024 15:11:26 -0700 (PDT) Received: from [192.168.1.128] ([38.175.170.29]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a3f3fd7e9bsm563435ab.4.2024.10.17.15.11.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Oct 2024 15:11:25 -0700 (PDT) Message-ID: Date: Thu, 17 Oct 2024 16:11:24 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 3/4] selftests: pidfd: add pidfd.h UAPI wrapper To: John Hubbard , Lorenzo Stoakes , Christian Brauner Cc: Shuah Khan , "Liam R . Howlett" , Suren Baghdasaryan , Vlastimil Babka , pedro.falcato@gmail.com, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Sang , Shuah Khan References: <7df771b9-bfd6-465e-b0ba-12d2aab13ec6@nvidia.com> Content-Language: en-US From: Shuah Khan In-Reply-To: <7df771b9-bfd6-465e-b0ba-12d2aab13ec6@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: A703E1A000B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 6xd1orj3d88cjyhnxf6zg595s7cedd7c X-HE-Tag: 1729203074-831752 X-HE-Meta: U2FsdGVkX1+JvAcFYVwmbdz8fkRqJsvk770aGArtMSylEXMoJqSBRw+HdfDiPwFqDblVruaL8dnrTKVZC8BHhdMkWmhOHB5Nj/Ajn4sKfIl4Y2kIDIp3BqDKcL2wlbOmmI7mPBfKdGveUxPXQmahH9vxJf/BirmPa/Ky4BS+PekypSjLLCC5pmtSZkIoQtvIuTQymOBW99+M5UCIVm3IMJpN3A7j2jedE+c5qC5SuX+vItEM5uFxFvu/ZPAeW2M3vekXzzpEcUr6syyxxyZKXkEoXHI770scC2AdwhO0KuTHWJeR6vuKqn6vm9+RghDQ3RiFDhEt/XD+2maIyxnrU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paAQTcWSxgPemk96Ahr4EBdO2YzxT09Uif757uIXhz7G+LCdPL4Jf/nrKcf64pcCsiFe2PwLwUzd+QzCN7Eu8Mn8o6O9WKo+bl7kdA== 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: List-Subscribe: List-Unsubscribe: On 10/17/24 15:45, John Hubbard wrote: > On 10/17/24 2:05 PM, Lorenzo Stoakes wrote: >> Conflicts can arise between system fcntl.h and linux/fcntl.h, imported by >> the linux/pidfd.h UAPI header. >> >> Work around this by adding a wrapper for linux/pidfd.h to >> tools/include/ which sets the linux/fcntl.h header guard ahead of >> importing the pidfd.h header file. >> >> Adjust the pidfd selftests Makefile to reference this include directory and >> put it at a higher precidence than any make header installed headers to >> ensure the wrapper is preferred. > > ...but we are not actually using the installed headers, now. And we intend > to continue avoiding them. So the ordering shouldn't matter. More below: > >> >> This way we can directly import the UAPI header file without issue, use the >> latest system header file without having to duplicate anything. >> >> Reviewed-by: Shuah Khan >> Signed-off-by: Lorenzo Stoakes >> --- >>   tools/include/linux/pidfd.h            | 14 ++++++++++++++ >>   tools/testing/selftests/pidfd/Makefile |  3 +-- >>   2 files changed, 15 insertions(+), 2 deletions(-) >>   create mode 100644 tools/include/linux/pidfd.h >> >> diff --git a/tools/include/linux/pidfd.h b/tools/include/linux/pidfd.h >> new file mode 100644 >> index 000000000000..113c8023072d >> --- /dev/null >> +++ b/tools/include/linux/pidfd.h >> @@ -0,0 +1,14 @@ >> +/* SPDX-License-Identifier: GPL-2.0-only */ >> + >> +#ifndef _TOOLS_LINUX_PIDFD_H >> +#define _TOOLS_LINUX_PIDFD_H >> + >> +/* >> + * Some systems have issues with the linux/fcntl.h import in linux/pidfd.h, so >> + * work around this by setting the header guard. >> + */ >> +#define _LINUX_FCNTL_H >> +#include "../../../include/uapi/linux/pidfd.h" >> +#undef _LINUX_FCNTL_H > > Oh shoot, I think you, Shuah and I were referring to different uapi locations, > the whole time. And so the basic approach is different after all. > > Your include path above actually refers to: > >     $(top_srcdir)/include/uapi/linux/fcntl.h Correct. I am glad we are on the same page now. > > ...but what I was intending was to copy a snapshot of that file (or a > snapshot from the one generated by "make headers"), to here: > >     $(top_srcdir)/tools/include/uapi/linux/fcntl.h So why do the copy and snapshot. Anytime you build userspace in the reoo - you will need to run "make headers: whether you install them under tools/include or include. > > ...and then use $(TOOLS_INCLUDES), which is already in selftests/lib.mk, > for that reason: to be available to all of the kselftests: > >     TOOLS_INCLUDES := -isystem $(top_srcdir)/tools/include/uapi Yes some tests do include that. > > The reasoning for this directory is further explained here: > >     tools/include/uapi/README > > (And I see that selftests/proc has started using $(TOOLS_INCLUDES), that's > progress.) Yes the same problems apply here - what complicates this more is selftests are supposed to test kernel changes, hence the need to include latest kernel headers. The simple solution is adding a dependency so we don't have to duplicate the headers. I don't believe the perf solution works here. We will have to figure out a solution. > > And now, it's possible to change fcntl.h in place, instead of using a wrapper. > Although either way seems OK to me. (I'm sort of ignoring the details of > the actual header file conflict itself, for now.) > > >> + >> +#endif /* _TOOLS_LINUX_PIDFD_H */ >> diff --git a/tools/testing/selftests/pidfd/Makefile b/tools/testing/selftests/pidfd/Makefile >> index d731e3e76d5b..f5038c9dae14 100644 >> --- a/tools/testing/selftests/pidfd/Makefile >> +++ b/tools/testing/selftests/pidfd/Makefile >> @@ -1,8 +1,7 @@ >>   # SPDX-License-Identifier: GPL-2.0-only >> -CFLAGS += -g $(KHDR_INCLUDES) -pthread -Wall >> +CFLAGS += -g -isystem $(top_srcdir)/tools/include $(KHDR_INCLUDES) -pthread -Wall > > Instead, it would look like this, which now mostly matches selftests/mm/Makefile, > which is also helpful, because eventually this can be factored into a common > piece for all selftests: > >     CFLAGS += -g -isystem $(KHDR_INCLUDES) $(TOOLS_INCLUDES) -pthread -Wall KHDR_INCLUDES is "make headers" location under the root directory. So what happens when you add TOOLS_INCLUDES to it. Does "make kselftest-all" work as it is supposed to? If it and all tests can build then I am all for it. > > I apologize for just now noticing this! And these kselftests shouldn't require > so much fussing around, I know. But once we get this just right, it will work > well and last a long time. :) > On the contrary if we don't discuss/fuss and get this right, we have to deal with changes like adding local defines and adhoc approaches in individual tests - that is one reason we made the "make headers" as a dependency. I would like to solve the problem of proliferation of local defines and even system calls in some cases. For now I am going let this patch go through as it is important to add tests. My goals are simple: - no local defines unless it is abslulutely necessary - be able to build tests that add coverage for new kernel api and features before we release the kernel. - make it easier for CIs to build and run tests - continue to have tests works for kernel developres e.g: mm developers build tests in mm directory. They don't see the issues that crop up in CIs or running the entire kselftest default run like CIs do. Adhoc changes break some use-cases. thanks, -- Shuah