Introduce a new macro, UAO_USES_SWHASH() and use it to reduce the diff
with NetBSD. Also change some space into tabs for the same reason.
ok?
Index: uvm/uvm_aobj.c
===================================================================
RCS file: /cvs/src/sys/uvm/uvm_aobj.c,v
retrieving revision 1.93
diff -u -p -r1.93 uvm_aobj.c
--- uvm/uvm_aobj.c 26 Mar 2021 13:40:05 -0000 1.93
+++ uvm/uvm_aobj.c 29 Mar 2021 09:37:59 -0000
@@ -58,38 +58,39 @@
* Note: for hash tables, we break the address space of the aobj into blocks
* of UAO_SWHASH_CLUSTER_SIZE pages, which shall be a power of two.
*/
-#define UAO_SWHASH_CLUSTER_SHIFT 4
-#define UAO_SWHASH_CLUSTER_SIZE (1 << UAO_SWHASH_CLUSTER_SHIFT)
+#define UAO_SWHASH_CLUSTER_SHIFT 4
+#define UAO_SWHASH_CLUSTER_SIZE (1 << UAO_SWHASH_CLUSTER_SHIFT)
/* Get the "tag" for this page index. */
-#define UAO_SWHASH_ELT_TAG(PAGEIDX) \
- ((PAGEIDX) >> UAO_SWHASH_CLUSTER_SHIFT)
+#define UAO_SWHASH_ELT_TAG(idx) ((idx) >>
UAO_SWHASH_CLUSTER_SHIFT)
+#define UAO_SWHASH_ELT_PAGESLOT_IDX(idx) \
+ ((idx) & (UAO_SWHASH_CLUSTER_SIZE - 1))
/* Given an ELT and a page index, find the swap slot. */
-#define UAO_SWHASH_ELT_PAGESLOT_IDX(PAGEIDX) \
- ((PAGEIDX) & (UAO_SWHASH_CLUSTER_SIZE - 1))
-#define UAO_SWHASH_ELT_PAGESLOT(ELT, PAGEIDX) \
- ((ELT)->slots[(PAGEIDX) & (UAO_SWHASH_CLUSTER_SIZE - 1)])
+#define UAO_SWHASH_ELT_PAGESLOT(elt, idx) \
+ ((elt)->slots[UAO_SWHASH_ELT_PAGESLOT_IDX(idx)])
/* Given an ELT, return its pageidx base. */
-#define UAO_SWHASH_ELT_PAGEIDX_BASE(ELT) \
- ((ELT)->tag << UAO_SWHASH_CLUSTER_SHIFT)
+#define UAO_SWHASH_ELT_PAGEIDX_BASE(elt) \
+ ((elt)->tag << UAO_SWHASH_CLUSTER_SHIFT)
/* The hash function. */
-#define UAO_SWHASH_HASH(AOBJ, PAGEIDX) \
- (&(AOBJ)->u_swhash[(((PAGEIDX) >> UAO_SWHASH_CLUSTER_SHIFT) \
- & (AOBJ)->u_swhashmask)])
+#define UAO_SWHASH_HASH(aobj, idx) \
+ (&(aobj)->u_swhash[(((idx) >> UAO_SWHASH_CLUSTER_SHIFT) \
+ & (aobj)->u_swhashmask)])
/*
* The threshold which determines whether we will use an array or a
* hash table to store the list of allocated swap blocks.
*/
-#define UAO_SWHASH_THRESHOLD (UAO_SWHASH_CLUSTER_SIZE * 4)
+#define UAO_SWHASH_THRESHOLD (UAO_SWHASH_CLUSTER_SIZE * 4)
+#define UAO_USES_SWHASH(aobj) \
+ ((aobj)->u_pages > UAO_SWHASH_THRESHOLD)
/* The number of buckets in a hash, with an upper bound. */
-#define UAO_SWHASH_MAXBUCKETS 256
-#define UAO_SWHASH_BUCKETS(pages) \
- (min((pages) >> UAO_SWHASH_CLUSTER_SHIFT, UAO_SWHASH_MAXBUCKETS))
+#define UAO_SWHASH_MAXBUCKETS 256
+#define UAO_SWHASH_BUCKETS(pages) \
+ (min((pages) >> UAO_SWHASH_CLUSTER_SHIFT, UAO_SWHASH_MAXBUCKETS))
/*
@@ -253,7 +254,7 @@ uao_find_swslot(struct uvm_aobj *aobj, i
/*
* if hashing, look in hash table.
*/
- if (aobj->u_pages > UAO_SWHASH_THRESHOLD) {
+ if (UAO_USES_SWHASH(aobj)) {
struct uao_swhash_elt *elt =
uao_find_swhash_elt(aobj, pageidx, FALSE);
@@ -299,7 +300,7 @@ uao_set_swslot(struct uvm_object *uobj,
/*
* are we using a hash table? if so, add it in the hash.
*/
- if (aobj->u_pages > UAO_SWHASH_THRESHOLD) {
+ if (UAO_USES_SWHASH(aobj)) {
/*
* Avoid allocating an entry just to free it again if
* the page had not swap slot in the first place, and
@@ -351,7 +352,7 @@ static void
uao_free(struct uvm_aobj *aobj)
{
- if (aobj->u_pages > UAO_SWHASH_THRESHOLD) {
+ if (UAO_USES_SWHASH(aobj)) {
int i, hashbuckets = aobj->u_swhashmask + 1;
/*
@@ -441,7 +442,7 @@ uao_shrink_hash(struct uvm_object *uobj,
unsigned long new_hashmask;
int i;
- KASSERT(aobj->u_pages > UAO_SWHASH_THRESHOLD);
+ KASSERT(UAO_USES_SWHASH(aobj));
/*
* If the size of the hash table doesn't change, all we need to do is
@@ -743,7 +744,7 @@ uao_create(vsize_t size, int flags)
mflags = M_WAITOK;
/* allocate hash table or array depending on object size */
- if (aobj->u_pages > UAO_SWHASH_THRESHOLD) {
+ if (UAO_USES_SWHASH(aobj)) {
aobj->u_swhash = hashinit(UAO_SWHASH_BUCKETS(pages),
M_UVMAOBJ, mflags, &aobj->u_swhashmask);
if (aobj->u_swhash == NULL) {
@@ -1370,7 +1371,7 @@ uao_pagein(struct uvm_aobj *aobj, int st
{
boolean_t rv;
- if (aobj->u_pages > UAO_SWHASH_THRESHOLD) {
+ if (UAO_USES_SWHASH(aobj)) {
struct uao_swhash_elt *elt;
int bucket;
@@ -1504,7 +1505,7 @@ uao_dropswap_range(struct uvm_object *uo
end = INT64_MAX;
}
- if (aobj->u_pages > UAO_SWHASH_THRESHOLD) {
+ if (UAO_USES_SWHASH(aobj)) {
int i, hashbuckets = aobj->u_swhashmask + 1;
voff_t taghi;
voff_t taglo;