Re: [Question] st_blocks of shm is number of pages, not 512B blocks

Konstantin Belousov <[email protected]>
Newsgroups gmane.os.freebsd.devel.file-systems
Message-ID <[email protected]>
On Sat, Aug 15, 2026 at 10:59:24AM +0900, David Timber wrote:
> On 8/2/26 22:54, Konstantin Belousov wrote:
> > The page size as st_blocks multiplier is natural because shm is allocated
> > in pages.  I wanted to return the number of large pages for st_blocks for
> > the largepage shmfds as well, but somebody argued against it AFAIR.
> Perhaps shm can implement fstatfs() and return whatever largepage
> decided in f_bsize? Just a thought. Seems to me that the information is
> lost from userspace after creating the shm. I wonder if there's a
> standard interface to query it back after creating it. If not, f_bsize
> seems to be the candidate. Just a thought.
There is no filesystem to perform fstatfs() on.

BUt there is ioctl(shmfd, FIOGSHMLPGCNF, &struct shm_largepage_conf)
which returns psind, the index of the largepage size in the array
returned by getpagesizes().

> 
> Anyway, I wasn't really nitpicking why FreeBSD does things the way it
> does. I was just wondering if there's actual use case in userspace where
> returning st_blocks in system page size unit makes more sense. By that I
> mean, yes, the page size IS the allocation unit so it makes perfect
> sense. It saves division and multiplication to do the alignment dance.
> 
> Me thinks that not being aligned to the usual 512-byte unit with the
> rest of the implementation does more harm than good...

Ok, https://reviews.freebsd.org/D58942
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.