On Sat, Dec 22, 2007 at 01:28:31AM -0500, Mark Fullmer wrote:
> 
> On Dec 22, 2007, at 12:36 AM, Kostik Belousov wrote:
> >Lets check whether the syncer is the culprit for you.
> >Please, change the value of the syncdelay at the sys/kern/vfs_subr.c
> >around the line 238 from 30 to some other value, e.g., 45. After that,
> >check the interval of the effect you have observed.
> 
> Changed it to 13.  Not sure if SYNCER_MAXDELAY also needed to be
> increased if syncdelay was increased.
> 
> static int syncdelay = 13;              /* max time to delay syncing  
> data */
> 
> Test:
> 
> ; use vnodes
> % find / -type f -print > /dev/null
> 
> ; verify
> % sysctl vfs.numvnodes
> vfs.numvnodes: 32128
> 
> ; run packet loss test
> now have periodic loss every 13994633us (13.99 seconds).
> 
> ; reduce # of vnodes with sysctl kern.maxvnodes=1000
> test now runs clean.
Definitely syncer. 

> >
> >It would be interesting to check whether completely disabling the  
> >syncer
> >eliminates the packet loss, but such system have to be operated with
> >extreme caution.
Ok, no need to do this.

As Bruce Evans noted, there is a vfs_msync() that do almost the same
traversal of the vnodes. It was missed in the previous patch. Try this one.

diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 3c2e1ed..6515d6a 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -2967,7 +2967,9 @@ vfs_msync(struct mount *mp, int flags)
 {
        struct vnode *vp, *mvp;
        struct vm_object *obj;
+       int yield_count;
 
+       yield_count = 0;
        MNT_ILOCK(mp);
        MNT_VNODE_FOREACH(vp, mp, mvp) {
                VI_LOCK(vp);
@@ -2996,6 +2998,12 @@ vfs_msync(struct mount *mp, int flags)
                        MNT_ILOCK(mp);
                } else
                        VI_UNLOCK(vp);
+               if (yield_count++ == 500) {
+                       MNT_IUNLOCK(mp);
+                       yield_count = 0;
+                       uio_yield();
+                       MNT_ILOCK(mp);
+               }
        }
        MNT_IUNLOCK(mp);
 }
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index cbccc62..9e8b887 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -1182,6 +1182,7 @@ ffs_sync(mp, waitfor, td)
        int secondary_accwrites;
        int softdep_deps;
        int softdep_accdeps;
+       int yield_count;
        struct bufobj *bo;
 
        fs = ump->um_fs;
@@ -1216,6 +1217,7 @@ loop:
        softdep_get_depcounts(mp, &softdep_deps, &softdep_accdeps);
        MNT_ILOCK(mp);
 
+       yield_count = 0;
        MNT_VNODE_FOREACH(vp, mp, mvp) {
                /*
                 * Depend on the mntvnode_slock to keep things stable enough
@@ -1233,6 +1235,12 @@ loop:
                    (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 &&
                    vp->v_bufobj.bo_dirty.bv_cnt == 0)) {
                        VI_UNLOCK(vp);
+                       if (yield_count++ == 500) {
+                               MNT_IUNLOCK(mp);
+                               yield_count = 0;
+                               uio_yield();
+                               MNT_ILOCK(mp);
+                       }
                        continue;
                }
                MNT_IUNLOCK(mp);

Attachment: pgpbeGkWXvOc3.pgp
Description: PGP signature

Reply via email to