# Why timestamp in vm_map commented as version number?



## spmzt (Sep 25, 2022)

Hi,
I have been reading the kernel sources. The vm_map struct at the /usr/src/sys/vm/vm_map.h file, contained this line:

```
struct vm_map {
    struct vm_map_entry header;    /* List of entries */
    struct sx lock;            /* Lock for map data */
    struct mtx system_mtx;
    int nentries;            /* Number of entries */
    vm_size_t size;            /* virtual size */
    u_int timestamp;        /* ==================> Version number <==================== */
    u_char needs_wakeup;
    u_char system_map;        /* (c) Am I a system map? */
    vm_flags_t flags;        /* flags for this vm_map */
    vm_map_entry_t root;        /* Root of a binary search tree */
    pmap_t pmap;            /* (c) Physical map */
    vm_offset_t anon_loc;
    int busy;
#ifdef DIAGNOSTIC
    int nupdates;
#endif
};
```
Why timestamp commented as version number?


----------



## Phishfry (Sep 25, 2022)

That code is quite old too.
It would be interesting to look back at older BSD code to see what it had.
Did you run it down?



> @(#)vm_map.h    8.9 (Berkeley) 5/17/95
> *
> *
> * Copyright (c) 1987, 1990 Carnegie-Mellon University.
> ...


----------



## Phishfry (Sep 25, 2022)

Apples version uses the same comment.


> unsigned int        timestamp;    /* Version number */


----------



## Phishfry (Sep 25, 2022)

NetBSD too


> unsigned int        timestamp;    /* Version number */


----------



## richardtoohey2 (Sep 25, 2022)

Could be easier way to check version numbers?

If you have major, minor and patch level version numbers it can get messy trying to work out if 1.19.44 is newer than something else.

And you avoid the development versus marketing argument if the changes need a patch level, minor version or major version level bump.

Whereas a time stamp will be a single incremental value - highest value is newer version and you can sort versions easily.


----------



## _martin (Sep 26, 2022)

You need to understand/read the variable name in its context. It has nothing to do with the version of the file. 
Check here: vm_map(9). 
	
	



```
timestamp       Used to determine if the map has changed since its last ac-
                cess.
```


----------

