From owner-freebsd-current@freebsd.org Mon Jul 10 05:51:59 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 9809FD9E45F for ; Mon, 10 Jul 2017 05:51:59 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 2F10E7CD69 for ; Mon, 10 Jul 2017 05:51:59 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v6A5pqUm007686 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 10 Jul 2017 08:51:52 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v6A5pqUm007686 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v6A5ppQO007685; Mon, 10 Jul 2017 08:51:51 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 10 Jul 2017 08:51:51 +0300 From: Konstantin Belousov To: Otac??lio Cc: freebsd-current 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: <20170710055151.GL1935@kib.kiev.ua> References: <1c37db96-7cd2-91c9-011c-967a32a97f05@bsd.com.br> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1c37db96-7cd2-91c9-011c-967a32a97f05@bsd.com.br> User-Agent: Mutt/1.8.3 (2017-05-23) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home 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 05:51:59 -0000 On Sun, Jul 09, 2017 at 11:15:18PM -0300, Otac??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; Why these casts are needed ? What is the type of vm.v_vnodepgsin ? > 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 ??????when interpreted as 64-bit > values. A debugging has shown that for this sysctl call the following > values ??????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 ??????as 32 > bits where it should be 64 bits. Is this behavior correct? Show the _exact_ code fragment that reads the MIBs values.