From owner-freebsd-current@freebsd.org Mon Jul 10 09:45:35 2017 Return-Path: Delivered-To: freebsd-current@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 8CB2EDA2711 for ; Mon, 10 Jul 2017 09:45:35 +0000 (UTC) (envelope-from junchoon@dec.sakura.ne.jp) Received: from dec.sakura.ne.jp (dec.sakura.ne.jp [210.188.226.8]) (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 5A0C282BFF for ; Mon, 10 Jul 2017 09:45:35 +0000 (UTC) (envelope-from junchoon@dec.sakura.ne.jp) Received: from fortune.joker.local (124-18-21-125.dz.commufa.jp [124.18.21.125]) (authenticated bits=0) by dec.sakura.ne.jp (8.15.2/8.15.2/[SAKURA-WEB]/20080708) with ESMTPA id v6A9jT9W033161; Mon, 10 Jul 2017 18:45:29 +0900 (JST) (envelope-from junchoon@dec.sakura.ne.jp) Date: Mon, 10 Jul 2017 18:45:28 +0900 From: Tomoaki AOKI To: freebsd-current@freebsd.org Cc: Konstantin Belousov , otacilio.neto@bsd.com.br Subject: Re: type of vm.stats.vm.v_vnodepgsin vm.stats.vm.v_swappgsin, vm.stats.vm.v_vnodepgsout vm.stats.vm.v_swappgsout on AMD64 r320730 Message-Id: <20170710184528.8677740bc55681e331c2fbea@dec.sakura.ne.jp> In-Reply-To: <20170710071807.GO1935@kib.kiev.ua> References: <1c37db96-7cd2-91c9-011c-967a32a97f05@bsd.com.br> <20170710154046.58c3d7b14a227a20bea3e55b@dec.sakura.ne.jp> <20170710071807.GO1935@kib.kiev.ua> Organization: Junchoon corps X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; amd64-portbld-freebsd11.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jul 2017 09:45:35 -0000 Hm, for example, sysutils/lsof (userspace app) depends on kernel source, and I thought the one Otacilio mentioned is something like it. Anyway, we should wait for Otacilio's response. ;-) On Mon, 10 Jul 2017 10:18:07 +0300 Konstantin Belousov wrote: > On Mon, Jul 10, 2017 at 03:40:46PM +0900, Tomoaki AOKI wrote: > > Hi. > > > > Members v_swappgsin and v_vnodepgsin are declared on sys/sys/vmmeter.h > > as > > > > u_int on stable/11@r320798 [1] > > counter_u64_t on head@r320861 [2] > > > > respectively. > > > > Diggin in further, on head@r320861, counter_u64_t is typedef'ed as > > uint64_t * at line 32 of sys/sys/counter.h [3] like below. > > > > typedef uint64_t *counter_u64_t; > > > > So they're "pointers" on head, while "values" on stable/11. > > > > So, as you're on head, it seems you're casting "pointers (addresses)" to > > uint64_t "value". It could be huge and non-expected values. > > Your code would work as expected on stable/11. > > What ? counter_u64_t in userspace in nonsense. > > Whole struct vmmeter is useless in userspace, it is not exported by the > sysctls and is only used in kernel. Sysctl MIBs export individual > counters which should be used with appropriate type, but besides native > uint64_t, 32bit requests are also supported. > > This is why I asked about the type of the vm.v_something and asked for > the explicit fragment of the code which reads the MIBs. > > > > > [1] > > https://svnweb.freebsd.org/base/stable/11/sys/sys/vmmeter.h?annotate=320610 > > > > [2] > > https://svnweb.freebsd.org/base/head/sys/sys/vmmeter.h?annotate=317061 > > > > [3] > > https://svnweb.freebsd.org/base/head/sys/sys/counter.h?annotate=309745 > > > > > > On Sun, 9 Jul 2017 23:15:18 -0300 > > Otac?$B".lio wrote: > > > > > Dears > > > > > > I'm the maintainer of xosview and I'm debugging rather weird behavior > > > from it in the latest FreeBSD 12 revisions (12.0-CURRENT #0 r320730 > > > AMD64) . The problem is occurring on the lines responsible for > > > collecting statistics about paging. These lines follow: > > > > > > If (pageinfo) { > > > Pageinfo [0] = (uint64_t) vm.v_vnodepgsin + (uint64_t) vm.v_swappgsin; > > > Pageinfo [1] = (uint64_t) vm.v_vnodepgsout + (uint64_t) vm.v_swappgsout; > > > } > > > > > > This code works on FreeBSD 11 and until a short time ago it works at 12. > > > But now it returns extremely large values ?$B".".when interpreted as 64-bit > > > values. A debugging has shown that for this sysctl call the following > > > values ?$B".".are returned in the terminal: > > > sysctl vm.stats.vm.v_vnodepgsin vm.stats.vm.v_swappgsin > > > vm.stats.vm.v_vnodepgsout vm.stats.vm.v_swappgsout > > > Vm.stats.vm.v_vnodepgsin: 47432 > > > Vm.stats.vm.v_swappgsin: 0 > > > Vm.stats.vm.v_vnodepgsout: 19 > > > Vm.stats.vm.v_swappgsout: 0 > > > > > > While the code returns things like: > > > > > > Pageinf [0] = 34359785800; Pageinfo [1] = 140733193388051 > > > Pageinf [0] = 34359785800; Pageinfo [1] = 2678138638516092947 > > > > > > After some tests I found that if I change the code to use a typecast to > > > (uint32_t) then Xosview works correctly.: > > > If (pageinfo) { > > > Pageinfo [0] = (uint32_t) ((uint64_t) vm.v_vnodepgsin + (uint64_t) > > > vm.v_swappgsin); > > > Pageinfo [1] = (uint32_t) ((uint64_t) vm.v_vnodepgsout + (uint64_t) > > > vm.v_swappgsout); > > > } > > > > > > For me, it seems that some code in the kernel is storing values ?$B".".as 32 > > > bits where it should be 64 bits. Is this behavior correct? > > > > > > []'s > > > > > > -Otac?$B".lio > > > _______________________________________________ > > > freebsd-current@freebsd.org mailing list > > > https://lists.freebsd.org/mailman/listinfo/freebsd-current > > > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > > > > > > > > > > > > -- > > Tomoaki AOKI > > _______________________________________________ > > freebsd-current@freebsd.org mailing list > > https://lists.freebsd.org/mailman/listinfo/freebsd-current > > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > -- Tomoaki AOKI