mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: yongli-oc <yongli-oc@zhaoxin.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>, <yongli@zhaoxin.com>,
	<cobechen@zhaoxin.com>, <louisqi@zhaoxin.com>,
	<jiangbowang@zhaoxin.com>
Subject: Re: [PATCH] Support lockref reference count if enable LOCK_STAT
Date: Fri, 15 Nov 2024 15:30:13 +0800	[thread overview]
Message-ID: <19b392d9d8f97170518354df0ebdf913a140799d.camel@zhaoxin.com> (raw)
In-Reply-To: <20241114161400.72259c36cca41c0c2da6d971@linux-foundation.org>


Hi, Morton:
One of the struct lockref is used in dcache.h. The spinlock_t is 4
bytes, with the 4 bytes reference count, the struct lockref is a 8
bytes variable, the count can be inc/dec by a 64 bits atomic operation,
when the spinlock is unlocked.
If the spinlock is more than 4 bytes, such as enable the kernel config
DEBUG_SPINLOCK or LOCK_STAT, the count inc/dec should got the spinlock
first, the sequence likes "lock; inc_ref; unlock;", which will caused
spinlock contention increased so much.
The chart below shows the spinlock contention with and without the
lockref patch. it got by "cat /proc/lock_stat" after ubuntu 22.04 boot
up. I tried each case two times. the con-bounces and contentions
of 6.6.28 with LOCK_STAT enable are much more than it of the 6.6.28
lockref patched. 
With the lockref patch, the count can be operated by atomic too. The
statistics result is similar to the 6.6.28 kernel production
environment.

lock_stat version 0.4
  --------------------------------------------------
  bootup  class name     con-bounces    contentions
  times
  --------kernel 6.6.28, enable LOCK_STAT-----------
   1   &dentry->d_lock:    385336         413098
   2   &dentry->d_lock:    378268         402761
  --------------------------------------------------
  -------6.6.28 with lockref patch and LOCK_STAT----
   1   &dentry->d_lock:     79941          82431
   2   &dentry->d_lock:     77817          80301
  --------------------------------------------------
Li Yong

On Thu, 2024-11-14 at 16:14 -0800, Andrew Morton wrote:
> 
> 
> [这封邮件来自外部发件人 谨防风险]
> 
> On Wed, 13 Nov 2024 16:57:03 +0800 yongli-oc <yongli-oc@zhaoxin.com>
> wrote:
> 
> > Swap the positions of lock and count to support CMPXCHG_LOCKREF
> > if SPINLOCK_SIZE > 4 when enable LOCK_STAT. The reference count
> > can always be used regardless of the spinlock_t size.
> 
> Please fully describe the problem we're solving here?  And what are
> the
> runtime effects of this change?


      reply	other threads:[~2024-11-15  9:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-13  8:57 yongli-oc
2024-11-13 22:08 ` kernel test robot
2024-11-13 22:08 ` kernel test robot
2024-11-15  0:14 ` Andrew Morton
2024-11-15  7:30   ` yongli-oc [this message]

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=19b392d9d8f97170518354df0ebdf913a140799d.camel@zhaoxin.com \
    --to=yongli-oc@zhaoxin.com \
    --cc=akpm@linux-foundation.org \
    --cc=cobechen@zhaoxin.com \
    --cc=jiangbowang@zhaoxin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=louisqi@zhaoxin.com \
    --cc=yongli@zhaoxin.com \
    /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

all inboxes | Powered by JetHome®