From owner-svn-src-head@FreeBSD.ORG Sun Mar 29 15:17:53 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 AFE30AD2; Sun, 29 Mar 2015 15:17:53 +0000 (UTC) Received: from mail-ie0-x232.google.com (mail-ie0-x232.google.com [IPv6:2607:f8b0:4001:c03::232]) (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 75A35EE4; Sun, 29 Mar 2015 15:17:53 +0000 (UTC) Received: by ierf6 with SMTP id f6so33450794ier.2; Sun, 29 Mar 2015 08:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=n2/mk/ehpKtXZloMl/gDfggpuvytJouD+3boZruiMoQ=; b=X47nfCwhpHzTUWRE70nS//A/GZwVZn7fFPotEpwpeGAh/ywIgweXXjOWBoLew0lQtI fhdoM++wuv9z0yFf/3UV63rPnF1dDvKsSuJJCLchcYUKFwv3B49mXRK9sAhvnJt1jCOc vhek+Qd8+OUEtscvbYy2bem9DQhMhSeJ5DCkjVAMJTJ2Bll264OIe1tO+iAgDaD7FJ8z jFTmKqaRmdIaIQNXUdK129j2swUddge55xt1zZm9B36yA6B5Ups4XYKOsJVeInjM22Pq PMyovcOf9h2V6anUpQB3wkIAtu4tGE5JLXIY6U7cMu3DTn5HwZh1gEgCnQXNLPE2UJOU CJvw== MIME-Version: 1.0 X-Received: by 10.50.143.42 with SMTP id sb10mr11932831igb.49.1427642272992; Sun, 29 Mar 2015 08:17:52 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.36.17.194 with HTTP; Sun, 29 Mar 2015 08:17:52 -0700 (PDT) In-Reply-To: <201503291002.t2TA2TbM021925@svn.freebsd.org> References: <201503291002.t2TA2TbM021925@svn.freebsd.org> Date: Sun, 29 Mar 2015 08:17:52 -0700 X-Google-Sender-Auth: dLQfrbtA_YsGNqzFdXhm6Tg3dFk Message-ID: Subject: Re: svn commit: r280805 - head/sys/kern From: Adrian Chadd To: Alexander Motin Content-Type: text/plain; charset=UTF-8 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:17:53 -0000 You know, I exactly wanted this about two days ago, but from userland. Do we expose this to userland? -a 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 >