Project

General

Profile

Actions

Bug #7206

closed

dpwrite() acquires p_lock unnecessarily

Added by Robert Mustacchi almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Category:
kernel
Start date:
2016-07-20
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Looking at p_lock contention on a machine running Couchbase revealed acquisitions coming from this stack:

poll`dpwrite+0xa1 genunix`cdev_write+0x2d specfs`spec_write+0x4c1 genunix`fop_write+0x8b genunix`write+0x250 unix`sys_syscall+0x196

This corresponds to this code:

uiosize = uiop->uio_resid; pollfdnum = uiosize / size; mutex_enter(&curproc->p_lock); if (pollfdnum > (uint_t)rctl_enforced_value( rctlproc_legacy[RLIMIT_NOFILE], curproc->p_rctls, curproc)) { (void) rctl_action(rctlproc_legacy[RLIMIT_NOFILE], curproc->p_rctls, curproc, RCA_SAFE); mutex_exit(&curproc->p_lock); return (EINVAL); } mutex_exit(&curproc->p_lock);

This is only necessary to prevent the kernel from allocating too much memory; considering that these writes are often small, this could be modified to only do the check if the size is larger than a threshold (e.g., 256).

Actions #1

Updated by Electric Monk almost 6 years ago

  • Status changed from New to Closed

git commit 158dfbe4529de26c7bd687efe70e837858cbf8cf

commit  158dfbe4529de26c7bd687efe70e837858cbf8cf
Author: Bryan Cantrill <bryan@joyent.com>
Date:   2016-08-09T15:41:45.000Z

    7206 dpwrite() acquires p_lock unnecessarily
    Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
    Approved by: Garrett D'Amore <garrett@damore.org>

Actions

Also available in: Atom PDF