linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brice Goglin <brice.goglin@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>,
	x86@kernel.org, Borislav Petkov <bp@suse.de>,
	Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Tony Luck <tony.luck@intel.com>, Len Brown <len.brown@intel.com>,
	"Ravi V. Shankar" <ravi.v.shankar@intel.com>,
	linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
	Dave Hansen <dave.hansen@intel.com>,
	"Gautham R. Shenoy" <ego@linux.vnet.ibm.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: Re: [PATCH 1/4] drivers core: Introduce CPU type sysfs interface
Date: Wed, 18 Nov 2020 11:45:46 +0100	[thread overview]
Message-ID: <ea20c2b8-18c8-ef76-4a16-15b7271333d1@gmail.com> (raw)
In-Reply-To: <33efde37-562f-4c6a-72ba-2277533e3781@gmail.com>


Le 17/11/2020 à 16:55, Brice Goglin a écrit :
> Le 12/11/2020 à 11:49, Greg Kroah-Hartman a écrit :
>> On Thu, Nov 12, 2020 at 10:10:57AM +0100, Brice Goglin wrote:
>>> Le 12/11/2020 à 07:42, Greg Kroah-Hartman a écrit :
>>>> On Thu, Nov 12, 2020 at 07:19:48AM +0100, Brice Goglin wrote:
>>>>> Hello
>>>>>
>>>>> Sorry for the late reply. As the first userspace consumer of this
>>>>> interface [1], I can confirm that reading a single file to get the mask
>>>>> would be better, at least for performance reason. On large platforms, we
>>>>> already have to read thousands of sysfs files to get CPU topology and
>>>>> cache information, I'd be happy not to read one more file per cpu.
>>>>>
>>>>> Reading these sysfs files is slow, and it does not scale well when
>>>>> multiple processes read them in parallel.
>>>> Really?  Where is the slowdown?  Would something like readfile() work
>>>> better for you for that?
>>>> 	https://lore.kernel.org/linux-api/20200704140250.423345-1-gregkh@linuxfoundation.org/
>>> I guess readfile would improve the sequential case by avoiding syscalls
>>> but it would not improve the parallel case since syscalls shouldn't have
>>> any parallel issue?
>> syscalls should not have parallel issues at all.
>>
>>> We've been watching the status of readfile() since it was posted on LKML
>>> 6 months ago, but we were actually wondering if it would end up being
>>> included at some point.
>> It needs a solid reason to be merged.  My "test" benchmarks are fun to
>> run, but I have yet to find a real need for it anywhere as the
>> open/read/close syscall overhead seems to be lost in the noise on any
>> real application workload that I can find.
>>
>> If you have a real need, and it reduces overhead and cpu usage, I'm more
>> than willing to update the patchset and resubmit it.
>>
>>
> Hello
>
> I updated hwloc to use readfile instead of open+read+close on all those
> small sysfs/procfs files. Unfortunately the improvement is very small,
> only a couple percents. On a 40 core server, our library starts in 38ms
> instead of 39ms. I can't deploy your patches on larger machines, but I
> tested our code on a copy of their sysfs files saved on a local disk :
> For a 256-thread KNL, we go from 15ms to 14ms. For a 896-core SGI
> machine, from 73ms to 71ms.


Sorry, I forgot to update some codepaths to properly use readfile yesterday :/
Here are updated and more precise numbers that show a non-negligible improvement.
Again, we're measuring the entire hwloc topology discovery, which includes reading
many sysfs file (improved thanks to readfile) and then building a hierarchy of
objects describing the machine (not modified).

Server sysfs files (dual-socket x 20 cores x SMT-2)
default  43.48ms +/-4.48
readfile 42.15ms +/-4.58 => 3.1% better
1971 readfile calls => 674ns improvement per call

Knight Landing sysfs stored on local hard drive (64 cores x SMT-4)
default  14.60ms +/-0.91
readfile 13.63ms +/-1.05 => 6.6% better
2940 readfile calls => 329ns improvement per call

