Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp237674pxb; Wed, 22 Sep 2021 00:37:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywC9eVNcZkmsICI8B7H0gFE45a78gS/vqxgv+R51XU2OpmEFRIqMWVWVTiB/ORiUBj9JQU X-Received: by 2002:a05:6638:168a:: with SMTP id f10mr3560092jat.100.1632296252874; Wed, 22 Sep 2021 00:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632296252; cv=none; d=google.com; s=arc-20160816; b=GDJpp5EYu1VwMED6LiOrWan9nOf1GNZ2zfDfxMtlA9V2mMpTiNj3KTn4en7RkUWJWd XPkK2ojOk+0P5xwGCpgyH+l8O9TCF8CvzfpqGRKvg1V9eEZSdjgBurTFNKgJpR87z6Sa Jee0spIf+7dzW+Kdrw7gwpnHebscbwpDdkzqg/HKzkSIwDdi2eKMYzhGB4HAOYVjRYhJ JcKEzhHC+k8/FJcQmSloe/QubFWJjL1bDM5dYkrq7YkdbRxO9YESAPjyHMBQ5TPOYz2Y JTsBgXrS+8CE1Vtx7wQRT/7qstWI3uqAzauEMKM8DwDvxw2wfsfFCn9Xky5zji1DEiqw EMkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=y3xmmdKaJ8nR6zMAC9GFuFhve4ZAwlWU9AAFlDtP3nY=; b=ndiYDDSsxesuap7kGQoBz2068aYZ2exni4hjI7DQLMbz1T2O8x3mHnpQuArl0QHXc1 Ms0cCm/uCDli8On3juxOIzWyj1OGz3o7DCvN1KvwQhI4r/HamJr1zkaueJrlom+V3w64 uv7zeohsDdvJDf0xtYtMYPM4Srv6F/RLhToxF/oJ+9Z2ai2rXMJ52Xz8SXL5M9BMG+KM /NLsJwgI2Uc//JcGEruwJXv6RQdlge1rj3mlAxSDYTxgQfnHzrhzNUK1hKkOD6H19EMB 1pQrAJSvMrU9WMOLIem5GG9l6SrcMbj3Jyo85Ni6M68c3pbQ2fkvIA3iaryN6XDFpvWg vPaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CTKSvZWT; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si1950040ilq.4.2021.09.22.00.37.18; Wed, 22 Sep 2021 00:37:32 -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=@kernel.org header.s=k20201202 header.b=CTKSvZWT; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233278AbhIVHhr (ORCPT + 99 others); Wed, 22 Sep 2021 03:37:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:43944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233059AbhIVHhp (ORCPT ); Wed, 22 Sep 2021 03:37:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C0DB261168; Wed, 22 Sep 2021 07:36:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632296175; bh=RYczK9r2Lb24aXEBNUuXXiaaKvcxv63ZjxQqm1IKabM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CTKSvZWToZLIn1dx9lQeKlUM8YtZZFL0Tlnet+Hr42Qr4Dwh47akQ3n5LKMG7VYw4 tg06OxQNlB+ar15TnlfHMpP43tcOJhg3MZzwAqadhR3OfgUjIxfGPXrIluZeGhxPoR nsOhxoR25LQD0kaXDThgIGynMNjWfJ/DS1J13tc4muM8kEo9CCe+KW/trgn1JgPkMs tBFJtNxTgkr7z0NbDvd2Hke/G4iQP1b36TZhRwdvk3ele2NhWTwtxdBNseJGN8Y1ee SbDaEA+w78DsCgMOwP25Bt2InxPYbgW5kroFNz+UZdnfuafz8c+dEfbWSILMxrIYRl rQcFwz1Gze6lg== Date: Wed, 22 Sep 2021 09:36:09 +0200 From: Mauro Carvalho Chehab To: Greg Kroah-Hartman Cc: Linux Doc Mailing List , linux-kernel@vger.kernel.org, Jonathan Corbet , Anton Vorontsov , Colin Cross , John Fastabend , KP Singh , Kees Cook , Martin KaFai Lau , Song Liu , Tony Luck , Yonghong Song , bpf@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v3 0/7] get_abi.pl: Check for missing symbols at the ABI specs Message-ID: <20210922093609.34d7bbca@coco.lan> In-Reply-To: References: <20210921201633.5e6128a0@coco.lan> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, 22 Sep 2021 08:22:33 +0200 Greg Kroah-Hartman escreveu: > On Wed, Sep 22, 2021 at 07:43:42AM +0200, Greg Kroah-Hartman wrote: > > On Tue, Sep 21, 2021 at 08:16:33PM +0200, Mauro Carvalho Chehab wrote: > > > Em Tue, 21 Sep 2021 18:52:42 +0200 > > > Greg Kroah-Hartman escreveu: > > >=20 > > > > On Sat, Sep 18, 2021 at 11:52:10AM +0200, Mauro Carvalho Chehab wro= te: > > > > > Hi Greg, > > > > >=20 > > > > > Add a new feature at get_abi.pl to optionally check for existing = symbols > > > > > under /sys that won't match a "What:" inside Documentation/ABI. > > > > >=20 > > > > > Such feature is very useful to detect missing documentation for A= BI. > > > > >=20 > > > > > This series brings a major speedup, plus it fixes a few border ca= ses when > > > > > matching regexes that end with a ".*" or \d+. > > > > >=20 > > > > > patch 1 changes get_abi.pl logic to handle multiple What: lines, = in > > > > > order to make the script more robust; > > > > >=20 > > > > > patch 2 adds the basic logic. It runs really quicky (up to 2 > > > > > seconds), but it doesn't use sysfs softlinks. > > > > >=20 > > > > > Patch 3 adds support for parsing softlinks. It makes the script a > > > > > lot slower, making it take a couple of minutes to process the ent= ire > > > > > sysfs files. It could be optimized in the future by using a graph, > > > > > but, for now, let's keep it simple. > > > > >=20 > > > > > Patch 4 adds an optional parameter to allow filtering the results > > > > > using a regex given by the user. When this parameter is used > > > > > (which should be the normal usecase), it will only try to find so= ftlinks > > > > > if the sysfs node matches a regex. > > > > >=20 > > > > > Patch 5 improves the report by avoiding it to ignore What: that > > > > > ends with a wildcard. > > > > >=20 > > > > > Patch 6 is a minor speedup. On a Dell Precision 5820, after patc= h 6,=20 > > > > > results are: > > > > >=20 > > > > > $ time ./scripts/get_abi.pl undefined |sort >undefined && cat un= defined| perl -ne 'print "$1\n" if (m#.*/(\S+) not found#)'|sort|uniq -c|so= rt -nr >undefined_symbols; wc -l undefined; wc -l undefined_symbols > > > > >=20 > > > > > real 2m35.563s > > > > > user 2m34.346s > > > > > sys 0m1.220s > > > > > 7595 undefined > > > > > 896 undefined_symbols > > > > >=20 > > > > > Patch 7 makes a *huge* speedup: it basically switches a linear O(= n^3) > > > > > search for links by a logic which handle symlinks using BFS. It > > > > > also addresses a border case that was making 'msi-irqs/\d+' regex= to > > > > > be misparsed.=20 > > > > >=20 > > > > > After patch 7, it is 11 times faster: > > > > >=20 > > > > > $ time ./scripts/get_abi.pl undefined |sort >undefined && cat un= defined| perl -ne 'print "$1\n" if (m#.*/(\S+) not found#)'|sort|uniq -c|so= rt -nr >undefined_symbols; wc -l undefined; wc -l undefined_symbols > > > > >=20 > > > > > real 0m14.137s > > > > > user 0m12.795s > > > > > sys 0m1.348s > > > > > 7030 undefined > > > > > 794 undefined_symbols > > > > >=20 > > > > > (the difference on the number of undefined symbols are due to the= fix for > > > > > it to properly handle 'msi-irqs/\d+' regex) > > > > >=20 > > > > > - > > > > >=20 > > > > > While this series is independent from Documentation/ABI changes, = it > > > > > works best when applied from this tree, which also contain ABI fi= xes > > > > > and a couple of additions of frequent missed symbols on my machin= e: > > > > >=20 > > > > > https://git.kernel.org/pub/scm/linux/kernel/git/mchehab/devel= .git/log/?h=3Dget_undefined_abi_v3 =20 > > > >=20 > > > > I've taken all of these, but get_abi.pl seems to be stuck in an end= less > > > > loop or something. I gave up and stopped it after 14 minutes. It = had > > > > stopped printing out anything after finding all of the pci attribut= es > > > > that are not documented :) > > >=20 > > > It is probably not an endless loop, just there are too many vars to > > > check on your system, which could make it really slow. > >=20 > > Ah, yes, I ran it overnight and got the following: > >=20 > > $ time ./scripts/get_abi.pl undefined |sort >undefined && cat undefined= | perl -ne 'print "$1\n" if (m#.*/(\S+) not found#)'|sort|uniq -c|sort -nr = >undefined_symbols; wc -l undefined; wc -l undefined_symbols > >=20 > > real 29m39.503s > > user 29m37.556s > > sys 0m0.851s > > 26669 undefined > > 765 undefined_symbols > >=20 > > > The way the search algorithm works is that reduces the number of rege= x=20 > > > expressions that will be checked for a given file entry at sysfs. It= =20 > > > does that by looking at the devnode name. For instance, when it check= s for > > > this file: > > >=20 > > > /sys/bus/pci/drivers/iosf_mbi_pci/bind > > >=20 > > > The logic will seek only the "What:" expressions that end with "bind". > > > Currently, there are just two What expressions for it[1]: > > >=20 > > > What: /sys/bus/fsl\-mc/drivers/.*/bind > > > What: /sys/bus/pci/drivers/.*/bind > > >=20 > > > It will then run an O(n=C2=B2) algorithm to seek: > > >=20 > > > foreach my $a (@names) { > > > foreach my $w (split /\xac/, $what) { > > > if ($a =3D~ m#^$w$#) { > > > exact =3D 1; > > > last; > > > } > > > } > > > } > > >=20 > > > Which runs quickly, when there are few regexs to seek. There are,=20 > > > however, some What: expressions that end with a wildcard. Those are > > > harder to process. Right now, they're all grouped together, which > > > makes them slower. Most of the processing time are spent on those. > > >=20 > > > I'm working right now on some strategy to also speed up the search=20 > > > for them. Once I get something better, I'll send a patch series. > > >=20 > > > -- > > >=20 > > > [1] On a side note, there are currently some problems with the What: > > > definitions for bind/unbind, as: > > >=20 > > > - it doesn't match all PCI devices; > > > - it doesn't match ACPI and other buses that also export > > > bind/unbind. > > >=20 > > > >=20 > > > > Anything I can do to help debug this? > > > > > > >=20 > > > There are two parameters that can help to identify the issue: > > >=20 > > > a) You can add a "--show-hints" parameter. This turns on some=20 > > > prints that may help to identify what the script is doing. > > > It is not really a debug option, but it helps to identify > > > when some regexes are failing. > > >=20 > > > b) You can limit the What expressions that will be parsed with: > > > --search-string > > >=20 > > > You can combine both. For instance, if you want to make it > > > a lot more verbose, you could run it as: > > >=20 > > > ./scripts/get_abi.pl undefined --search-string /sys --show-hints > >=20 > > Let me run this and time stamp it to see where it is getting hung up on. > > Give it another 30 minutes :) >=20 > Hm, that didn't make too much sense as to what it was stalled on. I've > attached the compressed file if you are curious. Hmm... [07:52:44] --> /sys/devices/pci0000:40/0000:40:01.3/0000:4a:00.1/iommu/amd= -iommu/cap [08:07:52] --> /sys/devices/pci0000:40/0000:40:01.1/0000:41:00.0/0000:42:0= 5.0/iommu/amd-iommu/cap It sounds it took quite a while handling iommu cap, which sounds weird, as it should be looking just 3 What expressions: [07:43:06] What: /sys/class/iommu/.*/amd\-iommu/cap [07:43:06] What: /sys/class/iommu/.*/intel\-iommu/cap [07:43:06] What: /sys/devices/pci.*.*.*.*\:.*.*/0000\:.*.*\:.*.*..*/dma/dm= a.*chan.*/quickdata/cap Maybe there was a memory starvation while running the script, causing swaps. Still, it is weird that it would happen there, as the hashes and arrays used at the script are all allocated before it starts the search logic. Here, the allocation part takes ~2 seconds. At least on my Dell Precision 5820 (12 cpu threads), the amount of memory it uses is not huge: $ /usr/bin/time -v ./scripts/get_abi.pl undefined >/dev/null Command being timed: "./scripts/get_abi.pl undefined" User time (seconds): 12.68 System time (seconds): 1.29 Percent of CPU this job got: 99% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:13.98 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 212608 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 0 Minor (reclaiming a frame) page faults: 52003 Voluntary context switches: 1 Involuntary context switches: 56 Swaps: 0 File system inputs: 0 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0 Unfortunately, I don't have any amd-based machine here, but I'll try to run it later on a big arm server and see how it behaves. > Anyway, this is all in my tree now, and I'll gladly take patches to make > it go faster :) Ok! Thanks, Mauro