How does one pick an optimal block size for a cache with a specific size limit? For example, if I have a size limit of 900 bits for the whole cache, including tags and validity bits and everything, how do I choose the best block size to maximize utilized space? I assume it's different for directly-mapped caches vs. set-associative vs. fully-associative.
Brute forcing would be guessing and checking, but that seems inefficient. Is there a formula or something?