On 2/11/23 14:40, Warner Losh wrote:
I was going to do something like:

+    if (host_page_size != TARGET_PAGE_SIZE) {
+        if (host_page_size > TARGET_PAGE_SIZE) {
+            /* Scale up */
+            pages *= host_page_size / TARGET_PAGE_SIZE;
+        } else {
+            /* Scale down with truncation */
+            pages /= TARGET_PAGE_SIZE / host_page_size;
+        }
+    }
in a helper function. Does multdiv64 replace that?

Yes, it uses a 128-bit intermediate result, so no overflow.
Obviously the above works as well, but perhaps premature optimization.


r~

Reply via email to