Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Jun 2018 09:04:56 -0400
From:      Andrew Gallatin <gallatin@cs.duke.edu>
To:        freebsd-hackers@freebsd.org
Subject:   Re: high CPU usage in FreeBSD for a PCIe card driver
Message-ID:  <a7caaecb-dd62-0c0f-e9ad-b83517bb3c7f@cs.duke.edu>
In-Reply-To: <CAKsGTHR9AzX2v%2B%2BDbNCdt7RwxEfw8jKwndXzH9oxQEHvPszo%2Bw@mail.gmail.com>
References:  <CAKsGTHR9AzX2v%2B%2BDbNCdt7RwxEfw8jKwndXzH9oxQEHvPszo%2Bw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 06/27/18 08:28, Steevan Rodrigues wrote:
> Hi
> 
> I  come from Linux background and new to FreeBSD.
> 
> I am investigating a high CPU usage issue on FreeBSD for PCIe driver of a

<...>

> 
> I wonder whether usage of mtx_lock is the cause of high CPU usage ? Any
> pointers or suggestions welcome.


It seems like you're experiencing lock contention.  The next step is to
determine which lock is contended and why.

I would suggest using the lockstat program to identify the lock which
is contended.  Try this:  lockstat -x aggsize=4m sleep 10 > out

And this:  lockstat -x aggsize=4m -s 10 sleep 10 > out-stacks

The first will show you contended locks broken down by type.  Eg:


Adaptive mutex spin: 61262 events in 10.007 seconds (6122 events/sec)

Count indv cuml rcnt     nsec Lock                   Caller
-------------------------------------------------------------------------------
15958  26%  26% 0.00     2960 tcp_hpts_lck           __tcp_hpts_remove+0xb5
11723  19%  45% 0.00     2608 tcp_hpts_lck 
tcp_hpts_insert_diag+0xaf
  6903  11%  56% 0.00     4605 tcp_hpts_lck           tcp_hpts_thread+0x11e
  6834  11%  68% 0.00   125868 sleep mtxpool          _sleep+0x2e3
  2756   4%  72% 0.00     1530 vm page 
sendfile_free_page+0x1c1


The second will show you the stacks associated with the lock contention,
and may help you identify the source of contention if, for example, your
driver is causing contention on a kernel lock.

Drew



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a7caaecb-dd62-0c0f-e9ad-b83517bb3c7f>