Page MenuHomeFreeBSD

pget: don't acquire allproc_lock when operating on curproc
ClosedPublic

Authored by kaktus on Nov 3 2017, 1:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 12 2024, 3:31 AM
Unknown Object (File)
Jan 3 2024, 3:50 AM
Unknown Object (File)
Dec 22 2023, 3:24 AM
Unknown Object (File)
Dec 20 2023, 8:08 AM
Unknown Object (File)
Oct 13 2023, 3:54 PM
Unknown Object (File)
Sep 19 2023, 5:06 PM
Unknown Object (File)
Sep 2 2023, 1:42 AM
Unknown Object (File)
Jul 11 2023, 2:51 AM
Subscribers

Details

Summary

pget(9) in it's current form unconditionally acquire allproc_lock every time.
Test showed that in many cases requested pid == curproc->p_pid allowing this lock to be avoided:

make -j4 buildworld

saved about 5600 locks;

poudriere bulk -J 12 -C -t -j 111amd64 www/nginx-full

where this ports depends on 230 others (java, llvm40, etc..) saved about 27000 locks.

Test Plan

This patch was tested using varied mix of make buildworld, poudriere, ps, proctstat.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

robak added reviewers: emaste, kib, adrian. robak added 1 blocking reviewer(s): mjg.Nov 3 2017, 1:43 PM

You may check for curthread->td_tid as well.

mjg accepted this revision.EditedNov 3 2017, 1:56 PM

I think checking if pfind may use a similar treatment would be nice.

This revision is now accepted and ready to land.Nov 3 2017, 1:56 PM

Address @kib comment and check for tid too.

This revision now requires review to proceed.Nov 3 2017, 2:02 PM

I'll check pfind and create new review if needed.

sys/kern/kern_proc.c
393 ↗(On Diff #34717)

Look below for PGET_NOTID. The check for tid should be conditional.

I would say scratch optimising for the _NOTID case. There is only one in-tree user of the flag and it is not expected to receive any tids.

Shouldn't then CPUCLOCK_WHICH_PID case in kern_clock_getcpuclockid2 be amended?

As the name suggests CPUCLOCK_WHICH_PID only wants to match pids. Thus the _NOTID flag is passed to avoid the corner case of *tid* being passed and matching an existing thread.

p_pid wil never match a *tid* thus it can be tested unconditionally.

I don't see any use for extra treatment for the _NOTID flag.

Roll back to the original version and optimise only for the pid == curproc->p_pid case.

This revision is now accepted and ready to land.Nov 3 2017, 4:08 PM
This revision was automatically updated to reflect the committed changes.