From owner-freebsd-hackers@freebsd.org Mon Oct 26 15:33:54 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 71274A1D7F2 for ; Mon, 26 Oct 2015 15:33:54 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-io0-x22f.google.com (mail-io0-x22f.google.com [IPv6:2607:f8b0:4001:c06::22f]) (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 3E2231839 for ; Mon, 26 Oct 2015 15:33:54 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by iody8 with SMTP id y8so34517532iod.1 for ; Mon, 26 Oct 2015 08:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=D1jreURCOLYzIYvYqm5kflvKiG/iSDB6eGOHN1oLcus=; b=0Zxa/q6kF6wE+z4Bfz6/Xx8uVzELtIHJpncki3We5iUUw4Nbp4wQoWuhJZ57Q3VwfI 8S8bGfiumxIeqPqBOVZZvZ+RDzKgIy6oWU0rJmGZzwi4dKHANZYFIGPfRzLMYEbnXT3V 4wHbp/nboOI3wYlgKY0DCqoKwnN4Npyw8OrfzbnOUcTraU73HPYALFa4GO/mO6s+IFlQ cmNChoKi2q8ybNFU815vE3gBv1PhVIhPPMVngHSj3FPWXZoE99nGuUyFEwdYbKw28oun WBg49H01aXwIaIGdandxlUOPBDs98+8DqIjG1m/pMeNgrSFCGk3u+z/1403ogJdg5rfd 98fw== MIME-Version: 1.0 X-Received: by 10.107.46.228 with SMTP id u97mr12418434iou.165.1445873633558; Mon, 26 Oct 2015 08:33:53 -0700 (PDT) Received: by 10.36.46.66 with HTTP; Mon, 26 Oct 2015 08:33:53 -0700 (PDT) In-Reply-To: References: Date: Mon, 26 Oct 2015 08:33:53 -0700 Message-ID: Subject: Re: vmtotal consumes significant portion of cpu cycles From: Adrian Chadd To: Jia-Shiun Li Cc: "freebsd-hackers@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Mailman-Approved-At: Mon, 26 Oct 2015 16:22:20 +0000 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2015 15:33:54 -0000 hiya, yes, please do. I recall there's some global vm lock and big hash/list walk involved when vmtotal() is called. :( -a On 26 October 2015 at 06:28, Jia-Shiun Li wrote: > Hi all, > > I noticed that 'sysctl -vm 1' consumes about 5% cpu time on a machine with > 2x 6-core Xeon E5v3 and 64GB memory. That's a lot for a monitoring tool. > > After digging a while I found that it is vmtotal() in kernel that consumes > major cycles. When memory usage is high the cost of vmtotal() rises too. It > is reproducible with sysctl when memory utilization is high: > > % time repeat 100 sysctl vm.vmtotal > /dev/null > 0.055u 8.102s 0:08.19 99.5% 31+175k 0+0io 0pf+0w > > % top > last pid: 40272; load averages: 0.32, 4.74, 8.01 up 3+01:19:54 > 17:23:59 > 58 processes: 1 running, 57 sleeping > CPU: 0.1% user, 0.0% nice, 1.6% system, 0.1% interrupt, 98.3% idle > Mem: 4509M Active, 52G Inact, 2819M Wired, 1572M Buf, 2930M Free > Swap: 3598M Total, 3598M Free > > PID USERNAME THR PRI NICE SIZE RES STATE C TIME CPU > COMMAND > 46841 root 30 20 0 9248M 7930M kqread 9 20.8H 11.88% bhyve > 49914 jsli 1 23 0 19320K 3884K select 5 134:08 4.79% systat > > > In FreeBSD source tree systat and vmstat are major user. Other tools like > bsnmpd may use it too via sysctl. > > I don't have idea yet how this can be improved. Shall I create a bug to > keep track of it? > > > -Jia-Shiun > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"