Author: markj
Date: Mon Apr 29 13:23:32 2019
New Revision: 346888
URL: https://svnweb.freebsd.org/changeset/base/346888

Log:
  Stop checking TD_IDLETHREAD() in buffer cache routines.
  
  These predicates are vestigal and cannot be true today.  For example,
  idle threads are not allowed to acquire locks.
  
  Also cache curthread in breada().
  
  No functional change intended.
  
  Reviewed by:  kib, mckusick
  MFC after:    1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:        https://reviews.freebsd.org/D20066

Modified:
  head/sys/kern/vfs_bio.c

Modified: head/sys/kern/vfs_bio.c
==============================================================================
--- head/sys/kern/vfs_bio.c     Mon Apr 29 13:20:55 2019        (r346887)
+++ head/sys/kern/vfs_bio.c     Mon Apr 29 13:23:32 2019        (r346888)
@@ -2073,8 +2073,11 @@ breada(struct vnode * vp, daddr_t * rablkno, int * rab
     struct ucred * cred, int flags, void (*ckhashfunc)(struct buf *))
 {
        struct buf *rabp;
+       struct thread *td;
        int i;
 
+       td = curthread;
+
        for (i = 0; i < cnt; i++, rablkno++, rabsize++) {
                if (inmem(vp, *rablkno))
                        continue;
@@ -2083,16 +2086,14 @@ breada(struct vnode * vp, daddr_t * rablkno, int * rab
                        brelse(rabp);
                        continue;
                }
-               if (!TD_IS_IDLETHREAD(curthread)) {
 #ifdef RACCT
-                       if (racct_enable) {
-                               PROC_LOCK(curproc);
-                               racct_add_buf(curproc, rabp, 0);
-                               PROC_UNLOCK(curproc);
-                       }
-#endif /* RACCT */
-                       curthread->td_ru.ru_inblock++;
+               if (racct_enable) {
+                       PROC_LOCK(curproc);
+                       racct_add_buf(curproc, rabp, 0);
+                       PROC_UNLOCK(curproc);
                }
+#endif /* RACCT */
+               td->td_ru.ru_inblock++;
                rabp->b_flags |= B_ASYNC;
                rabp->b_flags &= ~B_INVAL;
                if ((flags & GB_CKHASH) != 0) {
@@ -2148,16 +2149,14 @@ breadn_flags(struct vnode *vp, daddr_t blkno, int size
         */
        readwait = 0;
        if ((bp->b_flags & B_CACHE) == 0) {
-               if (!TD_IS_IDLETHREAD(td)) {
 #ifdef RACCT
-                       if (racct_enable) {
-                               PROC_LOCK(td->td_proc);
-                               racct_add_buf(td->td_proc, bp, 0);
-                               PROC_UNLOCK(td->td_proc);
-                       }
-#endif /* RACCT */
-                       td->td_ru.ru_inblock++;
+               if (racct_enable) {
+                       PROC_LOCK(td->td_proc);
+                       racct_add_buf(td->td_proc, bp, 0);
+                       PROC_UNLOCK(td->td_proc);
                }
+#endif /* RACCT */
+               td->td_ru.ru_inblock++;
                bp->b_iocmd = BIO_READ;
                bp->b_flags &= ~B_INVAL;
                if ((flags & GB_CKHASH) != 0) {
@@ -2258,16 +2257,14 @@ bufwrite(struct buf *bp)
        bp->b_runningbufspace = bp->b_bufsize;
        space = atomic_fetchadd_long(&runningbufspace, bp->b_runningbufspace);
 
-       if (!TD_IS_IDLETHREAD(curthread)) {
 #ifdef RACCT
-               if (racct_enable) {
-                       PROC_LOCK(curproc);
-                       racct_add_buf(curproc, bp, 1);
-                       PROC_UNLOCK(curproc);
-               }
-#endif /* RACCT */
-               curthread->td_ru.ru_oublock++;
+       if (racct_enable) {
+               PROC_LOCK(curproc);
+               racct_add_buf(curproc, bp, 1);
+               PROC_UNLOCK(curproc);
        }
+#endif /* RACCT */
+       curthread->td_ru.ru_oublock++;
        if (oldflags & B_ASYNC)
                BUF_KERNPROC(bp);
        bp->b_iooffset = dbtob(bp->b_blkno);
@@ -4019,9 +4016,6 @@ loop:
                 */
                if (flags & GB_NOCREAT)
                        return (EEXIST);
-               if (bdomain[bo->bo_domain].bd_freebuffers == 0 &&
-                   TD_IS_IDLETHREAD(curthread))
-                       return (EBUSY);
 
                bsize = vn_isdisk(vp, NULL) ? DEV_BSIZE : bo->bo_bsize;
                KASSERT(bsize != 0, ("bsize == 0, check bo->bo_bsize"));
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to