From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id E14386CC8 for ; Thu, 19 May 2016 08:08:56 +0200 (CEST) Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7E2D3750FB; Thu, 19 May 2016 06:08:55 +0000 (UTC) Received: from sopuli.koti.laiskiainen.org (vpn1-5-221.ams2.redhat.com [10.36.5.221]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4J68qbn002832; Thu, 19 May 2016 02:08:53 -0400 To: Neil Horman References: <1463431287-4551-1-git-send-email-nhorman@tuxdriver.com> <1463431287-4551-5-git-send-email-nhorman@tuxdriver.com> <3ee4159d-fd29-1a20-1417-4c0a40c18779@redhat.com> <20160518120300.GA29900@hmsreliant.think-freely.org> <20160518134817.GB29900@hmsreliant.think-freely.org> Cc: dev@dpdk.org, Bruce Richardson , Thomas Monjalon , Stephen Hemminger From: Panu Matilainen Message-ID: <4e9a5124-8ea0-7f23-9268-fde1b5d4af02@redhat.com> Date: Thu, 19 May 2016 09:08:52 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <20160518134817.GB29900@hmsreliant.think-freely.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 19 May 2016 06:08:55 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH 4/4] pmd_hw_support.py: Add tool to query binaries for hw support information X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 May 2016 06:08:57 -0000 On 05/18/2016 04:48 PM, Neil Horman wrote: > On Wed, May 18, 2016 at 03:48:12PM +0300, Panu Matilainen wrote: >> On 05/18/2016 03:03 PM, Neil Horman wrote: >>> On Wed, May 18, 2016 at 02:48:30PM +0300, Panu Matilainen wrote: >>>> On 05/16/2016 11:41 PM, Neil Horman wrote: >>>>> This tool searches for the primer sting PMD_DRIVER_INFO= in any ELF binary, >>>>> and, if found parses the remainder of the string as a json encoded string, >>>>> outputting the results in either a human readable or raw, script parseable >>>>> format >>>>> >>>>> Signed-off-by: Neil Horman >>>>> CC: Bruce Richardson >>>>> CC: Thomas Monjalon >>>>> CC: Stephen Hemminger >>>>> CC: Panu Matilainen >>>>> --- >>>>> tools/pmd_hw_support.py | 174 ++++++++++++++++++++++++++++++++++++++++++++++++ >>>>> 1 file changed, 174 insertions(+) >>>>> create mode 100755 tools/pmd_hw_support.py >>>>> >>>>> diff --git a/tools/pmd_hw_support.py b/tools/pmd_hw_support.py >>>>> new file mode 100755 >>>>> index 0000000..0669aca >>>>> --- /dev/null >>>>> +++ b/tools/pmd_hw_support.py >>>>> @@ -0,0 +1,174 @@ >>>>> +#!/usr/bin/python3 >>>> >>>> I think this should use /usr/bin/python to be consistent with the other >>>> python scripts, and like the others work with python 2 and 3. I only tested >>>> it with python2 after changing this and it seemed to work fine so the >>>> compatibility side should be fine as-is. >>>> >>> Sure, I can change the python executable, that makes sense. >>> >>>> On the whole, AFAICT the patch series does what it promises, and works for >>>> both static and shared linkage. Using JSON formatted strings in an ELF >>>> section is a sound working technical solution for the storage of the data. >>>> But the difference between the two cases makes me wonder about this all... >>> You mean the difference between checking static binaries and dynamic binaries? >>> yes, there is some functional difference there >>> >>>> >>>> For static library build, you'd query the application executable, eg >>> Correct. >>> >>>> testpmd, to get the data out. For a shared library build, that method gives >>>> absolutely nothing because the data is scattered around in individual >>>> libraries which might be just about wherever, and you need to somehow >>> Correct, I figured that users would be smart enough to realize that with >>> dynamically linked executables, they would need to look at DSO's, but I agree, >>> its a glaring diffrence. >> >> Being able to look at DSOs is good, but expecting the user to figure out >> which DSOs might be loaded and not and where to look is going to be well >> above many users. At very least it's not what I would call user-friendly. >> > I disagree, there is no linkage between an application and the dso's it opens > via dlopen that is exportable. The only way to handle that is to have a > standard search path for the pmd_hw_info python script. Thats just like modinfo > works (i.e. "modinfo bnx2" finds the bnx2 module for the running kernel). We > can of course do something simmilar, but we have no existing implicit path > information to draw from to do that (because you can have multiple dpdk installs > side by side). The only way around that is to explicitly call out the path on > the command line. There's no telling what libraries user might load at runtime with -D, that is true for both static and shared libraries. When CONFIG_RTE_EAL_PMD_PATH is set, as it is likely to be on distro builds, you *know* that everything in that path will be loaded on runtime regardless of what commandline options there might be so the situation is actually on par with static builds. Of course you still dont know about ones added with -D but that's a limitation of any solution that works without actually running the app. > >>>> discover the location + correct library files to be able to query that. For >>>> the shared case, perhaps the script could be taught to walk files in >>>> CONFIG_RTE_EAL_PMD_PATH to give in-the-ballpark correct/identical results >>> My initial thought would be to run ldd on the executable, and use a heuristic to >>> determine relevant pmd DSO's, and then feed each of those through the python >>> script. I didn't want to go to that trouble unless there was consensus on it >>> though. >> >> Problem is, ldd doesn't know about them either because the pmds are not >> linked to the executables at all anymore. They could be force-linked of >> course, but that means giving up the flexibility of plugins, which IMO is a >> no-go. Except maybe as an option, but then that would be a third case to >> support. >> > Thats not true at all, or at least its a perfectly valid way to link the DSO's > in at link time via -lrte_pmd_. Its really just the dlopen case we need > to worry about. I would argue that, if they're not explicitly linked in like > that, then its correct to indicate that an application supports no hardware, > because it actually doesn't, it only supports the pmds that it chooses to list > on the command line. And if a user is savy enough to specify a pmd on the > application command line, then they are perfectly capable of specifying the same > path to the hw_info script. Yes you can force-link apps to every driver on existence, but it requires not just linking but using --whole-archive. The apps in DPDK itself dont in shared link setup (take a look at testpmd) and I think its for a damn good reason - the drivers are plugins and that's how plugins are expected to work: they are not linked to, they reside in a specific path which is scanned at runtime and plugins loaded to provide extra functionality. >> >>> >>>> when querying the executable as with static builds. If identical operation >>>> between static and shared versions is a requirement (without running the app >>>> in question) then query through the executable itself is practically the >>>> only option. Unless some kind of (auto-generated) external config file >>>> system ala kernel depmod / modules.dep etc is brought into the picture. >>> Yeah, I'm really trying to avoid that, as I think its really not a typical part >>> of how user space libraries are interacted with. >>> >>>> >>>> For shared library configurations, having the data in the individual pmds is >>>> valuable as one could for example have rpm autogenerate provides from the >>>> data to ease/automate installation (in case of split packaging and/or 3rd >>>> party drivers). And no doubt other interesting possibilities. With static >>>> builds that kind of thing is not possible. >>> Right. >>> >>> Note, this also leaves out PMD's that are loaded dynamically (i.e. via dlopen). >>> For those situations I don't think we have any way of 'knowing' that the >>> application intends to use them. >> >> Hence my comment about CONFIG_RTE_EAL_PMD_PATH above, it at least provides a >> reasonable heuristic of what would be loaded by the app when run. But >> ultimately the only way to know what hardware is supported at a given time >> is to run an app which calls rte_eal_init() to load all the drivers that are >> present and work from there, because besides CONFIG_RTE_EAL_PMD_PATH this >> can be affected by runtime commandline switches and applies to both shared >> and static builds. >> > I'm not sure I agree with that. Its clearly tempting to use, but its not > at all guaranteed to be accurate (the default is just set to "", and there is no > promise anyone will set it properly). The promise is that shared builds are barely functional unless its set correctly, because zero drivers are linked to testpmd in shared config. So you're kinda likely to notice if its not set. It defaults to empty because at the time there was no standard installation available at that time. Setting a reasonable default is tricky still because it needs to be set before build whereas install path is set at install time. > And it also requires that the binary will > be tied to a specific release. I really think that, given the fact that > distributions generally try to package dpdk in such a way that multiple dpdk > versions might be available, the right solution is to just require a full path > specification if you want to get hw info for a DSO that is dynamically loaded > via dlopen from the command line. Otherwise you're going to fall into this trap > where you might be looking implicitly at an older version of the PMD while your > application may use a newer version. If there are multiple dpdk versions available then they just need to have separate PMD paths, but that's not a problem. >>>> >>>> Calling up on the list of requirements from >>>> http://dpdk.org/ml/archives/dev/2016-May/038324.html, I see a pile of >>>> technical requirements but perhaps we should stop for a moment to think >>>> about the use-cases first? >>> >>> To ennumerate the list: >>> >>> - query all drivers in static binary or shared library (works) >>> - stripping resiliency (works) >>> - human friendly (works) >>> - script friendly (works) >>> - show driver name (works) >>> - list supported device id / name (works) >>> - list driver options (not yet, but possible) >>> - show driver version if available (nope, but possible) >>> - show dpdk version (nope, but possible) >>> - show kernel dependencies (vfio/uio_pci_generic/etc) (nope) >>> - room for extra information? (works) >>> >>> Of the items that are missing, I've already got a V2 started that can do driver >>> options, and is easier to expand. Adding in the the DPDK and PMD version should >>> be easy (though I think they can be left out, as theres currently no globaly >>> defined DPDK release version, its all just implicit, and driver versions aren't >>> really there either). I'm also hesitant to include kernel dependencies without >>> defining exactly what they mean (just module dependencies, or feature >>> enablement, or something else?). Once we define it though, adding it can be >>> easy. >> >> Yup. I just think the shared/static difference needs to be sorted out >> somehow, eg requiring user to know about DSOs is not human-friendly at all. >> That's why I called for the higher level use-cases in my previous email. >> > > I disagree with that. While its reasonable to give users the convienience of > scanning the DT_NEEDED entries of a binary and scanning those DSO's. If a user Scanning DT_NEEDED is of course ok sane and right thing to do, its just not sufficient. > has to specify the PMD to load in an application (either on the command line or > via a configuration file), then its reasonable assume that they (a) know where But when the PMD path is set (as it should be on a distro build), this is all automatic with zero action or extra config required from the user. > to find that pmd and (b) are savy enough to pass that same path to a hardware > info tool. Thats the exact same way that modinfo works (save for the fact that > modinfo can implicitly check the running kernel version to find the appropriate > path for a modular driver). > > The only other thing that seems reasonable to me would be to scan > LD_LIBRARY_PATH. I would assume that, if an application is linked dynamically, > the individual DSO's (librte_sched.so, etc), need to be in LD_LIBRARY_PATH. If > thats the case, then we can assume that the appropriate PMD DSO's are there too, > and we can search there. We can also check the standard /usr/lib and /lib paths > with that. I think that would make fairly good sense. You really don't want go crashing through the potentially thousands of libraries in the standard library path going "is it a pmd, no, is it a pmd, no..." - Panu - > >>> >>> I'll have a v2 posted soon, with the consensus corrections you have above, as >>> well as some other cleanups >>> >>> Best >>> Neil >>> >>>> >>>> To name some from the top of my head: >>>> - user wants to know whether the hardware on the system is supported >>>> - user wants to know which package(s) need to be installed to support the >>>> system hardware >>>> - user wants to list all supported hardware before going shopping >>>> - [what else?] >>>> >>>> ...and then think how these things would look like from the user >>>> perspective, in the light of the two quite dramatically differing cases of >>>> static vs shared linkage. >> >> >> - Panu - >>