SGI Altix UV sysfs stored on local hard drive (56 sockets x 8 coeurs x SMT-2)
default  69.12ms +/-1.40
readfile 66.03ms +/-1.35 => 4.5% better
14525 readfile calls => 212ns improvement per call

I don't know why the first case (real sysfs files) gets a much
higher standard deviation and higher improvement per readfile call.
The other two cases match what microbenmarks say
(about 200ns improvement per readfile call).

Brice




>
> I see 200ns improvement for readfile (2300) vs open+read+close (2500) on
> my server when reading a single cpu topology file. With several
> thousands of sysfs files to read in the above large hwloc tests, it
> confirms an overall improvement in the order of 1ms.
>
> So, just like you said, the overhead seems to be pretty much lost in the
> noise of hwloc doing its own stuff after reading hundreds of sysfs files :/
>
> Brice
>
>

  reply	other threads:[~2020-11-18 10:46 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-03  1:17 [PATCH 0/4] drivers core: Introduce CPU type sysfs interface Ricardo Neri
2020-10-03  1:17 ` [PATCH 1/4] " Ricardo Neri
2020-10-03  3:27   ` Randy Dunlap
2020-10-06  1:15     ` Ricardo Neri
2020-10-10  3:14       ` Randy Dunlap
2020-10-03  8:53   ` Greg Kroah-Hartman
2020-10-03 11:05     ` Greg Kroah-Hartman
2020-10-06  1:08       ` Ricardo Neri
2020-10-06  0:57     ` Ricardo Neri
2020-10-06  7:37       ` Greg Kroah-Hartman
2020-10-07  3:14         ` Ricardo Neri
2020-10-07  5:15           ` Greg Kroah-Hartman
2020-10-08  3:34             ` Ricardo Neri
2020-11-12  6:19             ` Brice Goglin
2020-11-12  6:42               ` Greg Kroah-Hartman
2020-11-12  9:10                 ` Brice Goglin
2020-11-12 10:49                   ` Greg Kroah-Hartman
2020-11-17 15:55                     ` Brice Goglin
2020-11-18 10:45                       ` Brice Goglin [this message]
2020-11-18 10:57                         ` Greg Kroah-Hartman
     [not found]                     ` <38f290d2-4c3a-d1b0-f3cc-a0897ea10abd@gmail.com>
2020-11-12 11:34                       ` Greg Kroah-Hartman
2020-11-19  8:25                       ` Fox Chen
2020-10-03  1:17 ` [PATCH 2/4] x86/cpu: Describe hybrid CPUs in cpuinfo_x86 Ricardo Neri
2020-10-03  4:07   ` kernel test robot
2020-10-03  1:17 ` [PATCH 3/4] x86/cpu/intel: Add function to get name of hybrid CPU types Ricardo Neri
2020-10-03  1:17 ` [PATCH 4/4] x86/cpu/topology: Implement the CPU type sysfs interface Ricardo Neri
2020-10-03  3:33   ` Randy Dunlap
2020-10-03  5:28   ` kernel test robot
2020-10-03  8:55   ` Greg Kroah-Hartman
2020-10-06  1:05     ` Ricardo Neri
2020-10-03  8:49 ` [PATCH 0/4] drivers core: Introduce " Borislav Petkov
2020-10-06  0:27   ` Ricardo Neri
2020-10-06  8:51 ` Qais Yousef
2020-10-07  2:50   ` Ricardo Neri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ea20c2b8-18c8-ef76-4a16-15b7271333d1@gmail.com \
    --to=brice.goglin@gmail.com \
    --cc=ak@linux.intel.com \
    --cc=bp@suse.de \
    --cc=dave.hansen@intel.com \
    --cc=ego@linux.vnet.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kan.liang@linux.intel.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=ravi.v.shankar@intel.com \
    --cc=ricardo.neri-calderon@linux.intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).