Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4767480pxb; Tue, 28 Sep 2021 03:45:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzChXxcfZrtqTXL4dRBE/5CROTalIU47bFtuc5IfWDIQ55zTLK3XXHvaPKgQdXI6+bQSyEE X-Received: by 2002:aa7:9282:0:b0:3e2:800a:b423 with SMTP id j2-20020aa79282000000b003e2800ab423mr4660621pfa.21.1632825938328; Tue, 28 Sep 2021 03:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632825938; cv=none; d=google.com; s=arc-20160816; b=0PHnrW0H0JszgsYbk7mDvpFCuhJovBG0w0cP7kjINxElTWOhDIvq/jZusCumUPeS38 WxMKVB7MQnqFn00V5Nr7pKuzyFFtF6t3Hy6BoI1m0epoPsRkf6jBjEe9qau2LPTfozIm H0QZ6ecLfUakXzDjVRYIH8sqhBdeEG2f10HXuXCT5WGaHvyZbMLi7XJc3wkYF76hyb6H IsS1PVcHqXjNYVVGl4SZBQ8/av12ndlxRWlHieUpNLUcQOHIkXFgVHlrtm8N39B2SCJf NPEW5IO98rGbSpNKf4Ah67PSkuy0yz7r2xF4nBWOw78ad7Lb62UQKeyDRc8lg2Ml4XQI MzjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=I+FRh3UKPLpeItWNxz5AxwVh/vaukzCPXMdfg3J36pY=; b=I5eFGHeSRCZ2bAFqXoTHY/CTUkNbgd2bNqpQ4cOTq8rtYNBb0iwzneU66TWl3jMnq7 zo1VnUYCgMiUGV7ArLtLrr2wh2N+21bTS+5tEXjspaWIDnknfGsBUEgAP5tWRwPZMd+d 6EDzV/PQFM5ewKRGBYvraMiZXKmwJl6BA3NfP0XoRYchY6bHVBxBJFjsOQt11ipILBkW r0b3vZhLXqipIPt1lNqbKwvfeOrnOHZbHnYz+20cJVOk3oRQg9lMOh2pxOpZBd24E5zo XQ3v0fwQMrBnmHby3xXzUv0jPkAcVHHalHNFeiP1gBkyzNgc2AiJ51h1Tz4ePxrelRpZ tzlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kUExyV2p; 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 n3si2936354pjh.74.2021.09.28.03.45.24; Tue, 28 Sep 2021 03:45:38 -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=korg header.b=kUExyV2p; 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 S240162AbhI1KpW (ORCPT + 99 others); Tue, 28 Sep 2021 06:45:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:50424 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234543AbhI1KpV (ORCPT ); Tue, 28 Sep 2021 06:45:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B4842610FC; Tue, 28 Sep 2021 10:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632825822; bh=fkAve8tKE0y/DXgMCdT+P095PTJ4abta0bz1NSD8BBM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kUExyV2pfYCt4LLFGN4K7GmTM/FjjXtmxeOViCwHeos+zdYqMakULok5AyM1gzNKT uR4fXQYuxB9bzOqg9gbsx5giKwF7vvOmEKwtiHvgTd2mY+qSqgDHmYC8rEXIfAsxlN 3IHJoOPN4ALWOCkkE5KAq856sPGBvlu+9h+sZPMc= Date: Tue, 28 Sep 2021 12:43:40 +0200 From: Greg Kroah-Hartman To: Mauro Carvalho Chehab Cc: Linux Doc Mailing List , linux-kernel@vger.kernel.org, Jonathan Corbet Subject: Re: [PATCH 0/8] (REBASED) get_abi.pl undefined: improve precision and performance Message-ID: References: <20210927105553.105f22c5@coco.lan> <20210927153942.75bbb9cf@coco.lan> <20210928120304.62319fba@coco.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210928120304.62319fba@coco.lan> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 28, 2021 at 12:03:04PM +0200, Mauro Carvalho Chehab wrote: > Em Mon, 27 Sep 2021 17:48:05 +0200 > Greg Kroah-Hartman escreveu: > > > On Mon, Sep 27, 2021 at 03:39:42PM +0200, Mauro Carvalho Chehab wrote: > > > Em Mon, 27 Sep 2021 11:23:20 +0200 > > > Greg Kroah-Hartman escreveu: > > > > > > > On Mon, Sep 27, 2021 at 10:55:53AM +0200, Mauro Carvalho Chehab wrote: > > > > > Em Thu, 23 Sep 2021 19:13:04 +0200 > > > > > Greg Kroah-Hartman escreveu: > > > > > > > > > > > On Thu, Sep 23, 2021 at 05:41:11PM +0200, Mauro Carvalho Chehab wrote: > > > > > > > Hi Greg, > > > > > > > > > > > > > > As requested, this is exactly the same changes, rebased on the top of > > > > > > > driver-core/driver-core-next. > > > > > > > > > > > > > > - > > > > > > > > > > > > > > It follows a series of improvements for get_abi.pl. it is on the top of driver-core/driver-core-next. > > > > > > > > > > > > > > With such changes, on my development tree, the script is taking 6 seconds to run > > > > > > > on my desktop: > > > > > > > > > > > > > > $ !1076 > > > > > > > $ time ./scripts/get_abi.pl undefined |sort >undefined_after && cat undefined_after| perl -ne 'print "$1\n" if (m#.*/(\S+) not found#)'|sort|uniq -c|sort -nr >undefined_symbols; wc -l undefined_after undefined_symbols > > > > > > > > > > > > > > real 0m6,292s > > > > > > > user 0m5,640s > > > > > > > sys 0m0,634s > > > > > > > 6838 undefined_after > > > > > > > 808 undefined_symbols > > > > > > > 7646 total > > > > > > > > > > > > > > And 7 seconds on a Dell Precision 5820: > > > > > > > > > > > > > > $ 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 > > > > > > > > > > > > > > real 0m7.162s > > > > > > > user 0m5.836s > > > > > > > sys 0m1.329s > > > > > > > 6548 undefined > > > > > > > 772 undefined_symbols > > > > > > > > > > > > > > Both tests were done against this tree (based on today's linux-next): > > > > > > > > > > > > > > $ https://git.kernel.org/pub/scm/linux/kernel/git/mchehab/devel.git/log/?h=get_abi_undefined-latest > > > > > > > > > > > > > > It should be noticed that, as my tree has several ABI fixes, the time to run the > > > > > > > script is likely less than if you run on your tree, as there will be less symbols to > > > > > > > be reported, and the algorithm is optimized to reduce the number of regexes > > > > > > > when a symbol is found. > > > > > > > > > > > > > > Besides optimizing and improving the seek logic, this series also change the > > > > > > > debug logic. It how receives a bitmap, where "8" means to print the regexes > > > > > > > that will be used by "undefined" command: > > > > > > > > > > > > > > $ time ./scripts/get_abi.pl undefined --debug 8 >foo > > > > > > > real 0m17,189s > > > > > > > user 0m13,940s > > > > > > > sys 0m2,404s > > > > > > > > > > > > > > $wc -l foo > > > > > > > 18421939 foo > > > > > > > > > > > > > > $ cat foo > > > > > > > ... > > > > > > > /sys/kernel/kexec_crash_loaded =~ /^(?^:^/sys/.*/iio\:device.*/in_voltage.*_scale_available$)$/ > > > > > > > /sys/kernel/kexec_crash_loaded =~ /^(?^:^/sys/.*/iio\:device.*/out_voltage.*_scale_available$)$/ > > > > > > > /sys/kernel/kexec_crash_loaded =~ /^(?^:^/sys/.*/iio\:device.*/out_altvoltage.*_scale_available$)$/ > > > > > > > /sys/kernel/kexec_crash_loaded =~ /^(?^:^/sys/.*/iio\:device.*/in_pressure.*_scale_available$)$/ > > > > > > > ... > > > > > > > > > > > > > > On other words, on my desktop, the /sys match is performing >18M regular > > > > > > > expression searches, which takes 6,2 seconds (or 17,2 seconds, if debug is > > > > > > > enabled and sent to an area on my nvme storage). > > > > > > > > > > > > Better, it's down to 10 minutes on my machine now: > > > > > > > > > > > > real 10m39.218s > > > > > > user 10m37.742s > > > > > > sys 0m0.775s > > > > > > > > > > A lot better, but not clear why it is still taking ~40x more than here... > > > > > It could well be due to the other ABI changes yet to be applied > > > > > (I'll submit it probably later today), but it could also be related to > > > > > something else. Could this be due to disk writes? > > > > > > > > Disk writes to where for what? This is a very fast disk (nvme raid > > > > array) It's also a very "big" system, with lots of sysfs files: > > > > > > > > $ find /sys/devices/ -type f | wc -l > > > > 44334 > > > > > > Ok. Maybe that partially explains why it is taking so long, as the > > > number of regex to compare will increase (not linearly). > > > > No idea. I just ran it on my laptop and it took only 5 seconds. > > Ok, 5 seconds is similar to what I got here on the machines I > tested so far. I'm waiting for a (shared) big machine to be available > in order to be able to do some tests on it. > > > Hm, you aren't reading the values of the sysfs files, right? > > No. Just retrieving the directory contents. That part is actually > fast: it takes less than 2 seconds here to read all ABI + traverse > sysfs directories. Also, from your past logs, the time is spent > later on, when it is handling the regex. On that time, there are > just the regex parsing and printing the results. > > > Anything I can do to run to help figure out where the script is taking > > so long? > > Not sure if it is worth the efforts. I mean, the relationship > between the number of processed sysfs nodes and the number of regex > to be tested (using big-oh and big-omega notation) should be between > Ω(n . log(n)) and O(n^2 . log(n)). There's not much space left for > optimizing it, I guess. > > So, I would expect that a big server would take a log more time to > process, it, due to the larger number of sysfs entries. > > Also, if one wants to speedup on a big machine, it could either > exclude some pattern, like: > > # Won't parse any PCI devices > $time ./scripts/get_abi.pl undefined --search-string '^(?!.*pci)' |wc -l > 8438 > > real 0m3,494s > user 0m2,829s > sys 0m0,658s That only takes 8 seconds on this box: $ time ./scripts/get_abi.pl undefined --search-string '^(?!.*pci)' |wc -l 18872 real 0m8.026s user 0m7.300s sys 0m0.726s > or (more likely) just search for an specific part of the ABI: > > # Seek ABI only for PCI devices > $ ./scripts/get_abi.pl undefined --search-string pci This takes much longer, I didn't want to wait the 10 minutes :) > --- > > After sleeping on it, I opted to implement some progress information. > > That will help to identify any issues that might be causing the > script to take so long to finish. > > I'll send the patches on a new series. Thanks, I'll go try those now... greg k-h