From owner-freebsd-hackers Tue Jan 30 16:18:21 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from earth.backplane.com (earth-nat-cw.backplane.com [208.161.114.67]) by hub.freebsd.org (Postfix) with ESMTP id 17C8837B69C for ; Tue, 30 Jan 2001 16:17:59 -0800 (PST) Received: (from dillon@localhost) by earth.backplane.com (8.11.1/8.9.3) id f0V0Htr96647; Tue, 30 Jan 2001 16:17:55 -0800 (PST) (envelope-from dillon) Date: Tue, 30 Jan 2001 16:17:55 -0800 (PST) From: Matt Dillon Message-Id: <200101310017.f0V0Htr96647@earth.backplane.com> To: Thomas Moestl Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: removing setgid kmem from top, collecting per-device swap stats References: <20010130224759.A1589@crow.dom2ip.de> <200101302321.f0UNLcB95520@earth.backplane.com> <20010131005923.A2199@crow.dom2ip.de> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG : VOP_SWAPACCOUNT(nbp->b_vp, nbp); : BUF_KERNPROC(nbp); : BUF_STRATEGY(nbp); : :Now, I have to define the vop in vm_swap.c, where I can get the area :index from the block number in a clean way and frob my counters. :The same method could be used in swap_pager_putpages(). :swap_pager_reserve() would need to construct a buf and act in a similar :way as e.g. swap_pager_strategy(), only that the buffer is not flushed :afterwards, only VOP_SWAPACCOUNT is called. Of course, this can be :done much easier by just passing the block number to VOP_SWAPACCOUNT, :and calling it for each blk returned by swp_pager_getswapspace() :(it costs virtually nothing, so it should be OK). :So, VOP_SWAPACCOUNT would become: : VOP_SWAPACCOUNT(nbp->b_vp, nbp->b_blkno, nbp->bcount); : :Or did I get things wrong? : : - thomas Hmm. I think it would be easier to figure it out in the swap allocation and free code. Specifically, look in vm/swap_pager.c: * The swp_pager_getswapspace() function * The swp_pager_freeswapspace() function I think these are the best places to keep track of per-swap-area allocation and frees. Note that the system tracks overall swap useage in these routines as well (the vm_swap_size global). Since the number of swap areas is fixed (NSWAP), it should be utterly trivial to have an 'int' array of current allocations for each swap area updated from the above two routines. swapinfo can then retrieve the information directly via sysctl. i.e. retrieve the entire array with a single sysctl. -Matt To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message