FreeBSD Bugzilla – Attachment 185184 Details for
Bug 221356
[patch] Improve swapon_check_swzone() function in swap_pager.c
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Improve swapon_check_swzone() function
swap_pager.diff (text/plain), 3.81 KB, created by
ota
on 2017-08-09 05:22:20 UTC
(
hide
)
Description:
Improve swapon_check_swzone() function
Filename:
MIME Type:
Creator:
ota
Created:
2017-08-09 05:22:20 UTC
Size:
3.81 KB
patch
obsolete
>Improve swapon_check_swzone() function. > >Change to more descriptive swapon_check_swzone() warnings. >#1 Indicate half the size is recommended size. >(I couldn't figure out and don't know why half is recommended, though.) >#2 Advice when the swap device size exceeds the max size. > >Convert swap_pager_full to static variable as it is not used in global space. >Add a unit to swap_total description. >Call uma_zone_get_max() to find proper swap_maxpages. >Use swap_maxpages and other global variable in swapon_check_swzone(). >Convert swapon_check_swzone() to a void function. > >Index: vm/swap_pager.c >=================================================================== >--- vm/swap_pager.c (revision 321376) >+++ vm/swap_pager.c (working copy) >@@ -155,7 +156,7 @@ > > static vm_ooffset_t swap_total; > SYSCTL_QUAD(_vm, OID_AUTO, swap_total, CTLFLAG_RD, &swap_total, 0, >- "Total amount of available swap storage."); >+ "Total bytes of all swap storages."); > static vm_ooffset_t swap_reserved; > SYSCTL_QUAD(_vm, OID_AUTO, swap_reserved, CTLFLAG_RD, &swap_reserved, 0, > "Amount of swap storage needed to back all allocated anonymous memory."); >@@ -315,7 +316,7 @@ > #define SWM_FREE 0x02 /* free, period */ > #define SWM_POP 0x04 /* pop out */ > >-int swap_pager_full = 2; /* swap space exhaustion (task killing) */ >+static int swap_pager_full = 2; /* swap space exhaustion (task killing) */ > static int swap_pager_almost_full = 1; /* swap space exhaustion (w/hysteresis)*/ > static int nsw_rcount; /* free read buffers */ > static int nsw_wcount_sync; /* limit write buffers / synchronous */ >@@ -550,6 +558,7 @@ > */ > n -= ((n + 2) / 3); > } while (n > 0); >+ n = uma_zone_get_max(swap_zone); > if (n2 != n) > printf("Swap zone entries reduced from %lu to %lu.\n", n2, n); > swap_maxpages = n * SWAP_META_PAGES; >@@ -2108,27 +2135,39 @@ > > /* > * Check that the total amount of swap currently configured does not >- * exceed half the theoretical maximum. If it does, print a warning >- * message and return -1; otherwise, return 0. >+ * exceed half or full of the maximum. If it does, print a warning >+ * message accordingly. > */ >-static int >-swapon_check_swzone(unsigned long npages) >+static void >+swapon_check_swzone() > { >- unsigned long maxpages; >+ unsigned long npages = swap_total / PAGE_SIZE; > >- /* absolute maximum we can handle assuming 100% efficiency */ >- maxpages = uma_zone_get_max(swap_zone) * SWAP_META_PAGES; >+ printf("swap_pager_avail=%d and swap_maxpages=%lu\n", >+ swap_pager_avail, swap_maxpages); > >+ if (npages <= swap_maxpages / 2) { >+ return; >+ } >+ /* we exceeded maximum and won't be able to use extra pages */ >+ else if (npages > swap_maxpages) { >+ printf("warning: total configured swap (%lu pages) " >+ "exceeds maximum amount (%lu pages).\n", >+ npages, swap_maxpages); >+ printf("%d devices will be used in round-robin but " >+ "%lu pages will not be used\n", >+ nswapdev, npages - swap_maxpages); >+ return; >+ } > /* recommend using no more than half that amount */ >- if (npages > maxpages / 2) { >+ else { > printf("warning: total configured swap (%lu pages) " > "exceeds maximum recommended amount (%lu pages).\n", >- npages, maxpages / 2); >+ npages, swap_maxpages / 2); > printf("warning: increase kern.maxswzone " > "or reduce amount of swap.\n"); >- return (-1); >+ return; > } >- return (0); > } > > static void >@@ -2196,7 +2235,7 @@ > nswapdev++; > swap_pager_avail += nblks - 2; > swap_total += (vm_ooffset_t)nblks * PAGE_SIZE; >- swapon_check_swzone(swap_total / PAGE_SIZE); >+ swapon_check_swzone(); > swp_sizecheck(); > mtx_unlock(&sw_dev_mtx); > } >Index: vm/swap_pager.h >=================================================================== >--- vm/swap_pager.h (revision 321376) >+++ vm/swap_pager.h (working copy) >@@ -73,7 +73,6 @@ > > #ifdef _KERNEL > >-extern int swap_pager_full; > extern int swap_pager_avail; > > struct xswdev;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 221356
: 185184 |
187070
|
187071