Print this page
OS-7753 THREAD_KPRI_RELEASE does nothing of the sort
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.

  24  */
  25 
  26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  27 /* All Rights Reserved */
  28 
  29 /*
  30  * Portions of this source code were derived from Berkeley 4.3 BSD
  31  * under license from the Regents of the University of California.
  32  */
  33 
  34 #include <sys/types.h>
  35 #include <sys/t_lock.h>
  36 #include <sys/param.h>
  37 #include <sys/time.h>
  38 #include <sys/systm.h>
  39 #include <sys/sysmacros.h>
  40 #include <sys/resource.h>
  41 #include <sys/signal.h>
  42 #include <sys/cred.h>
  43 #include <sys/user.h>


 204          */
 205         if (error)
 206                 if (bp->b_resid)
 207                         *bytes_iop = bp->b_bcount - bp->b_resid;
 208                 else
 209                         *bytes_iop = 0;
 210         else
 211                 *bytes_iop += bp->b_bcount;
 212         /*
 213          * Release direct IO resources
 214          */
 215         bp->b_flags &= ~(B_BUSY|B_WANTED|B_PHYS|B_SHADOW);
 216         kmem_cache_free(directio_buf_cache, dbp);
 217         return (error);
 218 }
 219 
 220 /*
 221  * Wait for all of the direct IO operations to finish
 222  */
 223 
 224 uint32_t        ufs_directio_drop_kpri = 0;     /* enable kpri hack */
 225 
 226 static int
 227 directio_wait(struct directio_buf *tail, long *bytes_iop)
 228 {
 229         int     error = 0, newerror;
 230         struct directio_buf     *dbp;
 231         uint_t  kpri_req_save;
 232 
 233         /*
 234          * The linked list of directio buf structures is maintained
 235          * in reverse order (tail->last request->penultimate request->...)
 236          */
 237         /*
 238          * This is the k_pri_req hack. Large numbers of threads
 239          * sleeping with kernel priority will cause scheduler thrashing
 240          * on an MP machine. This can be seen running Oracle using
 241          * directio to ufs files. Sleep at normal priority here to
 242          * more closely mimic physio to a device partition. This
 243          * workaround is disabled by default as a niced thread could
 244          * be starved from running while holding i_rwlock and i_contents.
 245          */
 246         if (ufs_directio_drop_kpri) {
 247                 kpri_req_save = curthread->t_kpri_req;
 248                 curthread->t_kpri_req = 0;
 249         }
 250         while ((dbp = tail) != NULL) {
 251                 tail = dbp->next;
 252                 newerror = directio_wait_one(dbp, bytes_iop);
 253                 if (error == 0)
 254                         error = newerror;
 255         }
 256         if (ufs_directio_drop_kpri)
 257                 curthread->t_kpri_req = kpri_req_save;
 258         return (error);
 259 }
 260 /*
 261  * Initiate direct IO request
 262  */
 263 static void
 264 directio_start(struct ufsvfs *ufsvfsp, struct inode *ip, size_t nbytes,
 265         offset_t offset, char *addr, enum seg_rw rw, struct proc *procp,
 266         struct directio_buf **tailp, page_t **pplist)
 267 {
 268         buf_t *bp;
 269         struct directio_buf *dbp;
 270 
 271         /*
 272          * Allocate a directio buf header
 273          *   Note - list is maintained in reverse order.
 274          *   directio_wait_one() depends on this fact when
 275          *   adjusting the ``bytes_io'' param. bytes_io
 276          *   is used to compute a residual in the case of error.
 277          */




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2019 Joyent, Inc.
  25  */
  26 
  27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  28 /* All Rights Reserved */
  29 
  30 /*
  31  * Portions of this source code were derived from Berkeley 4.3 BSD
  32  * under license from the Regents of the University of California.
  33  */
  34 
  35 #include <sys/types.h>
  36 #include <sys/t_lock.h>
  37 #include <sys/param.h>
  38 #include <sys/time.h>
  39 #include <sys/systm.h>
  40 #include <sys/sysmacros.h>
  41 #include <sys/resource.h>
  42 #include <sys/signal.h>
  43 #include <sys/cred.h>
  44 #include <sys/user.h>


 205          */
 206         if (error)
 207                 if (bp->b_resid)
 208                         *bytes_iop = bp->b_bcount - bp->b_resid;
 209                 else
 210                         *bytes_iop = 0;
 211         else
 212                 *bytes_iop += bp->b_bcount;
 213         /*
 214          * Release direct IO resources
 215          */
 216         bp->b_flags &= ~(B_BUSY|B_WANTED|B_PHYS|B_SHADOW);
 217         kmem_cache_free(directio_buf_cache, dbp);
 218         return (error);
 219 }
 220 
 221 /*
 222  * Wait for all of the direct IO operations to finish
 223  */
 224 


 225 static int
 226 directio_wait(struct directio_buf *tail, long *bytes_iop)
 227 {
 228         int     error = 0, newerror;
 229         struct directio_buf     *dbp;

 230 
 231         /*
 232          * The linked list of directio buf structures is maintained
 233          * in reverse order (tail->last request->penultimate request->...)
 234          */













 235         while ((dbp = tail) != NULL) {
 236                 tail = dbp->next;
 237                 newerror = directio_wait_one(dbp, bytes_iop);
 238                 if (error == 0)
 239                         error = newerror;
 240         }


 241         return (error);
 242 }
 243 /*
 244  * Initiate direct IO request
 245  */
 246 static void
 247 directio_start(struct ufsvfs *ufsvfsp, struct inode *ip, size_t nbytes,
 248     offset_t offset, char *addr, enum seg_rw rw, struct proc *procp,
 249     struct directio_buf **tailp, page_t **pplist)
 250 {
 251         buf_t *bp;
 252         struct directio_buf *dbp;
 253 
 254         /*
 255          * Allocate a directio buf header
 256          *   Note - list is maintained in reverse order.
 257          *   directio_wait_one() depends on this fact when
 258          *   adjusting the ``bytes_io'' param. bytes_io
 259          *   is used to compute a residual in the case of error.
 260          */