From owner-svn-src-all@FreeBSD.ORG Tue Oct 14 12:13:03 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5CBB7556; Tue, 14 Oct 2014 12:13:03 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4809134A; Tue, 14 Oct 2014 12:13:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9ECD3QR098788; Tue, 14 Oct 2014 12:13:03 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9ECD2nW098783; Tue, 14 Oct 2014 12:13:02 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201410141213.s9ECD2nW098783@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 14 Oct 2014 12:13:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r273078 - in stable/10: sbin/camcontrol sys/cam X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Oct 2014 12:13:03 -0000 Author: mav Date: Tue Oct 14 12:13:01 2014 New Revision: 273078 URL: https://svnweb.freebsd.org/changeset/base/273078 Log: MFC r271588: Update CAM CCB accounting for the new status quo. devq_openings counter lost its meaning after allocation queues has gone. held counter is still meaningful, but problematic to update due to separate locking of CCB allocation and queuing. To fix that replace devq_openings counter with allocated counter. held is now calculated on request as difference between number of allocated, queued and active CCBs. Modified: stable/10/sbin/camcontrol/camcontrol.c stable/10/sys/cam/cam_ccb.h stable/10/sys/cam/cam_queue.c stable/10/sys/cam/cam_queue.h stable/10/sys/cam/cam_xpt.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/10/sbin/camcontrol/camcontrol.c Tue Oct 14 12:04:50 2014 (r273077) +++ stable/10/sbin/camcontrol/camcontrol.c Tue Oct 14 12:13:01 2014 (r273078) @@ -4469,9 +4469,9 @@ tagcontrol(struct cam_device *device, in fprintf(stdout, "%s", pathstr); fprintf(stdout, "dev_active %d\n", ccb->cgds.dev_active); fprintf(stdout, "%s", pathstr); - fprintf(stdout, "devq_openings %d\n", ccb->cgds.devq_openings); + fprintf(stdout, "allocated %d\n", ccb->cgds.allocated); fprintf(stdout, "%s", pathstr); - fprintf(stdout, "devq_queued %d\n", ccb->cgds.devq_queued); + fprintf(stdout, "queued %d\n", ccb->cgds.queued); fprintf(stdout, "%s", pathstr); fprintf(stdout, "held %d\n", ccb->cgds.held); fprintf(stdout, "%s", pathstr); Modified: stable/10/sys/cam/cam_ccb.h ============================================================================== --- stable/10/sys/cam/cam_ccb.h Tue Oct 14 12:04:50 2014 (r273077) +++ stable/10/sys/cam/cam_ccb.h Tue Oct 14 12:13:01 2014 (r273078) @@ -352,8 +352,8 @@ struct ccb_getdevstats { struct ccb_hdr ccb_h; int dev_openings; /* Space left for more work on device*/ int dev_active; /* Transactions running on the device */ - int devq_openings; /* Space left for more queued work */ - int devq_queued; /* Transactions queued to be sent */ + int allocated; /* CCBs allocated for the device */ + int queued; /* CCBs queued to be sent to the device */ int held; /* * CCBs held by peripheral drivers * for this device Modified: stable/10/sys/cam/cam_queue.c ============================================================================== --- stable/10/sys/cam/cam_queue.c Tue Oct 14 12:04:50 2014 (r273077) +++ stable/10/sys/cam/cam_queue.c Tue Oct 14 12:13:01 2014 (r273078) @@ -290,7 +290,6 @@ cam_ccbq_resize(struct cam_ccbq *ccbq, i delta = new_size - (ccbq->dev_active + ccbq->dev_openings); ccbq->total_openings += delta; - ccbq->devq_openings += delta; ccbq->dev_openings += delta; new_size = imax(64, 1 << fls(new_size + new_size / 2)); @@ -308,7 +307,6 @@ cam_ccbq_init(struct cam_ccbq *ccbq, int imax(64, 1 << fls(openings + openings / 2))) != 0) return (1); ccbq->total_openings = openings; - ccbq->devq_openings = openings; ccbq->dev_openings = openings; return (0); } Modified: stable/10/sys/cam/cam_queue.h ============================================================================== --- stable/10/sys/cam/cam_queue.h Tue Oct 14 12:04:50 2014 (r273077) +++ stable/10/sys/cam/cam_queue.h Tue Oct 14 12:13:01 2014 (r273078) @@ -62,10 +62,9 @@ struct cam_ccbq { struct ccb_hdr_tailq queue_extra_head; int queue_extra_entries; int total_openings; - int devq_openings; + int allocated; int dev_openings; int dev_active; - int held; }; struct cam_ed; @@ -188,8 +187,8 @@ cam_ccbq_pending_ccb_count(struct cam_cc static __inline void cam_ccbq_take_opening(struct cam_ccbq *ccbq) { - ccbq->devq_openings--; - ccbq->held++; + + ccbq->allocated++; } static __inline void @@ -198,8 +197,6 @@ cam_ccbq_insert_ccb(struct cam_ccbq *ccb struct ccb_hdr *old_ccb; struct camq *queue = &ccbq->queue; - ccbq->held--; - /* * If queue is already full, try to resize. * If resize fail, push CCB with lowest priority out to the TAILQ. @@ -264,7 +261,7 @@ cam_ccbq_send_ccb(struct cam_ccbq *ccbq, send_ccb->ccb_h.pinfo.index = CAM_ACTIVE_INDEX; ccbq->dev_active++; - ccbq->dev_openings--; + ccbq->dev_openings--; } static __inline void @@ -272,15 +269,14 @@ cam_ccbq_ccb_done(struct cam_ccbq *ccbq, { ccbq->dev_active--; - ccbq->dev_openings++; - ccbq->held++; + ccbq->dev_openings++; } static __inline void cam_ccbq_release_opening(struct cam_ccbq *ccbq) { - ccbq->held--; - ccbq->devq_openings++; + + ccbq->allocated--; } #endif /* _KERNEL */ Modified: stable/10/sys/cam/cam_xpt.c ============================================================================== --- stable/10/sys/cam/cam_xpt.c Tue Oct 14 12:04:50 2014 (r273077) +++ stable/10/sys/cam/cam_xpt.c Tue Oct 14 12:13:01 2014 (r273078) @@ -2652,20 +2652,25 @@ call_sim: struct ccb_getdevstats *cgds; struct cam_eb *bus; struct cam_et *tar; + struct cam_devq *devq; cgds = &start_ccb->cgds; bus = path->bus; tar = path->target; + devq = bus->sim->devq; + mtx_lock(&devq->send_mtx); cgds->dev_openings = dev->ccbq.dev_openings; cgds->dev_active = dev->ccbq.dev_active; - cgds->devq_openings = dev->ccbq.devq_openings; - cgds->devq_queued = cam_ccbq_pending_ccb_count(&dev->ccbq); - cgds->held = dev->ccbq.held; + cgds->allocated = dev->ccbq.allocated; + cgds->queued = cam_ccbq_pending_ccb_count(&dev->ccbq); + cgds->held = cgds->allocated - cgds->dev_active - + cgds->queued; cgds->last_reset = tar->last_reset; cgds->maxtags = dev->maxtags; cgds->mintags = dev->mintags; if (timevalcmp(&tar->last_reset, &bus->last_reset, <)) cgds->last_reset = bus->last_reset; + mtx_unlock(&devq->send_mtx); cgds->ccb_h.status = CAM_REQ_CMP; } break; @@ -3008,7 +3013,6 @@ xpt_polled_action(union ccb *start_ccb) * can get it before us while we simulate interrupts. */ mtx_lock(&devq->send_mtx); - dev->ccbq.devq_openings--; dev->ccbq.dev_openings--; while((devq->send_openings <= 0 || dev->ccbq.dev_openings < 0) && (--timeout > 0)) { @@ -3020,7 +3024,6 @@ xpt_polled_action(union ccb *start_ccb) camisr_runqueue(); mtx_lock(&devq->send_mtx); } - dev->ccbq.devq_openings++; dev->ccbq.dev_openings++; mtx_unlock(&devq->send_mtx);