Max size of one swap slice

Matthew Dillon dillon at
Wed Aug 6 20:24:08 UTC 2008


    Hmm.  I see an issue that FreeBSD could correct to reduce wired
    memory use by the swap system.

    Your sys/blist.h has this:

	typedef u_int32_t       u_daddr_t;      /* unsigned disk address */

    and your sys/types.h has this:

	typedef int64_t       daddr_t;      /* unsigned disk address */

    sys/blist.h really assumes a 32 bit daddr_t.  It's amazing the code
    even still works with daddr_t at 64 bits and u_daddr_t at 32 bits.

    Changing that whole mess in sys/blist.h to a different typedef name,
    say swblk_t (which is already defined to be 32 bits), and renaming
    u_daddr_t to u_swblk_t, plus also changing the swblock structure
    in vm/swap_pager.c to use a 32 bit array elements instead of 64 bit
    array elements will cut the size of struct swblock almost in half.

    There is no real need for swap block addressing > 32 bits.  32 bits
    gives you swap in the terrabyte range.

struct swblock {
        struct swblock  *swb_hnext;
        vm_object_t     swb_object;
        vm_pindex_t     swb_index;
        int             swb_count;
        daddr_t         swb_pages[SWAP_META_PAGES]; <<<<<<<<< this array

    Any arithmatic accessing the elements would also have to be vetted
    for any necessary promotions.

					Matthew Dillon 
					<dillon at>

More information about the freebsd-stable mailing list