Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4230671imu; Mon, 7 Jan 2019 18:40:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN4ZwDI6pXcsvRPYq2HzhL4yRExujQ3obql8noNCmjwHxcofdiR6V0bI2g0OVcTxBnTC+UFa X-Received: by 2002:a63:9c1a:: with SMTP id f26mr13128049pge.381.1546915249785; Mon, 07 Jan 2019 18:40:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546915249; cv=none; d=google.com; s=arc-20160816; b=cVk6ZfPo16mbyAhU+LSvk/g5JtEgj5jixjNd8UUDXmVdAfGGiAj+x8kN3QwKufqdSx wxk4qTW2LWUwFRpponXFiHrIDjdqkLAS61j85+nFYJtYZupqsumyJclW87o5azwKjUOU UV4X/KrZGKIJ5Xp2vzsOLG7FEyaRZmXNQYifsjlqzNU3XEnpqudfpzteOuTj/kw1hH70 EnvFCg1DnP0dkNZubQ7EZ+zZQDDSxmgY2h91Du7M4h0AXEe99nH7LyPMlq/pFgI0NTHC UP0XIs1oFZ1v9Ew3aXuIR+SoCVoK3+X+kBrA3vY2COrBbXwiVjhf8kbT3qklMF4XFhwZ FQPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=v6PtAFpx0s+xQpxb5yN+utZgCQLN8oxhJpZ9ly5eSVI=; b=nI9eSrpl+ZL30tZ3FzlgH0cUJvwxFghuBGXnNNApFU2tcG3i0YL86muckcz9uxO/hJ LaXwoKlUe99SDV4JZaz6X6JDiGvtBwNUZAZueS22ANeMIWE7G6p3MtERgBR5AjOPI5rY BbFzc5vJQIvb3PZyMXy9I0x0liA0A1YFJs5vXHx5xt6nD4nbJ53GfbD4jTI6ljykjeOV rqJvO5GOYtGurZyle/Orl2fU7/SayYTjhiCYx4H2a2g6DVn9YJIZ5tY3fvjiktgyUsyw Mx1B+2ZNN+jOBq5XiADZ+aVeRe8cojW/YjQTdFCheka70RV+J8Qyf13/9ixPw+vZoKBU Q9hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="SZa0v2G/"; 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 d9si59390702pgv.123.2019.01.07.18.40.30; Mon, 07 Jan 2019 18:40:49 -0800 (PST) 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; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="SZa0v2G/"; 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 S1727424AbfAHCjO (ORCPT + 99 others); Mon, 7 Jan 2019 21:39:14 -0500 Received: from conssluserg-04.nifty.com ([210.131.2.83]:49250 "EHLO conssluserg-04.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727147AbfAHCjK (ORCPT ); Mon, 7 Jan 2019 21:39:10 -0500 Received: from mail-vk1-f176.google.com (mail-vk1-f176.google.com [209.85.221.176]) (authenticated) by conssluserg-04.nifty.com with ESMTP id x082coBK024989; Tue, 8 Jan 2019 11:38:51 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-04.nifty.com x082coBK024989 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1546915132; bh=v6PtAFpx0s+xQpxb5yN+utZgCQLN8oxhJpZ9ly5eSVI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SZa0v2G/ZFw4iOzp8r0BQIOuoF520KZv04K0S/7aGidTczFb8YtElkedyl8Fe4waE Va3rKampfW9c6Z6tpGJ3IikQxy6vF3TPFx7ryo8wCENJ98eyFAv8MTUMNKSiZD/qzI PQZi8f+tPU38mg0o8kKSoMxSi9Wbda//b7uF+DFC+ts8nz/qjS2VLao96HD70t76y/ eW67FEzZP7GgF0SIrjs1TuFTQXiVpjx6ce/zWa5V1AyyXiBBS7fZfEehF6ZwJtfCXt 4KIjJeh4VCh2sqJb0w4prPhNngQ6Ospu5v5YfZgGEwN3L7Z3rlF9FF/C73Grx0SHOF J+3xf9/ZefSQw== X-Nifty-SrcIP: [209.85.221.176] Received: by mail-vk1-f176.google.com with SMTP id t127so553364vke.8; Mon, 07 Jan 2019 18:38:51 -0800 (PST) X-Gm-Message-State: AJcUukeGQQVSRBjgdWAsk5u1JD11JE1xD3s/haOXoUlY4SGkUuSp84Al SclR443RIqA7XZRmRq9PvZAUAbuo/zEjND8vuO4= X-Received: by 2002:a1f:4d47:: with SMTP id a68mr22904590vkb.34.1546915130339; Mon, 07 Jan 2019 18:38:50 -0800 (PST) MIME-Version: 1.0 References: <20190104195714.30045-1-labbott@redhat.com> <874lakc09x.fsf@concordia.ellerman.id.au> <20190107120716.51d95854.cohuck@redhat.com> <20190107131341.00581863@x1.home> <4b9b6cf2-d39e-8dd2-9271-158489b03a61@ozlabs.ru> <20190107172437.0f0b5331@x1.home> In-Reply-To: From: Masahiro Yamada Date: Tue, 8 Jan 2019 11:38:14 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] vfio_pci: Add local source directory as include To: Alexey Kardashevskiy Cc: Alex Williamson , Cornelia Huck , Michael Ellerman , Laura Abbott , kvm@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 8, 2019 at 11:22 AM Alexey Kardashevskiy wrote: > > > > On 08/01/2019 11:24, Alex Williamson wrote: > > On Tue, 8 Jan 2019 10:52:43 +1100 > > Alexey Kardashevskiy wrote: > > > >> On 08/01/2019 07:13, Alex Williamson wrote: > >>> On Mon, 7 Jan 2019 20:39:19 +0900 > >>> Masahiro Yamada wrote: > >>> > >>>> On Mon, Jan 7, 2019 at 8:09 PM Cornelia Huck wrote: > >>>>> > >>>>> On Mon, 7 Jan 2019 19:12:10 +0900 > >>>>> Masahiro Yamada wrote: > >>>>> > >>>>>> On Mon, Jan 7, 2019 at 6:18 PM Michael Ellerman wrote: > >>>>>>> > >>>>>>> Laura Abbott writes: > >>>>>>>> Commit 7f92891778df ("vfio_pci: Add NVIDIA GV100GL [Tesla V100 SXM2] > >>>>>>>> subdriver") introduced a trace.h file in the local directory but > >>>>>>>> missed adding the local include path, resulting in compilation > >>>>>>>> failures with tracepoints: > >>>>>>>> > >>>>>>>> In file included from drivers/vfio/pci/trace.h:102, > >>>>>>>> from drivers/vfio/pci/vfio_pci_nvlink2.c:29: > >>>>>>>> ./include/trace/define_trace.h:89:42: fatal error: ./trace.h: No such file or directory > >>>>>>>> #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) > >>>>>>>> > >>>>>>>> Fix this by adjusting the include path. > >>>>>>>> > >>>>>>>> Fixes: 7f92891778df ("vfio_pci: Add NVIDIA GV100GL [Tesla V100 SXM2] subdriver") > >>>>>>>> Signed-off-by: Laura Abbott > >>>>> > >>>>> (...) > >>>>> > >>>>>>> Alex I assume you'll merge this fix via the vfio tree? > >>>>>>> > >>>>>>> cheers > >>>>>>> > >>>>>>>> diff --git a/drivers/vfio/pci/Makefile b/drivers/vfio/pci/Makefile > >>>>>>>> index 9662c063a6b1..08d4676a8495 100644 > >>>>>>>> --- a/drivers/vfio/pci/Makefile > >>>>>>>> +++ b/drivers/vfio/pci/Makefile > >>>>>>>> @@ -1,3 +1,4 @@ > >>>>>>>> +ccflags-y += -I$(src) > >>>>>>>> > >>>>>>>> vfio-pci-y := vfio_pci.o vfio_pci_intrs.o vfio_pci_rdwr.o vfio_pci_config.o > >>>>>>>> vfio-pci-$(CONFIG_VFIO_PCI_IGD) += vfio_pci_igd.o > >>>>>>>> -- > >>>>>>>> 2.20.1 > >>>>>> > >>>>>> > >>>>>> Hi. > >>>>>> > >>>>>> If I correctly understand the usage of TRACE_INCLUDE_PATH, > >>>>>> the correct fix should be like follows: > >>>>>> > >>>>>> > >>>>>> diff --git a/drivers/vfio/pci/trace.h b/drivers/vfio/pci/trace.h > >>>>>> index 228ccdb..4d13e51 100644 > >>>>>> --- a/drivers/vfio/pci/trace.h > >>>>>> +++ b/drivers/vfio/pci/trace.h > >>>>>> @@ -94,7 +94,7 @@ TRACE_EVENT(vfio_pci_npu2_mmap, > >>>>>> #endif /* _TRACE_VFIO_PCI_H */ > >>>>>> > >>>>>> #undef TRACE_INCLUDE_PATH > >>>>>> -#define TRACE_INCLUDE_PATH . > >>>>>> +#define TRACE_INCLUDE_PATH ../../drivers/vfio/pci > >>>>>> #undef TRACE_INCLUDE_FILE > >>>>>> #define TRACE_INCLUDE_FILE trace > >>>>> > >>>>> Going from the comments in samples/trace_events/trace-events-sample.h, > >>>>> I think both approaches are possible, and I see both used in various > >>>>> places. > >>>>> > >>>>> Personally, I'd prefer Laura's patch, as it doesn't involve hardcoding > >>>>> a path. > >>> > >>> Numbering options for clarity: > >>> > >>> 1) > >>>> ccflags-y += -I$(src) > >>>> would add the header search path for all files in drivers/vfio/pci/ > >>>> whereas only the drivers/vfio/pci/vfio_pci_nvlink2.c needs it. > >>>> > >>> > >>> 2) > >>>> CFLAGS_vfio_pci_nvlink2.o += -I$(src) > >>>> is a bit better. > >>>> However, it is not obvious why this extra header search path is needed > >>>> until you find vfio_pci_nvlink2.c including trace.h > >>>> > >>> > >>> 3) > >>>> #define TRACE_INCLUDE_PATH ../../drivers/vfio/pci > >>>> clarifies the intention because the related code is all placed in trace.h > >>>> > >>>> > >>>> > >>>> From the comment in include/trace/define_trace.h > >>>> TRACE_INCLUDE_PATH is relative to include/trace/define_trace.h > >>> > >>> In my scan of the tree, the most common solution seems to be 2) as this > >>> is essentially recommended in the sample file. 3) is well represented, > >>> with much fewer examples of 1), though it might depend how liberally > >>> we grep out or examine the use cases. Choice 1) also seems to be the > >>> most shotgun approach, adding to the search path for all files. > >> > >> > >> The shotgun approach is always used when compiling out of tree which is > >> what many people do anyway without realizing that there are additional > >> -I. Why do not we make in-tree behave the same way? Thanks, > > > > Are you suggesting bandaging this individual leaf directory, as in > > choice 1), because it's no worse than what happens for an out-of-tree > > build anyway, > > > I suggest making in-tree and out-of-tree behavior equal - both either > fail or compile. Just makes sense to me. > > Since out-of-tree adds extra -I, then there should have been a reason > for that at the time (before 2005 though). Unfortunately git blame does > not say why it was done this way for out-of-tree so imho the safest > thing is to add -I for in-tree as well. Or ditch extra -I and do 2) or > 3) - this is fine too and can count as an impressive compile > optimization, although... look below :) For the out-of-tree building, scripts/Makefile.lib adds -I$(srctree)/$(src) and -I$(obj). In my understanding, -I$(srctree)/$(src) is for including check-in headers from generated C files. -I$(obj) is for including generated headers from check-in C files. One example of the correct usage of this is, crypto/rsa_helper.c (check-in file) includes crypto/rsapubkey.asn1.h (generated fle) Those extra header search paths are unneeded for in-tree building since generated files and check-in files exist in the same tree. You just happened to find it works for out-of-tree building. We are talking about how to make include/trace/define_trace.h include drivers/vfio/pci/trace.h The build system cannot (should not) cater to such a particular case. > > > or are you suggesting to fix the in-tree build behavior to > > be as inefficient as the out-of-tree behavior in general? > > Inefficient you say. Hm. > > I tried this: > > --- scripts/Makefile.lib.old 2019-01-08 11:39:51.830983393 +1100 > +++ scripts/Makefile.lib 2019-01-08 13:09:54.199054981 +1100 > @@ -140,11 +140,6 @@ > # If building the kernel in a separate objtree expand all occurrences > # of -Idir to -I$(srctree)/dir except for absolute paths (starting with > '/'). > > -ifeq ($(KBUILD_SRC),) > -__c_flags = $(_c_flags) > -__a_flags = $(_a_flags) > -__cpp_flags = $(_cpp_flags) > -else > > # -I$(obj) locates generated .h files > # $(call addtree,-I$(obj)) locates .h files in srctree, from generated > .c files > @@ -154,7 +149,6 @@ > $(call flags,_c_flags) > __a_flags = $(call flags,_a_flags) > __cpp_flags = $(call flags,_cpp_flags) > -endif > > > Compiled 3 times with the patch and without, "make clean ; time make > -j200 vmlinux modules". > > No patch: > > real 4m33.047s user 481m48.322s sys 10m15.639s > real 4m29.038s user 480m22.873s sys 10m11.394s > real 4m34.373s user 483m7.570s sys 10m10.559s > > With the patch: > > real 4m32.008s user 479m54.207s sys 10m13.075s > real 4m30.027s user 479m46.272s sys 10m15.886s > real 4m31.548s user 480m2.897s sys 10m10.024 > > > which is slightly faster but I guess within accuracy. > > > > > It appears > > to me that options 2) and 3) are the intended solutions for this issue > > while 1) is more of a workaround. Thanks, > > > > Alex > > > >>> From a > >>> maintenance perspective I agree that 2) seems more error prone, > >>> especially when the build system only catches the error on in-tree > >>> builds, something I rarely do. Therefore I'm leaning towards option > >>> 3). The hardcoded path here doesn't seem much of an issue relative to > >>> the negatives of the other approaches (how often do we move these > >>> files?) and it keeps the trace support relatively self-contained. Are > >>> there further arguments for or against these options? Otherwise who > >>> wants to formally post the TRACE_INCLUDE_PATH version? Thanks, > > > > > -- > Alexey -- Best Regards Masahiro Yamada