Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Dec 2016 10:32:26 -0500
From:      Shea Levy <shea@shealevy.com>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Detecting changes when mapping /dev/devstat
Message-ID:  <87mvfcnmgl.fsf@shlevy-laptop.i-did-not-set--mail-host-address--so-tickle-me>
In-Reply-To: <87r34o3ity.fsf@shlevy-laptop.i-did-not-set--mail-host-address--so-tickle-me>
References:  <87r34o3ity.fsf@shlevy-laptop.i-did-not-set--mail-host-address--so-tickle-me>

next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-=
Content-Type: text/plain

So looking into this more I see the thing to check is stat.allocated &&
stat.unit_number != -1. But there's a bigger problem of there being no
good way (as far as I can tell) to know how big of a mapping we want!
The number of devices is not enough, because depending on the order of
calls to devstat_new_entry and devstat_remove_entry the actually active
devices can live anywhere in the list. The best I can come up with is:

* map successively larger multiples of the page size.
* iterate through the map until I find numdevs structures with
  stat.allocated && stat.unit_number != -1 (and properly matching
  sequence numbers), mapping more pages in if needed.
* Check the generation number and reiterate, possibly dropping pages if all
  devices are now available and adding them if needed.

Can we do better? In particular, do we need to get the generation number
to detect when to reiterate?

Thanks,
Shea

Shea Levy <shea@shealevy.com> writes:

> Hi all,
>
> What is the appropriate way to detect changes when accessing devstat
> info via a mapping of /dev/devstat? I'm interested both in changes to
> the device list as a whole and new statistics on a given device.
>
> For new stats on a given device, it seems the only way to detect a new
> stat is to check the sequence number for that device. Is that right?
>
> For changes in the device list, it's a bit less clear. My hope was that
> I could map space for one more struct devstat than the current numdevs
> and just check to see if some field or other is nonzero, but in my
> glances through subr_devstat.c I'm not sure if there are any guarantees
> about those fields for structures past the current list, especially if a
> device was added and removed. Is there anything doable here?
>
> Thanks,
> Shea
>
> P.S. I wasn't quite sure which list was appropriate for this question,
> please feel free to point me to another!

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEE6ESKvwKkwnxgMLnaXAvWlX2G/icFAlhnz4oACgkQXAvWlX2G
/icsUhAAkggKWLIX4/gGh9QSR3+QgUOCBinhpwfBUcVLfILMvTuiJMyVrCazHJNH
ovyGfA1naRtEOkp29hgAv1Y0KzhgU1erYqAx/TD86NEl0arWmWoGCXiEdsUkjmSl
pOrn0i12Ijv8wvHRdL9NxvVJoW1tvIGuDozAQW69HJ2bQifU/cEFsxI3OTYhqiRv
6Cw0JTbXQzXrITYKKkcY3HZdUjFcKBG+XZ2YucPnLOCWK96/v6NZNXSYhtoaxPXL
CyAjaujlKHGlgbMzoDW7emxkxTpg3R+yNa3q1G7LitGflrqzgE33URll1TDY9/Y8
4SkM4TNcpySRtxj4hUF4Vgj1mX97H5e6y7nC7brYAGGiHa9vKyf3WofGCA0zL77s
2hS9l4sFAhz996iYOQf0PPBrAOkhJzvTyN8SXxPSEq5iEBej5QL+9w9dKYb6mBBw
uWQnYg2x9AsFqrv9oJU1i9I1SXYSkQmZf1MRuKgwwiDvltHmVWuo4mspP+ljnXqP
je0mlG4/sjGa7JxPvRWDlhMsFylOaEvg7bBau/g/2OZ0vXfgZA0nHycQkSoK7Ofm
XP0SjvzY9HFOY4AxjqXVdLq/2rsrU64OWZ0Mi/rHZa1Sf87J4UZsrYppQVeohdA+
ALnMgvE5kdMvYWO4/4FW/JM98hykkBrqey8iee+HqxW6eV3Xui4=
=bMB3
-----END PGP SIGNATURE-----
--=-=-=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87mvfcnmgl.fsf>