From owner-svn-src-head@FreeBSD.ORG Sun Mar 29 15:21:19 2015 Return-Path: Delivered-To: svn-src-head@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 184D6EBF; Sun, 29 Mar 2015 15:21:19 +0000 (UTC) Received: from mail-wi0-x22c.google.com (mail-wi0-x22c.google.com [IPv6:2a00:1450:400c:c05::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9B234F24; Sun, 29 Mar 2015 15:21:18 +0000 (UTC) Received: by wicne17 with SMTP id ne17so3350267wic.0; Sun, 29 Mar 2015 08:21:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=WY0Ug544D5b6Op6zG1HUTOx/bOvnHbG5IHAF9h2djtA=; b=Zr8NUi5wlPjtPZMQCj3D/3TbLW/cxRQ3pnB/uHOrIKz2Iry2+ZrnVy36uy1jxJypec MgQMi18g+2eIGXjmSwG1M1oBrr8EEqtXecdsqna1EM0wx+D3eZa67YWAS1M3sIu0r0SK rDZ3uH4lkdouK/UPljsMjaw590Rm5nENKWoKTSOi6jzpKcVtOOrJmLyO/waxV6qVDcUP UnZFTNvHqNSyshkd8NtRWTrn0MWEe1SEKP8n28rpE66ABStP1rtU+7+KdjSecXEgtUaQ IhMgk1yokGrWMMWW7ZAbc4xm8gfSlJoK+7pZXWibYTLgnkUuWAE+N0c3Rz/CJYIbykgN Xciw== X-Received: by 10.194.63.16 with SMTP id c16mr55369951wjs.117.1427642477187; Sun, 29 Mar 2015 08:21:17 -0700 (PDT) Received: from mavbook.mavhome.dp.ua ([134.249.139.101]) by mx.google.com with ESMTPSA id a13sm11608167wjx.30.2015.03.29.08.21.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Mar 2015 08:21:16 -0700 (PDT) Sender: Alexander Motin Message-ID: <5518186A.7060602@FreeBSD.org> Date: Sun, 29 Mar 2015 18:21:14 +0300 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Adrian Chadd Subject: Re: svn commit: r280805 - head/sys/kern References: <201503291002.t2TA2TbM021925@svn.freebsd.org> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Mar 2015 15:21:19 -0000 On 29.03.2015 18:17, Adrian Chadd wrote: > You know, I exactly wanted this about two days ago, but from userland. > > Do we expose this to userland? Actually my first attempt was to make a tool alike to umastat, but appeared that all vmem(9) structures are internal in C file, so I had to do it this way. > On 29 March 2015 at 03:02, Alexander Motin wrote: >> Author: mav >> Date: Sun Mar 29 10:02:29 2015 >> New Revision: 280805 >> URL: https://svnweb.freebsd.org/changeset/base/280805 >> >> Log: >> Add four new DDB commands to display vmem(9) statistics. >> >> In particular, such DDB commands were added: >> show vmem >> show all vmem >> show vmemdump >> show all vmemdump >> >> As possible usage, that allows to see KVA usage and fragmentation. >> >> Modified: >> head/sys/kern/subr_vmem.c >> >> Modified: head/sys/kern/subr_vmem.c >> ============================================================================== >> --- head/sys/kern/subr_vmem.c Sun Mar 29 07:48:02 2015 (r280804) >> +++ head/sys/kern/subr_vmem.c Sun Mar 29 10:02:29 2015 (r280805) >> @@ -1390,6 +1390,8 @@ vmem_dump(const vmem_t *vm , int (*pr)(c >> #endif /* defined(DDB) || defined(DIAGNOSTIC) */ >> >> #if defined(DDB) >> +#include >> + >> static bt_t * >> vmem_whatis_lookup(vmem_t *vm, vmem_addr_t addr) >> { >> @@ -1443,6 +1445,78 @@ vmem_print(vmem_addr_t addr, const char >> >> vmem_dump(vm, pr); >> } >> + >> +DB_SHOW_COMMAND(vmemdump, vmemdump) >> +{ >> + >> + if (!have_addr) { >> + db_printf("usage: show vmemdump \n"); >> + return; >> + } >> + >> + vmem_dump((const vmem_t *)addr, db_printf); >> +} >> + >> +DB_SHOW_ALL_COMMAND(vmemdump, vmemdumpall) >> +{ >> + const vmem_t *vm; >> + >> + LIST_FOREACH(vm, &vmem_list, vm_alllist) >> + vmem_dump(vm, db_printf); >> +} >> + >> +DB_SHOW_COMMAND(vmem, vmem_summ) >> +{ >> + const vmem_t *vm = (const void *)addr; >> + const bt_t *bt; >> + size_t ft[VMEM_MAXORDER], ut[VMEM_MAXORDER]; >> + size_t fs[VMEM_MAXORDER], us[VMEM_MAXORDER]; >> + int ord; >> + >> + if (!have_addr) { >> + db_printf("usage: show vmem \n"); >> + return; >> + } >> + >> + db_printf("vmem %p '%s'\n", vm, vm->vm_name); >> + db_printf("\tquantum:\t%zu\n", vm->vm_quantum_mask + 1); >> + db_printf("\tsize:\t%zu\n", vm->vm_size); >> + db_printf("\tinuse:\t%zu\n", vm->vm_inuse); >> + db_printf("\tfree:\t%zu\n", vm->vm_size - vm->vm_inuse); >> + db_printf("\tbusy tags:\t%d\n", vm->vm_nbusytag); >> + db_printf("\tfree tags:\t%d\n", vm->vm_nfreetags); >> + >> + memset(&ft, 0, sizeof(ft)); >> + memset(&ut, 0, sizeof(ut)); >> + memset(&fs, 0, sizeof(fs)); >> + memset(&us, 0, sizeof(us)); >> + TAILQ_FOREACH(bt, &vm->vm_seglist, bt_seglist) { >> + ord = SIZE2ORDER(bt->bt_size >> vm->vm_quantum_shift); >> + if (bt->bt_type == BT_TYPE_BUSY) { >> + ut[ord]++; >> + us[ord] += bt->bt_size; >> + } else if (bt->bt_type == BT_TYPE_FREE) { >> + ft[ord]++; >> + fs[ord] += bt->bt_size; >> + } >> + } >> + db_printf("\t\t\tinuse\tsize\t\tfree\tsize\n"); >> + for (ord = 0; ord < VMEM_MAXORDER; ord++) { >> + if (ut[ord] == 0 && ft[ord] == 0) >> + continue; >> + db_printf("\t%-15zu %zu\t%-15zu %zu\t%-16zu\n", >> + ORDER2SIZE(ord) << vm->vm_quantum_shift, >> + ut[ord], us[ord], ft[ord], fs[ord]); >> + } >> +} >> + >> +DB_SHOW_ALL_COMMAND(vmem, vmem_summall) >> +{ >> + const vmem_t *vm; >> + >> + LIST_FOREACH(vm, &vmem_list, vm_alllist) >> + vmem_summ((db_expr_t)vm, TRUE, count, modif); >> +} >> #endif /* defined(DDB) */ >> >> #define vmem_printf printf >> -- Alexander Motin